/// <summary> /// Adds/removes an amount of a faction's resource. /// </summary> /// <param name="factionID">ID of the faction whose resources will be updated.</param> /// <param name="name">Name of the resource type to add/remove.</param> /// <param name="amount">Amount of the resource to add/remove.</param> public void UpdateResource(int factionID, string name, int amount) { if (mapResourcesTable.TryGetValue(name, out int id)) //if the resource name corresponds to a valid ID { //Add the resource amount. factionsResources[factionID].Resources[id].UpdateCurrAmount(amount); if (factionID == GameManager.PlayerFactionID) //if this is the player faction, update the UI { PlayerFactionResources.UpdateUI(); } CustomEvents.OnFactionResourceUpdate(factionsResources[factionID].Resources[id].GetResourceType(), factionID, amount); } else { Debug.LogError($"[ResourceManager] The resource type with name: {name} is not defined in the mapResources array."); } }