private bool Clean() { var nonStructureItems = Blueprint.Cell.Items.Where(i => !Blueprint.Cost.Items.ContainsKey(i.Name)); if (nonStructureItems.Any()) { foreach (var item in nonStructureItems) { item.Free(); AddSubTask(new Pickup(item)); AddSubTask(new Drop(Blueprint.Cell.GetPathableNeighbour())); } return(false); } var structuresToClean = Loc.GetIdService() .GetStructuresInCell(Blueprint.Cell) .Where(c => !c.Buildable); if (structuresToClean.Any()) { foreach (var structureToClean in structuresToClean) { AddSubTask(new RemoveStructure(structureToClean)); } return(false); } return(true); }
private List <ItemData> GetItemsByCriteria(string criteria) { List <ItemData> items = DomainCells.GetCells().SelectMany(c => c?.Items.Where(item => item.IsType(criteria) && !item.IsReserved())).ToList(); items.AddRange(Loc.GetIdService().ItemIdLookup.Values.Where(i => i.FactionName == FactionName && i.IsType(criteria))); return(items); }
internal void DestroyItem(ItemData item) { if (item != null) { Loc.GetIdService().RemoveItem(item); Loc.GetGameController().AddItemToDestroy(item.Renderer.gameObject); } }
private void DeselectItem() { foreach (var item in Loc.GetIdService().ItemIdLookup.Values) { item.HideOutline(); } Loc.GetGameController().DestroyItemInfoPanel(); }
public static Structure GetStructure(this string id) { if (Loc.GetIdService().StructureIdLookup.TryGetValue(id, out var structure)) { return(structure); } return(null); }
public static ItemData GetItem(this string id) { if (!Loc.GetIdService().ItemIdLookup.TryGetValue(id, out var item)) { return(null); } return(item); }
public static CreatureData GetCreature(this string id) { if (!Loc.GetIdService().CreatureIdLookup.TryGetValue(id, out var creature)) { return(null); } return(creature); }
internal IEnumerable <Structure> GetStructuresInCell(Cell cell) { if (Loc.GetIdService().StructureCellLookup.ContainsKey(cell)) { return(Loc.GetIdService().StructureCellLookup[cell]); } return(new List <Structure>()); }
private void DeselectStructure() { foreach (var structure in Loc.GetIdService().StructureIdLookup.Values) { structure.HideOutline(); } Loc.GetGameController().DestroyStructureInfoPanel(); }
private string Burn() { var structure = Loc.GetIdService().StructureIdLookup.Values.Where(s => s.Flammable()).GetRandomItem(); structure.AddBehaviour <Wildfire>(); return($"Started a fire at {structure.Cell}"); }
private void DeselectCreature() { foreach (var creature in Loc.GetIdService().CreatureIdLookup.Values.Select(v => v.CreatureRenderer)) { creature.DisableHightlight(); } Loc.GetGameController().DestroyCreaturePanel(); Loc.GetGameController().DestroyToolTip(); }
private static CreatureData GetCreature(string nameOrId) { var creature = nameOrId.GetCreature(); if (creature == null) { creature = Loc.GetIdService().CreatureIdLookup.Values.ToList().Find(c => c.Name.Equals(nameOrId, StringComparison.OrdinalIgnoreCase)); } return(creature); }
public CreatureRenderer GetCreatureAtPoint(Vector2 point) { foreach (var creature in Loc.GetIdService().CreatureIdLookup.Values) { var rect = new Rect(creature.CreatureRenderer.transform.position.x - 0.5f, creature.CreatureRenderer.transform.position.y - 0.5f, 1f, 1f); if (rect.Contains(point)) { return(creature.CreatureRenderer); } } return(null); }
private void UpdateWorkStructures() { _lastUpdate += Time.deltaTime; if (_lastUpdate > 0.5f) { foreach (var structure in Loc.GetIdService().StructureIdLookup.Values.OfType <WorkStructureBase>()) { structure.Process(_lastUpdate); } _lastUpdate = 0; } }
internal void DestroyStructure(Structure structure) { if (structure != null) { if (structure.Cell == null) { Debug.Log("Unbound structure"); } structure.OnDestroy(); Loc.GetIdService().RemoveStructure(structure); Loc.GetFactionController().Factions[structure.FactionName].Structures.Remove(structure); Loc.GetGameController().AddItemToDestroy(structure.Renderer.gameObject); } }
internal void DestroyCreature(CreatureRenderer creature) { if (creature != null) { Debug.Log($"Destroying: {creature.Data.Name}"); if (creature.Data.Task != null) { creature.Data.AbandonTask(); } Loc.GetFactionController().Factions[creature.Data.FactionName].Creatures.Remove(creature.Data); Loc.GetIdService().RemoveCreature(creature.Data); Loc.GetGameController().AddItemToDestroy(creature.gameObject); } }
public static Save MakeSave() { return(new Save { MapGenerationData = MapGenerationData.Instance, Factions = Loc.GetFactionController().Factions.Values.ToList(), Time = Loc.GetTimeManager().Data, Items = Loc.GetIdService().ItemIdLookup.Values.ToList(), CameraData = new CameraData(Loc.GetCamera()), Rooms = Loc.GetZoneController().RoomZones, Stores = Loc.GetZoneController().StorageZones, Areas = Loc.GetZoneController().AreaZones, Chunks = Loc.GetMap().Chunks.Values.Select(s => s.Data).ToList(), }); }
public string List(string type) { var list = ""; switch (type.ToLower()) { case "items": foreach (var item in Loc.GetIdService().ItemIdLookup) { list += $"{item.Key}: {item.Value.Name}\n"; } break; case "creatures": foreach (var creature in Loc.GetIdService().CreatureIdLookup) { list += $"{creature.Key}: {creature.Value.Name}\n"; } break; case "structures": foreach (var structure in Loc.GetIdService().StructureIdLookup) { list += $"{structure.Key}: {structure.Value.Name}\n"; } break; case "factions": foreach (var faction in Loc.GetFactionController().Factions) { list += $"{faction.Key}\n"; } break; case "zones": foreach (var zone in Loc.GetZoneController().Zones) { list += $"{zone.Key.Name}: {zone.Key.FactionName}\n"; } break; default: list = "Provide type of list:\n-items\n-creatures\n-structures\n-factions\n-zones"; break; } return(list); }
private void IndexItem(ItemData item) { Loc.GetIdService().EnrollItem(item); }
private void IndexStructure(Structure structure) { Loc.GetIdService().EnrollStructure(structure); }