public void Update() { Title.text = _task.Message; if (Loc.GetFactionController().PlayerFaction.AssignedTasks.ContainsKey(_task)) { CreatureIcon.Creature = Loc.GetFactionController().PlayerFaction.AssignedTasks[_task]; NowButton.enabled = false; NowButton.image.color = ColorConstants.GreyAccent; SuspendButton.enabled = false; SuspendButton.image.color = ColorConstants.GreyAccent; } else { NowButton.enabled = true; NowButton.image.color = ColorConstants.GreenAccent; SuspendButton.enabled = true; SuspendButton.image.color = ColorConstants.YellowAccent; } if (_task.IsSuspended()) { Background.color = ColorConstants.YellowAccent; Title.text = "Suspended: " + Title.text; } else { Background.color = ColorConstants.WhiteAccent; } }
private void Update() { var tasks = Loc.GetFactionController().PlayerFaction.AssignedTasks.Keys.ToList(); tasks.AddRange(Loc.GetFactionController().PlayerFaction.AvailableTasks); foreach (var task in tasks) { if (!Tasks.ContainsKey(task)) { var taskDisplay = Instantiate(TaskDisplayPrefab, TaskView.transform); taskDisplay.Load(task); Tasks.Add(task, taskDisplay); } } foreach (var task in Tasks.Keys.ToList()) { if (task.Destroyed) { Destroy(Tasks[task].gameObject); Tasks.Remove(task); } } }
public void StoreItems() { foreach (var item in Items) { // todo: a check can be added here to not add double storage tasks for the same item to the // task queue but it seems like it would probably be overkill at this point Loc.GetFactionController().PlayerFaction.AddTask(new StoreItem(item)); } }
public void MoveUp() { if (Loc.GetFactionController().PlayerFaction.AvailableTasks.Contains(_task)) { Loc.GetFactionController().PlayerFaction.AvailableTasks.Remove(_task); Loc.GetFactionController().PlayerFaction.AvailableTasks.Insert(0, _task); Loc.GetGameController().UIController.ReloadTaskPanel(); } }
public void Suspend() { if (Loc.GetFactionController().PlayerFaction.AvailableTasks.Contains(_task)) { _task.Suspend(false); Loc.GetFactionController().PlayerFaction.AvailableTasks.Remove(_task); Loc.GetFactionController().PlayerFaction.AvailableTasks.Add(_task); Loc.GetGameController().UIController.ReloadTaskPanel(); } }
public void Claim() { foreach (var structure in Structures) { structure.FactionName = Loc.GetFactionController().PlayerFaction.FactionName; if (!Loc.GetFactionController().PlayerFaction.Structures.Contains(structure)) { Loc.GetFactionController().PlayerFaction.Structures.Add(structure); } } }
private void MoveClicked() { Loc.Current.Get <CursorController>().SetSelectionPreference(SelectionPreference.Cell); Loc.Current.Get <CursorController>().SetSprite(Loc.GetSpriteStore().GetSprite(MoveIcon), (cell) => cell.TravelCost > 0); CellClickOrder = cells => { var cell = cells[0]; Loc.GetFactionController().PlayerFaction.AddTask(new Move(cell)); }; }
public void Remove() { foreach (var structure in Structures) { if (!Loc.GetFactionController().PlayerFaction.AvailableTasks.OfType <RemoveStructure>().Any(r => r.StructureToRemove == structure)) { Loc.GetFactionController().PlayerFaction.AddTask(new RemoveStructure(structure)); } else { Debug.Log("Already added task to remove"); } } }
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); } }
private static string CompleteStructures() { var ids = ""; foreach (var build in Loc.GetFactionController() .PlayerFaction .AvailableTasks.OfType <Build>().ToList()) { build.FinishStructure(); ids += $"{build.Blueprint.StructureName},"; Loc.GetFactionController().PlayerFaction.AvailableTasks.Remove(build); } return(ids.Trim(',')); }
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); } }
private void ConstructClicked(Construct constuct) { Debug.Log($"Construct clicked {constuct.Name}"); Loc.Current.Get <CursorController>().ShowConstructGhost(constuct); ShowConstructInfo(constuct); CellClickOrder = cells => { if (constuct.ValidateStartPos(cells[0])) { constuct.Place(cells[0], Loc.GetFactionController().PlayerFaction); } }; }
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(), }); }
internal void DestroyBlueprint(Blueprint blueprint) { if (blueprint.BlueprintRenderer != null) { Loc.GetGameController().AddItemToDestroy(blueprint.BlueprintRenderer.transform.gameObject); foreach (var faction in Loc.GetFactionController().Factions.Values) { if (faction.Blueprints.Contains(blueprint)) { faction.Blueprints.Remove(blueprint); return; } } } }
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); }
public void Delete() { if (_task is Build build) { Loc.GetStructureController().DestroyBlueprint(build.Blueprint); } if (Loc.GetFactionController().PlayerFaction.AssignedTasks.ContainsKey(_task)) { Loc.GetFactionController().PlayerFaction.AssignedTasks[_task].CancelTask(); } else { Loc.GetFactionController().PlayerFaction.AvailableTasks.Remove(_task); } _task.Destroy(); }
public void BuildClicked(string structureName) { var structure = Loc.GetStructureController().StructureDataReference[structureName]; Loc.Current.Get <CursorController>().SetSelectionPreference(SelectionPreference.Cell); Loc.Current.Get <CursorController>().SetMesh(structureName, (cell) => structure.ValidateCellLocationForStructure(cell)); UpdateStuctureOrder(structureName); CellClickOrder = cells => { foreach (var cell in cells) { if (structure.ValidateCellLocationForStructure(cell)) { Loc.GetStructureController().SpawnBlueprint(structureName, cell, Loc.GetFactionController().PlayerFaction); } } }; }
private void RemoveStructureClicked() { Loc.Current.Get <CursorController>().SetSelectionPreference(SelectionPreference.Cell); Loc.Current.Get <CursorController>().SetSprite(Loc.GetSpriteStore().GetSprite(DefaultRemoveIcon), (cell) => cell.Structures != null); CellClickOrder = cells => { foreach (var cell in cells) { if (cell.Structures.Count > 0) { var structure = cell.Structures.First(); if (Loc.GetFactionController().PlayerFaction.AvailableTasks.OfType <RemoveStructure>().Any(t => t.StructureToRemove == structure)) { continue; } Loc.GetFactionController().PlayerFaction.AddTask(new RemoveStructure(structure)); } } }; }
internal Blueprint GetBlueprintById(string blueprintId) { return(Loc.GetFactionController().Factions .SelectMany(f => f.Value.Blueprints) .FirstOrDefault(b => b.ID == blueprintId)); }
internal Structure CreateStructure(string structureName, string faction = FactionConstants.World) { var structure = Loc.GetStructureController().SpawnStructure(structureName, this, Loc.GetFactionController().Factions[faction]); return(structure); }
private void UpdateRemainingFlammability(Structure structure, float delta) { structure.Flammability -= delta / 2; if (structure.Flammability <= 0) { Loc.GetStructureController().SpawnStructure("Debris", structure.Cell, Loc.GetFactionController().WorldFaction); Loc.GetStructureController().DestroyStructure(structure); } }