예제 #1
0
        public Polygon2D(List <Vector2Int> points)
        {
            this.points = points;

            if (!RoomTemplatesLoader.IsClockwiseOriented(points.Select(x => x.ToCustomIntVector2()).ToList()))
            {
                this.points.Reverse();
            }

            CheckValidity();
        }
예제 #2
0
        public PolygonGrid2D GetOutline()
        {
            try
            {
                var polygon = RoomTemplatesLoader.GetPolygonFromRoomTemplate(gameObject);

                return(polygon);
            }
            catch (ArgumentException)
            {
                return(null);
            }
        }
예제 #3
0
        private RoomTemplateGrid2D GetRoomTemplate(GameObject roomTemplatePrefab)
        {
            if (prefabToRoomTemplateMapping.ContainsKey(roomTemplatePrefab))
            {
                return(prefabToRoomTemplateMapping[roomTemplatePrefab]);
            }

            var roomTemplate = RoomTemplatesLoader.GetRoomTemplate(roomTemplatePrefab);

            prefabToRoomTemplateMapping.Add(roomTemplatePrefab, roomTemplate);

            return(roomTemplate);
        }
예제 #4
0
        private RoomTemplateGrid2D GetRoomTemplate(GameObject roomTemplatePrefab)
        {
            if (prefabToRoomTemplateMapping.ContainsKey(roomTemplatePrefab))
            {
                return(prefabToRoomTemplateMapping[roomTemplatePrefab]);
            }

            if (RoomTemplatesLoader.TryGetRoomTemplate(roomTemplatePrefab, out var roomTemplate, out var result))
            {
                prefabToRoomTemplateMapping.Add(roomTemplatePrefab, roomTemplate);
                return(roomTemplate);
            }

            Debug.LogError($"There was a problem when loading the room template \"{roomTemplatePrefab.name}\":");
            foreach (var error in result.Errors)
            {
                Debug.LogError($"- {error}");
            }

            throw new ConfigurationException("Please fix all the errors above and try again");
        }