Example #1
0
        public void AddRoomAttribute(int height, int width, RoomAttributeSO roomAttribute)
        {
            if (!AttributeToCoordinates.ContainsKey(roomAttribute))
            {
                AttributeToCoordinates.Add(roomAttribute, new List <IntPair>());
            }

            AttributeToCoordinates[roomAttribute].Add(IntPair.CreatePair(height, width));
            AttributeLayout[height, width].Add(roomAttribute);
        }
Example #2
0
        public List <T> GetRoomsWithAttribute <T>(RoomAttributeSO roomAttribute)
        {
            if (!AttributeToCoordinates.ContainsKey(roomAttribute))
            {
                return(null);
            }

            var coordinates = AttributeToCoordinates[roomAttribute];

            var rooms = new List <T>();

            coordinates.ForEach(c =>
            {
                var script = Rooms[c.x, c.y].GetComponent <T>();
                if (script != null)
                {
                    rooms.Add(script);
                }
            });

            return(rooms);
        }