public void AddToActionEmergy(string action, float value) { if (!ActionEnergy.ContainsKey(action)) { ActionEnergy.Add(action, GetActionsMaxEnergy(action, Colony, RoamingJobSettings.ObjectiveCategory)); } ActionEnergy[action] += value; }
public float InitializeActionEnergy(string action, float valueIfNotInitialized) { if (!ActionEnergy.ContainsKey(action)) { ActionEnergy.Add(action, valueIfNotInitialized); } return(ActionEnergy[action]); }
public void SubtractFromActionEnergy(string action, float value) { if (!ActionEnergy.ContainsKey(action)) { ActionEnergy.Add(action, GetActionsMaxEnergy(action, Colony, RoamingJobSettings.ObjectiveCategory)); } ActionEnergy[action] -= value; if (ActionEnergy[action] < 0) { ActionEnergy[action] = 0; } }
public RoamingJobState(JSONNode baseNode, Colony colony) { Position = (Vector3Int)baseNode[nameof(Position)]; Colony = colony; if (baseNode.TryGetAs <string>(nameof(RoamObjective), out var ro)) { RoamObjective = ro; } if (baseNode.TryGetAs(nameof(ActionEnergy), out JSONNode ItemsRemovedNode) && ItemsRemovedNode.NodeType == NodeType.Object) { foreach (var aNode in ItemsRemovedNode.LoopObject()) { ActionEnergy.Add(aNode.Key, aNode.Value.GetAs <int>()); } } RoamingJobSettings = RoamingJobManager.GetCallbacks(RoamObjective); Initialize(); }