public AreaDto GetArea(string directory) { AreaDto area = null; bool isPath = directory.Contains(Path.DirectorySeparatorChar); string path = isPath ? directory : PathUtils.FinalizePath(DirectoryPath + directory); if (!Directory.Exists(path)) { return(null); } string directoryName = isPath ? Path.GetFileName(directory) : directory; if (Areas.ContainsKey(directoryName)) { area = Areas[directoryName]; } if (area == null) { area = AreaProcessor.BuildDto(path); } area.Type = Type; AreaProcessor.RefreshDto(area); Areas[area.Directory] = area; return(area); }
public Area GetArea(Guid id) { if (Areas.ContainsKey(id)) { return(Areas[id]); } return(null); }
internal static Area GetArea(int code) { if (Areas.ContainsKey(code)) { return(Areas[code]); } return(new Area()); }
public static bool GetIsDuty(int key) { if (Areas.ContainsKey(key)) { return(Areas[key].isDuty); } else { return(false); } }
/// <summary> /// Returns an Area by a given area ID /// </summary> /// <param name="id">The ID of the area</param> /// <returns>The area wanted, if it exists otherwise null</returns> public Area GetAreaByID(uint id) { if (Areas.ContainsKey(id)) { return(Areas[id]); } else { Debug.Log("Map::getAreaByID - There exists no area with this ID"); return(null); } }
/// <summary> /// Removes an area by id, and sets parentArea for the hexcells in this area null /// <param name="areaId">the ID of the Area</param> void RemoveArea(uint areaId) { if (Areas.ContainsKey(areaId)) { Area areaToRemove = Areas[areaId]; foreach (HexCell cell in areaToRemove.Cells) { cell.ParentArea = null; } Areas.Remove(areaId); } }
/// <summary> /// Generates the biomes each area has /// </summary> void GenerateBiomes() { AreaGraph = new AreaGraph(Areas.Values.ToList(), this); AreaGraph.ColorGraph(); MergeAreasWithSameBiome(AreaGraph); foreach (AreaNode node in AreaGraph.GetNodes()) { if (Areas.ContainsKey(node.NodeID)) { Area areaForNode = Areas[node.NodeID]; areaForNode.GenerateBiomeForArea(node.GetColor()); } } }
internal static Instance GetInstance(int code) { if (Areas.ContainsKey(code)) { return(Areas[code].Instance); } if (code != 0) { var @event = new SentryEvent("Missing instance code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new Instance(string.Format("알 수 없는 임무 ({0})", code), 0, 0, 0)); }
private void SetWallAreas() { var upWindWall = new Wall(Width, Height, EdgeDistance, Wall.Rotation.UpWind); var downWindWall = new Wall(Width, Height, EdgeDistance, Wall.Rotation.DownWind); var crossWindWall = new Wall(Length, Height, EdgeDistance, Wall.Rotation.Crosswind); var areas = upWindWall.Areas.Concat(downWindWall.Areas) .Concat(crossWindWall.Areas); foreach (var area in areas) { if (!Areas.ContainsKey(area.Key)) { Areas.Add(area.Key, area.Value); } } }
protected bool DeleteArea(AreaDto area, bool notify = true) { if (area is not AreaDto || area.Type != Type || String.IsNullOrEmpty(area.Path) || !area.Path.StartsWith(DirectoryPath) || !Directory.Exists(area.Path)) { return(false); } Directory.Delete(area.Path, true); if (Areas.ContainsKey(area.Directory)) { Areas.Remove(area.Directory); if (notify) { InvokeDataChanged(); } } return(true); }
public static string GetAreaName(int key) { if (Areas.ContainsKey(key)) { return(Areas[key].Name); } else { if (key != 0) { var @event = new SentryEvent("Missing area code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = key.ToString(); Sentry.ReportAsync(@event); } return(string.Format("알 수 없는 지역 ({0})", key)); } }
/// <summary> /// Merges areas that have the same color in the area graph /// </summary> void MergeAreasWithSameBiome(AreaGraph g) { // FIND ALL AREAS THAT HAVE TO BE MERGED WITH THIS AREA // MERGE ALL AT ONCE List <List <uint> > listOfAreasToMerge = g.GetAreasToMerge(); foreach (List <uint> areasToMerge in listOfAreasToMerge) { int size = 0; List <HexCell> cellsInNewArea = new List <HexCell>(); int tier = 0; foreach (uint areaID in areasToMerge) { if (Areas.ContainsKey(areaID)) { Area mergeArea = Areas[areaID]; // use capacity if merge area not completely filled // aka can add to this area if map is expanding size += mergeArea.Cells.Capacity; cellsInNewArea.AddRange(mergeArea.Cells); tier = (tier < mergeArea.Tier) ? mergeArea.Tier : tier; RemoveArea(areaID); } else { Debug.LogError("trying to acces area that does not exist. ID: " + areaID); } }// end foreach uint areaID // accumulated all things about the merging ares from cell to capcaity to tier Area newMergedArea = new Area(size); newMergedArea.SetTier(tier); foreach (HexCell cellInNewArea in cellsInNewArea) { newMergedArea.TryEstablishRelationWithCell(cellInNewArea); } Areas.Add(newMergedArea.AreaID, newMergedArea); //Debug.Log("Created new Area with ID: " + newMergedArea.AreaID); AreaGraph.MergeNodesIntoNewNode(areasToMerge, newMergedArea.AreaID); }// end foreach list uint }
// This is O(n) time protected override void _handlePaging(KnyttPoint location) { List <KnyttPoint> q_remove = new List <KnyttPoint>(); List <KnyttPoint> q_add = new List <KnyttPoint>(); // Iterate over the current set, and remove foreach (var l in this.Areas.Keys) { if (!isIn(l, location)) { q_remove.Add(l); } } // Iterate over the new area and add any that aren't in this.Areas for (int y = location.y - BorderSize.y; y <= location.y + BorderSize.y; y++) { for (int x = location.x - BorderSize.x; x <= location.x + BorderSize.x; x++) { var kp = new KnyttPoint(x, y); if (!Areas.ContainsKey(kp)) { q_add.Add(kp); } } } // Now just parse the queues foreach (var l in q_remove) { pageOut(l); } foreach (var l in q_add) { pageIn(l); } }