/// <summary> /// Update all the need system that is mark "dirty" /// </summary> /// <remarks> /// The order of the NeedSystems' update metter, /// this should be their relative order(temp) : /// Terrian/Atmosphere -> Species -> FoodSource -> Density /// This order can be gerenteed in how NeedSystems is add to the manager in Awake() /// </remarks> public void UpdateDirtyNeedSystems() { // Update populations' accessible map when terrain was modified if (m_tileDataController.HasTerrainChanged) { // TODO: Update population's accessible map only for changed terrain m_reservePartitionManager.UpdateAccessMapChangedAt(m_tileDataController.ChangedTiles.ToList <Vector3Int>()); } foreach (KeyValuePair <NeedType, NeedSystem> entry in m_needSystems) { NeedSystem system = entry.Value; if (system.IsDirty) { //Debug.Log($"Updating {system.NeedType} NS by dirty flag"); system.UpdateSystem(); } else if (system.CheckState()) { //Debug.Log($"Updating {system.NeedType} NS by dirty pre-check"); system.UpdateSystem(); } } // Reset pop accessibility status m_populationManager.UdateAllPopulationStateForChecking(); // Reset food source accessibility status m_foodSourceManager.UpdateAccessibleTerrainInfoForAll(); // Reset terrain modified flag m_tileDataController.HasTerrainChanged = false; }
/// <summary> /// Add a system so that populations can register with it via it's need name. /// </summary> /// <param name="needSystem">The system to add</param> private void AddNeedSystem(NeedSystem needSystem) { if (!this.m_needSystems.ContainsKey(needSystem.NeedType)) { m_needSystems.Add(needSystem.NeedType, needSystem); } else { Debug.Log($"{needSystem.NeedType} need system already existed"); } }
void Start() { needSystem = GameObject.FindGameObjectWithTag("GameManager").GetComponent <NeedSystem>(); }