Exemple #1
0
        public override void Trigger(MessageCenterMessage inMessage, string triggeringName)
        {
            Main.LogDebug("[DestroyBuildingsAtLanceSpawnsResult] Setting state...");

            LanceSpawnerGameLogic lanceSpawnerGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <LanceSpawnerGameLogic>(LanceSpawnerGuid);

            UnitSpawnPointGameLogic[] unitSpawns = lanceSpawnerGameLogic.GetComponentsInChildren <UnitSpawnPointGameLogic>();

            List <BuildingRepresentation> buildingsInMap = GameObjextExtensions.GetBuildingsInMap();

            Main.LogDebug($"[TagUnitsInRegionResult] Collected '{buildingsInMap.Count}' buildings to check.");

            DestroyBuildingsUnderLanceSpawns(unitSpawns, buildingsInMap.ToArray(), Radius);
        }
Exemple #2
0
        private void TagUnitsInRegion()
        {
            Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Tagging '{NumberOfUnits}' '{Type}' in region '{RegionGuid}'");
            RegionGameLogic regionGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <RegionGameLogic>(RegionGuid);

            if (regionGameLogic == null)
            {
                Main.Logger.LogError($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Region Not Found for Guid '{RegionGuid}'");
                return;
            }

            if (Type == "Building")
            {
                List <BuildingRepresentation> buildingsInMap = GameObjextExtensions.GetBuildingsInMap();
                Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Collected '{buildingsInMap.Count}' buildings to check.");

                if (NumberOfUnits > 0)
                {
                    buildingsInMap.Shuffle();
                }

                foreach (BuildingRepresentation building in buildingsInMap)
                {
                    bool isBuildingInRegion = RegionUtil.PointInRegion(UnityGameInstance.BattleTechGame.Combat, building.transform.position, RegionGuid);
                    if (isBuildingInRegion)
                    {
                        Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Found building '{building.gameObject.name}' in region!");
                        building.ParentBuilding.EncounterTags.UnionWith(Tags);

                        SetTeam(building.ParentBuilding);
                        SetIsTargetObjective(building.ParentBuilding);

                        if (HasReachedUnitLimit())
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Tagging '{Type}' Not Yet Supported. Use 'TagUnitsInRegion'");
            }
        }
        public void ResetAllBuildingData()
        {
            Main.LogDebug($"[EncounterDataManager.ResetAllBuildingData] Resetting all old building data");
            List <BuildingRepresentation> buildingsInMap = GameObjextExtensions.GetBuildingsInMap();

            foreach (BuildingRepresentation buildingRep in buildingsInMap)
            {
                BattleTech.Building building = buildingRep.ParentBuilding;

                if (building != null)
                {
                    AccessTools.Field(typeof(BattleTech.Building), "isObjectiveTarget").SetValue(building, false);
                    AccessTools.Field(typeof(BattleTech.Building), "isObjectiveActive").SetValue(building, false);
                    building.objectiveGUIDS.Clear();
                }

                ObstructionGameLogic obstructionGameLogic = buildingRep.GetComponent <ObstructionGameLogic>();
                if (obstructionGameLogic != null)
                {
                    obstructionGameLogic.isObjectiveTarget = false;
                }
            }
        }