/// <summary> /// Creates room and adds it to <see cref="RoomGrid"/> /// </summary> /// <param name="location">Location in the grid</param> /// <param name="replace">Will replace room at that location if set true</param> /// <typeparam name="T"></typeparam> /// <returns>Returns created room</returns> public Room CreateRoom <T>(Room.GridLocation location, bool replace = true) where T : Room { if (replace) { TryDestroyRoom(location); } if (!replace && RoomGrid.ContainsKey(location)) { return(null); } var prefab = PrefabHelper.GetRoomPrefab <T>(); var newRoom = Instantiate(prefab, transform).GetComponent <Room>(); newRoom.Create(location); newRoom.Populate(); RoomGrid.Add(location, newRoom); return(newRoom); }