| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class Room : MonoBehaviour |
| public class Room : MonoBehaviour |
| { |
| { |
| private void Awake() |
| private void Awake() |
| { |
| { |
| if (this.m_musicPrefab) |
| if (this.m_musicPrefab) |
| { |
| { |
| UnityEngine.Object.Instantiate<MusicVolume>(this.m_musicPrefab, base.transform).m_sizeFromRoom = this; |
| UnityEngine.Object.Instantiate<MusicVolume>(this.m_musicPrefab, base.transform).m_sizeFromRoom = this; |
| } |
| } |
| } |
| } |
| |
| |
| private void OnDrawGizmos() |
| private void OnDrawGizmos() |
| { |
| { |
| Gizmos.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); |
| Gizmos.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); |
| Gizmos.matrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, new Vector3(1f, 1f, 1f)); |
| Gizmos.matrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, new Vector3(1f, 1f, 1f)); |
| Gizmos.DrawWireCube(Vector3.zero, new Vector3((float)this.m_size.x, (float)this.m_size.y, (float)this.m_size.z)); |
| Gizmos.DrawWireCube(Vector3.zero, new Vector3((float)this.m_size.x, (float)this.m_size.y, (float)this.m_size.z)); |
| Gizmos.matrix = Matrix4x4.identity; |
| Gizmos.matrix = Matrix4x4.identity; |
| } |
| } |
| |
| |
| public int GetHash() |
| public int GetHash() |
| { |
| { |
| return Utils.GetPrefabName(base.gameObject).GetStableHashCode(); |
| return Utils.GetPrefabName(base.gameObject).GetStableHashCode(); |
| } |
| } |
| |
| |
| private void OnEnable() |
| private void OnEnable() |
| { |
| { |
| this.m_roomConnections = null; |
| this.m_roomConnections = null; |
| } |
| } |
| |
| |
| public RoomConnection[] GetConnections() |
| public RoomConnection[] GetConnections() |
| { |
| { |
| if (this.m_roomConnections == null) |
| if (this.m_roomConnections == null) |
| { |
| { |
| this.m_roomConnections = base.GetComponentsInChildren<RoomConnection>(false); |
| this.m_roomConnections = base.GetComponentsInChildren<RoomConnection>(false); |
| } |
| } |
| return this.m_roomConnections; |
| return this.m_roomConnections; |
| } |
| } |
| |
| |
| public RoomConnection GetConnection(RoomConnection other) |
| public RoomConnection GetConnection(RoomConnection other) |
| { |
| { |
| RoomConnection[] connections = this.GetConnections(); |
| RoomConnection[] connections = this.GetConnections(); |
| Room.tempConnections.Clear(); |
| Room.tempConnections.Clear(); |
| foreach (RoomConnection roomConnection in connections) |
| foreach (RoomConnection roomConnection in connections) |
| { |
| { |
| if (roomConnection.m_type == other.m_type) |
| if (roomConnection.m_type == other.m_type) |
| { |
| { |
| Room.tempConnections.Add(roomConnection); |
| Room.tempConnections.Add(roomConnection); |
| } |
| } |
| } |
| } |
| if (Room.tempConnections.Count == 0) |
| if (Room.tempConnections.Count == 0) |
| { |
| { |
| return null; |
| return null; |
| } |
| } |
| return Room.tempConnections[UnityEngine.Random.Range(0, Room.tempConnections.Count)]; |
| return Room.tempConnections[UnityEngine.Random.Range(0, Room.tempConnections.Count)]; |
| } |
| } |
| |
| |
| public RoomConnection GetEntrance() |
| public RoomConnection GetEntrance() |
| { |
| { |
| RoomConnection[] connections = this.GetConnections(); |
| RoomConnection[] connections = this.GetConnections(); |
| ZLog.Log("Connections " + connections.Length.ToString()); |
| ZLog.Log("Connections " + connections.Length.ToString()); |
| foreach (RoomConnection roomConnection in connections) |
| foreach (RoomConnection roomConnection in connections) |
| { |
| { |
| if (roomConnection.m_entrance) |
| if (roomConnection.m_entrance) |
| { |
| { |
| return roomConnection; |
| return roomConnection; |
| } |
| } |
| } |
| } |
| return null; |
| return null; |
| } |
| } |
| |
| |
| public bool HaveConnection(RoomConnection other) |
| public bool HaveConnection(RoomConnection other) |
| { |
| { |
| RoomConnection[] connections = this.GetConnections(); |
| RoomConnection[] connections = this.GetConnections(); |
| for (int i = 0; i < connections.Length; i++) |
| for (int i = 0; i < connections.Length; i++) |
| { |
| { |
| if (connections[i].m_type == other.m_type) |
| if (connections[i].m_type == other.m_type) |
| { |
| { |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| return false; |
| return false; |
| } |
| } |
| |
| |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| return string.Format("{0}, Enabled: {1}, {2}, {3}", new object[] |
| return string.Format("{0}, Enabled: {1}, {2}, {3}", new object[] |
| { |
| { |
| base.name, |
| base.name, |
| this.m_enabled, |
| this.m_enabled, |
| this.m_theme, |
| this.m_theme, |
| this.m_entrance ? "Entrance" : (this.m_endCap ? "EndCap" : "Room") |
| this.m_entrance ? "Entrance" : (this.m_endCap ? "EndCap" : "Room") |
| }); |
| }); |
| } |
| } |
| |
| |
| private static List<RoomConnection> tempConnections = new List<RoomConnection>(); |
| private static List<RoomConnection> tempConnections = new List<RoomConnection>(); |
| |
| |
| public Vector3Int m_size = new Vector3Int(8, 4, 8); |
| public Vector3Int m_size = new Vector3Int(8, 4, 8); |
| |
| |
| [BitMask(typeof(Room.Theme))] |
| [BitMask(typeof(Room.Theme))] |
| public Room.Theme m_theme = Room.Theme.Crypt; |
| public Room.Theme m_theme = Room.Theme.Crypt; |
| |
| |
| public bool m_enabled = true; |
| public bool m_enabled = true; |
| |
| |
| public bool m_entrance; |
| public bool m_entrance; |
| |
| |
| public bool m_endCap; |
| public bool m_endCap; |
| |
| |
| public bool m_divider; |
| public bool m_divider; |
| |
| |
| public int m_endCapPrio; |
| public int m_endCapPrio; |
| |
| |
| public int m_minPlaceOrder; |
| public int m_minPlaceOrder; |
| |
| |
| public float m_weight = 1f; |
| public float m_weight = 1f; |
| |
| |
| public bool m_faceCenter; |
| public bool m_faceCenter; |
| |
| |
| public bool m_perimeter; |
| public bool m_perimeter; |
| |
| |
| [NonSerialized] |
| [NonSerialized] |
| public int m_placeOrder; |
| public int m_placeOrder; |
| |
| |
| [NonSerialized] |
| [NonSerialized] |
| public int m_seed; |
| public int m_seed; |
| |
| |
| public MusicVolume m_musicPrefab; |
| public MusicVolume m_musicPrefab; |
| |
| |
| private RoomConnection[] m_roomConnections; |
| private RoomConnection[] m_roomConnections; |
| |
| |
| public enum Theme |
| public enum Theme |
| { |
| { |
| None, |
| None, |
| Crypt, |
| Crypt, |
| SunkenCrypt, |
| SunkenCrypt, |
| Cave = 4, |
| Cave = 4, |
| ForestCrypt = 8, |
| ForestCrypt = 8, |
| GoblinCamp = 16, |
| GoblinCamp = 16, |
| MeadowsVillage = 32, |
| MeadowsVillage = 32, |
| MeadowsFarm = 64, |
| MeadowsFarm = 64, |
| DvergerTown = 128, |
| DvergerTown = 128, |
| DvergerBoss = 256, |
| DvergerBoss = 256, |
| ForestCryptHildir = 512, |
| ForestCryptHildir = 512, |
| CaveHildir = 1024, |
| CaveHildir = 1024, |
| . | PlainsFortHildir = 2048 |
| PlainsFortHildir = 2048, |
| |
| AshlandRuins = 4096, |
| |
| FortressRuins = 8192 |
| } |
| } |
| } |
| } |
| |
| |