/// <summary> /// Activates the main NPCUnitRegulator instance for the main resource collector unit. /// </summary> /// <param name="resourceType"></param> /// <param name="collectorMonitor"></param> private void ActivateCollectorRegulator(ResourceTypeInfo resourceType, NPCActiveRegulatorMonitor collectorMonitor) { collectorMonitor.Init(factionMgr); //Go ahead and add the resource collector regulator (if there's one).. foreach (ResourceCollector collector in collectors) { Assert.IsNotNull(collector, $"[NPCResourceCollector] NPC Faction ID: {factionMgr.FactionID} 'Collectors' list has some unassigned elements."); NPCUnitRegulator nextRegulator = null; //as soon a collector prefab produces a valid unit regulator instance (matches the faction type and faction npc manager), add it to monitor component if (collector.CanCollectResourceType(resourceType, false) && //also make sure the resource collector can collect this resource type. (nextRegulator = npcMgr.GetNPCComp <NPCUnitCreator>().ActivateUnitRegulator(collector.GetComponent <Unit>())) != null) { collectorMonitor.Replace("", nextRegulator.Code); } } Assert.IsTrue(collectorMonitor.GetCount() > 0, $"[NPCBuildingConstructor] NPC Faction ID: {factionMgr.FactionID} doesn't have a resource collector regulator assigned for resource type: {resourceType.GetName()}!"); }