public Polygon2D(List <Vector2Int> points) { this.points = points; if (!RoomTemplatesLoader.IsClockwiseOriented(points.Select(x => x.ToCustomIntVector2()).ToList())) { this.points.Reverse(); } CheckValidity(); }
public PolygonGrid2D GetOutline() { try { var polygon = RoomTemplatesLoader.GetPolygonFromRoomTemplate(gameObject); return(polygon); } catch (ArgumentException) { return(null); } }
private RoomTemplateGrid2D GetRoomTemplate(GameObject roomTemplatePrefab) { if (prefabToRoomTemplateMapping.ContainsKey(roomTemplatePrefab)) { return(prefabToRoomTemplateMapping[roomTemplatePrefab]); } var roomTemplate = RoomTemplatesLoader.GetRoomTemplate(roomTemplatePrefab); prefabToRoomTemplateMapping.Add(roomTemplatePrefab, roomTemplate); return(roomTemplate); }
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"); }