Пример #1
0
            public static bool Prefix(VehicleDockingBay __instance, GameObject nearby)
            {
                SubRoot cyclops = UWE.Utils.GetComponentInHierarchy <SubRoot>(nearby.gameObject);

                if (cyclops != null && !InceptionManager.DockedCyclopses.Contains(cyclops))
                {
                    if ((bool)__instance.GetInstanceField("powered"))
                    {
                        SubRoot main = __instance.GetSubRoot();
                        main.BroadcastMessage("OnLaunchBayOpening", SendMessageOptions.DontRequireReceiver);
                        main.BroadcastMessage("LockDoors", SendMessageOptions.DontRequireReceiver);
                        if ((bool)__instance.GetInstanceField("soundReset"))
                        {
                            if (__instance.bayDoorsOpenSFX != null)
                            {
                                __instance.bayDoorsOpenSFX.Play();
                            }
                            __instance.SetInstanceField("soundReset", false);
                            __instance.Invoke("SoundReset", 1f);
                        }
                    }
                    __instance.SetInstanceField("nearbyVehicle", null);
                    return(false);
                }
                return(true);
            }
Пример #2
0
        internal void HandleUpgrades()
        {
            // Turn off all upgrades and clear all values
            if (Cyclops == null)
            {
                ErrorMessage.AddError("ClearAllUpgrades: Cyclops ref is null - Upgrade handling cancled");
                return;
            }

            foreach (UpgradeHandler upgradeType in KnownsUpgradeModules.Values)
            {
                upgradeType.UpgradesCleared(Cyclops);
            }

            var foundUpgrades = new List <TechType>();

            foreach (UpgradeSlot upgradeSlot in this.UpgradeSlots)
            {
                Equipment modules = upgradeSlot.Modules;
                string    slot    = upgradeSlot.Slot;

                TechType techTypeInSlot = modules.GetTechTypeInSlot(slot);

                if (techTypeInSlot == TechType.None)
                {
                    continue;
                }

                foundUpgrades.Add(techTypeInSlot);

                if (KnownsUpgradeModules.TryGetValue(techTypeInSlot, out UpgradeHandler handler))
                {
                    handler.UpgradeCounted(Cyclops, modules, slot);
                }
            }

            if (foundUpgrades.Count > 0)
            {
                Cyclops.slotModSFX?.Play();
                Cyclops.BroadcastMessage("RefreshUpgradeConsoleIcons", foundUpgrades.ToArray(), SendMessageOptions.RequireReceiver);

                foreach (UpgradeHandler upgradeType in KnownsUpgradeModules.Values)
                {
                    upgradeType.UpgradesFinished(Cyclops);
                }
            }
        }
Пример #3
0
        private static void HandleToggleableUpgrades(SubRoot __instance, Equipment modules, ref bool fireSupressionSystem)
        {
            var subControl = __instance.GetAllComponentsInChildren <SubControl>();

            List <TechType> upgradeList = new List <TechType>(SlotHelper.SlotNames.Length);

            foreach (string slot in SlotHelper.SlotNames)
            {
                TechType techTypeInSlot = modules.GetTechTypeInSlot(slot);
                switch (techTypeInSlot)
                {
                case TechType.CyclopsShieldModule:
                    __instance.shieldUpgrade = true;
                    break;

                case TechType.CyclopsSonarModule:
                    __instance.sonarUpgrade = true;
                    break;

                case TechType.CyclopsSeamothRepairModule:
                    __instance.vehicleRepairUpgrade = true;
                    break;

                case TechType.CyclopsDecoyModule:
                    __instance.decoyTubeSizeIncreaseUpgrade = true;
                    break;

                case TechType.CyclopsFireSuppressionModule:
                    fireSupressionSystem = true;
                    break;
                    // CyclopsThermalReactorModule handled in PowerManager.RechargeCyclops
                    // CyclopsSpeedModule handled in PowerManager.UpdatePowerSpeedRating
                }

                upgradeList.Add(techTypeInSlot);
            }

            if (__instance.slotModSFX != null)
            {
                __instance.slotModSFX.Play();
            }

            __instance.BroadcastMessage("RefreshUpgradeConsoleIcons", upgradeList.ToArray(), SendMessageOptions.RequireReceiver);
        }
        public static void SetCyclopsUpgrades(SubRoot subRoot)
        {
            var live = LiveField.GetValue(subRoot) as LiveMixin;

            if (subRoot.upgradeConsole == null || !live.IsAlive())
            {
                return;
            }

            subRoot.shieldUpgrade                = false;
            subRoot.sonarUpgrade                 = false;
            subRoot.vehicleRepairUpgrade         = false;
            subRoot.decoyTubeSizeIncreaseUpgrade = false;
            subRoot.thermalReactorUpgrade        = false;
            var nuclearUpgrades = 0;

            var refreshArray = new TechType[6];
            var modules      = subRoot.upgradeConsole.modules;
            var slotNames    = SlotNamesField.GetValue(null) as string[];

            for (var i = 0; i < 6; i++)
            {
                var techTypeInSlot = modules.GetTechTypeInSlot(slotNames[i]);

                switch (techTypeInSlot)
                {
                case TechType.CyclopsShieldModule:
                    subRoot.shieldUpgrade = true;
                    break;

                case TechType.CyclopsSonarModule:
                    subRoot.sonarUpgrade = true;
                    break;

                case TechType.CyclopsSeamothRepairModule:
                    subRoot.vehicleRepairUpgrade = true;
                    break;

                case TechType.CyclopsDecoyModule:
                    subRoot.decoyTubeSizeIncreaseUpgrade = true;
                    break;

                case TechType.CyclopsThermalReactorModule:
                    subRoot.thermalReactorUpgrade = true;
                    break;

                case TechType.ReactorRod:
                    nuclearUpgrades++;
                    break;
                }

                refreshArray[i] = techTypeInSlot;
            }

            NuclearUpgradeField.SetValue(subRoot, nuclearUpgrades);

            if (subRoot.slotModSFX != null)
            {
                subRoot.slotModSFX.Play();
            }

            subRoot.BroadcastMessage("RefreshUpgradeConsoleIcons", refreshArray,
                                     SendMessageOptions.RequireReceiver);
        }