/// <summary>
        /// Activates the NPCBuildingRegulator instances for the NPC faction's population buildings
        /// </summary>
        public void ActivatePopulationBuildingRegulators()
        {
            populationBuildingsMonitor.Init(factionMgr);

            //Go ahead and add the army units regulators (if there are valid ones)
            foreach (Building building in populationBuildings)
            {
                Assert.IsNotNull(building,
                                 $"[NPCPopulationManager] NPC Faction ID: {factionMgr.FactionID} 'Population Buildings' list has some unassigned elements.");

                Assert.IsTrue(building.GetAddedPopulationSlots() > 0,
                              $"[NPCPopulationManager] NPC Faction ID: {factionMgr.FactionID} 'Population Buildings' list has includes Building of code: {building.GetCode()} that does not add population slots.");

                NPCBuildingRegulator nextRegulator = null;
                //only add the army unit regulators that match this NPC faction's type
                if ((nextRegulator = npcMgr.GetNPCComp <NPCBuildingCreator>().ActivateBuildingRegulator(
                         building,
                         npcMgr.GetNPCComp <NPCBuildingCreator>().GetCapitalBuildingRegualtor())) != null)
                {
                    populationBuildingsMonitor.Replace("", nextRegulator.Code);
                }
            }

            Assert.IsTrue(populationBuildingsMonitor.GetCount() > 0,
                          $"[NPCPopulationManager] NPC Faction ID: {factionMgr.FactionID} doesn't have any active NPCBuildingRegulator instances for population buildings.");
        }
        /// <summary>
        /// Activates the main NPCUnitRegulator instance for the main builder unit.
        /// </summary>
        private void ActivateBuilderRegulator()
        {
            builderMonitor.Init(factionMgr);

            //Go ahead and add the builder regulator (if there's one)..
            foreach (Builder builder in builders)
            {
                Assert.IsNotNull(builder,
                                 $"[NPCBuildingConstructor] NPC Faction ID: {factionMgr.FactionID} 'Builders' list has some unassigned elements.");

                NPCUnitRegulator nextRegulator = null;
                //as soon a builder prefab produces a valid builder regulator instance (matches the faction type and faction npc manager), add it to be monitored:
                if ((nextRegulator = npcMgr.GetNPCComp <NPCUnitCreator>().ActivateUnitRegulator(builder.GetComponent <Unit>())) != null)
                {
                    builderMonitor.Replace("", nextRegulator.Code);
                }
            }

            Assert.IsTrue(builderMonitor.GetCount() > 0,
                          $"[NPCBuildingConstructor] NPC Faction ID: {factionMgr.FactionID} doesn't have a builder regulator assigned!");
        }
        /// <summary>
        /// Activates the NPCUnitRegulator instances for the NPC faction's army units.
        /// </summary>
        public void ActivateArmyUnitRegulators()
        {
            armyUnitsMonitor.Init(factionMgr);

            //Go ahead and add the army units regulators (if there are valid ones)
            foreach (UnitAttack armyUnit in armyUnits)
            {
                Assert.IsNotNull(armyUnit,
                                 $"[NPCArmyCreator] NPC Faction ID: {factionMgr.FactionID} 'Army Unit' list has some unassigned elements.");

                NPCUnitRegulator nextRegulator = null;
                //only add the army unit regulators that match this NPC faction's type
                if ((nextRegulator = npcMgr.GetNPCComp <NPCUnitCreator>().ActivateUnitRegulator(armyUnit.GetComponent <Unit>())) != null)
                {
                    armyUnitsMonitor.Replace("", nextRegulator.Code);
                }
            }

            Assert.IsTrue(armyUnitsMonitor.GetCount() > 0,
                          $"[NPCArmyCreator] NPC Faction ID: {factionMgr.FactionID} doesn't have any active NPCUnitRegulator instance for army units!");
        }
Exemple #4
0
        /// <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()}!");
        }
        /// <summary>
        /// Activates the main NPCBuildingRegulator instance for the main building center.
        /// </summary>
        public void ActivateCenterRegulator()
        {
            centerMonitor.Init(factionMgr);

            //Go ahead and add the building center regulator
            foreach (Border center in centers)
            {
                Assert.IsNotNull(center,
                                 $"[NPCTerritoryManager] NPC Faction ID: {factionMgr.FactionID} 'Centers' list has some unassigned elements.");

                NPCBuildingRegulator nextRegulator = null;
                //as soon a center prefab produces a valid building regulator instance (matches the faction type and faction npc manager), add to monitoring
                if ((nextRegulator = npcMgr.GetNPCComp <NPCBuildingCreator>().ActivateBuildingRegulator(
                         center.GetComponent <Building>(),
                         npcMgr.GetNPCComp <NPCBuildingCreator>().GetCapitalBuildingRegualtor())) != null)
                {
                    centerMonitor.Replace("", nextRegulator.Code);
                }
            }

            Assert.IsTrue(centerMonitor.GetCount() > 0,
                          $"[NPCTerritoryManager] NPC Faction ID: {factionMgr.FactionID} doesn't have a center building regulator assigned!");
        }