Ejemplo n.º 1
0
        private static void Postfix(IngameMenu __instance)
        {
            if (GameModeUtils.IsPermadeath())
            {
                return;
            }

            if (__instance != null && quitButton == null)
            {
                var prefab = __instance.quitToMainMenuButton.transform.parent.GetChild(0).gameObject.GetComponent <Button>();
                quitButton      = GameObject.Instantiate(prefab, __instance.quitToMainMenuButton.transform.parent);
                quitButton.name = "ButtonQuitToDesktop";
                quitButton.onClick.RemoveAllListeners();
                quitButton.onClick.AddListener(() => { __instance.QuitGame(true); });

                IEnumerable <Text> texts = quitButton.GetComponents <Text>().Concat(quitButton.GetComponentsInChildren <Text>());
                foreach (Text text in texts)
                {
                    text.text = "Quit to Desktop";
                }

                texts = __instance.quitToMainMenuButton.GetComponents <Text>().Concat(__instance.quitToMainMenuButton.GetComponentsInChildren <Text>());
                foreach (Text text in texts)
                {
                    text.text = "Quit to Main Menu";
                }
            }
        }
Ejemplo n.º 2
0
        public void PulseShield()
        {
            if (!this.HasUpgrade)
            {
                return;
            }

            if (!this.HasShieldModule)
            {
                return;
            }

            if (this.IsOnCooldown)
            {
                return;
            }

            UpdateCooldown();

            float originalCost = Cyclops.shieldPowerCost;

            Cyclops.shieldPowerCost = originalCost * ShieldCostModifier;

            this.ShieldButton?.StartShield();

            if (GameModeUtils.RequiresPower())
            {
                Cyclops.powerRelay.ConsumeEnergy(Cyclops.shieldPowerCost, out float amountConsumed);
            }

            this.ShieldButton?.StopShield();

            Cyclops.shieldPowerCost = originalCost;
        }
        public bool ModifyPower(float amount, out float modified)
        {
            bool result = false;

            modified = 0f;

            if (_powerState != FCSPowerStates.Unpowered && _chargeMode == PowerToggleStates.TrickleMode)
            {
                if (amount >= 0f)
                {
                    result   = (amount <= LoadData.BatteryConfiguration.Capacity - _charge);
                    modified = Mathf.Min(amount, LoadData.BatteryConfiguration.Capacity - _charge);
                    ChargeBatteries(modified);
                }
                else
                {
                    result = (_charge >= -amount);
                    if (GameModeUtils.RequiresPower())
                    {
                        if (_chargeMode == PowerToggleStates.TrickleMode)
                        {
                            modified = -Mathf.Min(-amount, _charge);
                            ConsumePower(modified);
                        }
                    }
                    else
                    {
                        modified = amount;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        public static void Postfix(IList <Ingredient> ingredients, ref List <TooltipIcon> icons)
        {
            if (ingredients == null)
            {
                return;
            }

            var ingredientCount = ingredients.Count;

            for (var i = 0; i < ingredientCount; i++)
            {
                var techType = ingredients[i].techType;
                if (!KnownTech.Contains(techType) && PDAScanner.ContainsCompleteEntry(techType))
                {
                    KnownTech.Add(techType);
                }

                if (KnownTech.Contains(techType) || !GameModeUtils.RequiresBlueprints())
                {
                    continue;
                }
                var icon = icons.Find((TooltipIcon) => TooltipIcon.sprite == SpriteManager.Get(techType) && TooltipIcon.text.Contains(Language.main.GetOrFallback(TooltipFactory.techTypeIngredientStrings.Get(techType), techType)));
                if (!icons.Contains(icon))
                {
                    continue;
                }
                icons.Remove(icon);
                var tooltipIcon = new TooltipIcon()
                {
                    sprite = SpriteManager.Get(TechType.None), text = Main.Config.UnKnownTitle
                };
                icons.Add(tooltipIcon);
            }
        }
Ejemplo n.º 5
0
        public override void UpdateText()
        {
            if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap)
            {
                base.MiddleText.FontSize   = 20;
                base.MiddleText.TextString = DisplayTexts.Main.CyclopsPowerLow;
                base.MiddleText.TextColor  = Color.red;

                base.UpperText.TextString = string.Empty;
                base.LowerText.TextString = string.Empty;
            }
            else
            {
                base.UpperText.FontSize = 12;
                base.LowerText.FontSize = 12;

                if (zapper.IsOnCooldown)
                {
                    base.LowerText.TextString = DisplayTexts.Main.DefenseCooldown;
                    base.LowerText.TextColor  = Color.yellow;
                }
                else
                {
                    base.LowerText.TextString = DisplayTexts.Main.DefenseCharged;
                    base.LowerText.TextColor  = Color.white;
                }
            }
        }
        public bool ModifyPower(float amount, out float modified)
        {
            modified = 0f;


            bool result;

            if (amount >= 0f)
            {
                result   = (amount <= AIJetStreamT242Buildable.JetStreamT242Config.MaxCapacity - _charge);
                modified = Mathf.Min(amount, AIJetStreamT242Buildable.JetStreamT242Config.MaxCapacity - _charge);
                _charge += Mathf.Round(modified);
            }
            else
            {
                result = (_charge >= -amount);
                if (GameModeUtils.RequiresPower())
                {
                    modified = -Mathf.Min(-amount, _charge);
                    _charge += Mathf.Round(modified);
                }
                else
                {
                    modified = amount;
                }
            }

            return(result);
        }
        private void OnConsoleCommandEntered(string command)
        {
            if (command.Equals("weather"))
            {
                isWeatherEnabled = !isWeatherEnabled;

                if (!isWeatherEnabled)
                {
                    WeatherManager.main.debugLightningEnabled     = false;
                    WeatherManager.main.debugPrecipitationEnabled = false;
                    WeatherManager.main.debugWindEnabled          = false;
                    GameModeUtils.ActivateCheat(GameModeOption.NoCold);
                }
                else
                {
                    WeatherManager.main.debugLightningEnabled     = true;
                    WeatherManager.main.debugPrecipitationEnabled = true;
                    WeatherManager.main.debugWindEnabled          = true;
                    GameModeUtils.DeactivateCheat(GameModeOption.NoCold);
                }
            }

            UpdateButtonsState();
            Debug.Log(command);
        }
Ejemplo n.º 8
0
        public static bool Prefix(Stillsuit __instance)
        {
            if (!__instance.GetComponent <ESSBehaviour>())
            {
                return(true);
            }

            if (GameModeUtils.RequiresSurvival() && !Player.main.GetComponent <Survival>().freezeStats)
            {
                ErrorMessage.AddDebug(Mathf.RoundToInt(__instance.waterCaptured).ToString() + "/" + __instance.waterPrefab.waterValue.ToString());


                __instance.waterCaptured += Time.deltaTime / 18f * 0.75f;
                if (__instance.waterCaptured >= __instance.waterPrefab.waterValue)
                {
                    ErrorMessage.AddDebug("Enhanced Stillsuit activated!");

                    GameObject gameObject = GameObject.Instantiate(__instance.waterPrefab.gameObject);
                    Pickupable component  = gameObject.GetComponent <Pickupable>();
                    Player.main.GetComponent <Survival>().Eat(component.gameObject);
                    __instance.waterCaptured -= __instance.waterPrefab.waterValue;
                }
            }

            return(false);
        }
Ejemplo n.º 9
0
        public override void UpdateText()
        {
            if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap)
            {
                base.UpperText.FontSize  = 20;
                base.MiddleText.FontSize = 20;
                base.LowerText.FontSize  = 20;

                base.UpperText.TextString  = "CYCLOPS";
                base.MiddleText.TextString = "POWER";
                base.LowerText.TextString  = "LOW";

                base.UpperText.TextColor  = Color.red;
                base.MiddleText.TextColor = Color.red;
                base.LowerText.TextColor  = Color.red;
            }
            else
            {
                base.UpperText.FontSize = 12;
                base.LowerText.FontSize = 12;

                if (zapper.IsOnCooldown)
                {
                    base.LowerText.TextString = "Defense System\n[Cooldown]";
                    base.LowerText.TextColor  = Color.yellow;
                }
                else
                {
                    base.LowerText.TextString = "Defense System\n[Charged]";
                    base.LowerText.TextColor  = Color.white;
                }
            }
        }
Ejemplo n.º 10
0
        public bool ModifyPower(float amount, out float modified)
        {
            modified = 0f;

            bool result;

            if (amount >= 0f)
            {
                result   = (amount <= _capacity - _charge);
                modified = Mathf.Min(amount, _capacity - _charge);
                _charge += Mathf.Round(modified);
            }
            else
            {
                result = (_charge >= -amount);
                if (GameModeUtils.RequiresPower())
                {
                    modified = -Mathf.Min(-amount, _charge);
                    _charge += Mathf.Round(modified);
                }
                else
                {
                    modified = amount;
                }
            }

            return(result);
        }
Ejemplo n.º 11
0
        public virtual void Update()
        {
            if (_connectedRelay == null)
            {
                return;
            }

            //_energyToConsume = EnergyConsumptionPerSecond * DayNightCycle.main.deltaTime;
            bool requiresEnergy    = GameModeUtils.RequiresPower();
            bool hasPowerToConsume = !requiresEnergy || (this.AvailablePower >= EnergyConsumptionPerSecond);

            if (hasPowerToConsume && _prevPowerState != FCSPowerStates.Powered)
            {
                OnPowerResume?.Invoke();
                _prevPowerState = FCSPowerStates.Powered;
            }
            else if (!hasPowerToConsume && _prevPowerState != FCSPowerStates.Unpowered)
            {
                OnPowerOutage?.Invoke();
                _prevPowerState = FCSPowerStates.Unpowered;
            }

            //if (this.NotAllowToOperate)
            //    return;

            //if (!hasPowerToConsume)
            //    return;

            //if (requiresEnergy)
            //    _connectedRelay.ConsumeEnergy(_energyToConsume, out float amountConsumed);
        }
Ejemplo n.º 12
0
        public static void Postfix()
        {
            TechType tankSlot = Inventory.main.equipment.GetTechTypeInSlot("Tank");

            if (GameModeUtils.RequiresOxygen() && Player.main.IsSwimming() && tankSlot == ScubaManifold.techType)
            {
                int photosynthesisTanks = Inventory.main.container.GetCount(O2TanksCore.PhotosynthesisSmallID) + Inventory.main.container.GetCount(O2TanksCore.PhotosynthesisTankID);
                int chemosynthesisTanks = Inventory.main.container.GetCount(O2TanksCore.ChemosynthesisTankID);

                if (photosynthesisTanks > 0)
                {
                    float playerDepth             = Ocean.main.GetDepthOf(Player.main.gameObject);
                    float currentLight            = DayNightCycle.main.GetLocalLightScalar();
                    float photosynthesisDepthCalc = (currentLight > 0.9f ? 0.9f : currentLight) * Time.deltaTime * (Config.multipleTanks ? photosynthesisTanks : 1) * (200f - playerDepth > 0f ? ((200 - playerDepth) / 200f) : 0);
                    Player.main.oxygenMgr.AddOxygen(photosynthesisDepthCalc);
                }

                if (chemosynthesisTanks > 0)
                {
                    float waterTemp = WaterTemperatureSimulation.main.GetTemperature(Player.main.transform.position);
                    float chemosynthesisTempCalc = (waterTemp > 30f ? waterTemp : 0) * Time.deltaTime * 0.01f * (Config.multipleTanks ? chemosynthesisTanks : 1);
                    Player.main.oxygenMgr.AddOxygen(chemosynthesisTempCalc);
                }
            }
        }
        private void OnTriggerEnter(Collider other)
        {
            if (!enter && IsPlayerCollided(other))
            {
                Debug.Log($"entered({GetInstanceID()})");

                if (IsAuroraLeaking() && !Main.isAuroraRadiationBypassed)
                {
                    LeakingRadiation.main.radiatePlayerInRange.CancelInvoke();
                    Main.isAuroraRadiationBypassed = true;
                }

                bool flag = GameModeUtils.HasRadiation() && (NoDamageConsoleCommand.main == null || !NoDamageConsoleCommand.main.GetNoDamageCheat());

                if (flag)
                {
                    InvokeRepeating("RadiateUranuim", 0f, 0.2f);
                    InvokeRepeating("DoDamage", 0f, updateInterval);
                }

                Main.isPlayerInRadiationZone = true;
                enter = true;
                exit  = false;
            }
        }
        internal void UpdateButtonsState()
        {
            toggleCommands[(int)ToggleCommands.freedom].State    = SNGUI.ConvertBoolToState(GameModeUtils.IsOptionActive(GameModeOption.NoSurvival));
            toggleCommands[(int)ToggleCommands.creative].State   = SNGUI.ConvertBoolToState(GameModeUtils.IsOptionActive(GameModeOption.NoBlueprints));
            toggleCommands[(int)ToggleCommands.survival].State   = SNGUI.ConvertBoolToState(GameModeUtils.RequiresSurvival());
            toggleCommands[(int)ToggleCommands.hardcore].State   = SNGUI.ConvertBoolToState(GameModeUtils.IsPermadeath());
            toggleCommands[(int)ToggleCommands.fastbuild].State  = SNGUI.ConvertBoolToState(NoCostConsoleCommand.main.fastBuildCheat);
            toggleCommands[(int)ToggleCommands.fastscan].State   = SNGUI.ConvertBoolToState(NoCostConsoleCommand.main.fastScanCheat);
            toggleCommands[(int)ToggleCommands.fastgrow].State   = SNGUI.ConvertBoolToState(NoCostConsoleCommand.main.fastGrowCheat);
            toggleCommands[(int)ToggleCommands.fasthatch].State  = SNGUI.ConvertBoolToState(NoCostConsoleCommand.main.fastHatchCheat);
            toggleCommands[(int)ToggleCommands.filterfast].State = SNGUI.ConvertBoolToState(filterFast);
            toggleCommands[(int)ToggleCommands.nocost].State     = SNGUI.ConvertBoolToState(GameModeUtils.IsOptionActive(GameModeOption.NoCost));
            toggleCommands[(int)ToggleCommands.noenergy].State   = SNGUI.ConvertBoolToState(GameModeUtils.IsCheatActive(GameModeOption.NoEnergy));
            toggleCommands[(int)ToggleCommands.nosurvival].State = SNGUI.ConvertBoolToState(GameModeUtils.IsOptionActive(GameModeOption.NoSurvival));
            toggleCommands[(int)ToggleCommands.oxygen].State     = SNGUI.ConvertBoolToState(GameModeUtils.IsOptionActive(GameModeOption.NoOxygen));
            toggleCommands[(int)ToggleCommands.radiation].State  = SNGUI.ConvertBoolToState(GameModeUtils.IsOptionActive(GameModeOption.NoRadiation));
            toggleCommands[(int)ToggleCommands.invisible].State  = SNGUI.ConvertBoolToState(GameModeUtils.IsInvisible());
            //toggleCommands[(int)ToggleCommands.shotgun].State = shotgun cheat
            toggleCommands[(int)ToggleCommands.nodamage].State    = SNGUI.ConvertBoolToState(NoDamageConsoleCommand.main.GetNoDamageCheat());
            toggleCommands[(int)ToggleCommands.noinfect].State    = SNGUI.ConvertBoolToState(NoInfectConsoleCommand.main.GetNoInfectCheat());
            toggleCommands[(int)ToggleCommands.alwaysday].State   = SNGUI.ConvertBoolToState(AlwaysDayConsoleCommand.main.GetAlwaysDayCheat());
            toggleCommands[(int)ToggleCommands.overpower].Enabled = GameModeUtils.RequiresSurvival();

            if (toggleCommands[(int)ToggleCommands.overpower].Enabled)
            {
                toggleCommands[(int)ToggleCommands.overpower].State = SNGUI.ConvertBoolToState(OverPowerConsoleCommand.main.GetOverPowerCheat());
            }

            vehicleSettings[0].State = SNGUI.ConvertBoolToState(isSeamothCanFly.value);
            vehicleSettings[1].State = SNGUI.ConvertBoolToState(isSeaglideFast.value);
        }
Ejemplo n.º 15
0
        public void ConsumePower(float amount)
        {
            if (GameModeUtils.RequiresPower())
            {
                float totalPower = TotalCanProvide(out int sourceCount);

                if (sourceCount > 0)
                {
                    amount = (amount > totalPower) ? totalPower : amount;
                    amount = amount / sourceCount;

                    BZLogger.Debug($"consume power: amount: {amount}, sources: {sourceCount}");

                    foreach (KeyValuePair <string, IBattery> kvp in batteries)
                    {
                        if (kvp.Value != null && kvp.Value.charge > 0f)
                        {
                            kvp.Value.charge += -Mathf.Min(amount, kvp.Value.charge);

                            if (slots.TryGetValue(kvp.Key, out SlotDefinition definition))
                            {
                                UpdateVisuals(definition, kvp.Value.charge / kvp.Value.capacity, equipment.GetItemInSlot(kvp.Key).item.GetTechType());
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public static bool IsCraftRecipeFulfilled(TechType techType)
        {
            if (Inventory.main == null)
            {
                return(false);
            }
            if (!GameModeUtils.RequiresIngredients())
            {
                return(true);
            }

            var       itemContainers = FindAllItemsContainersInRange();
            ITechData techData       = CraftData.Get(techType, false);

            if (techData != null)
            {
                int i = 0;
                int ingredientCount = techData.ingredientCount;
                while (i < ingredientCount)
                {
                    IIngredient ingredient = techData.GetIngredient(i);
                    if (GetTotalPickupCount(ingredient.techType, itemContainers) < ingredient.amount)
                    {
                        return(false);
                    }
                    i++;
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 17
0
        internal static void PreUpdateStats(Survival __instance, float timePassed)
        {
            bool bHasSurvivalSuit = PlayerPatch.bHasSurvivalSuit;

            if (bHasSurvivalSuit && GameModeUtils.RequiresSurvival() && !Player.main.IsFrozenStats())
            {
                //preHunger = __instance.food;
                //preWater = __instance.water;
                float regenRate = SurvivalsuitBehaviour.SurvivalRegenRate;
                float kMaxStat  = SurvivalConstants.kMaxStat;

                /*float kFoodTime = SurvivalConstants.kFoodTime;
                 * float kWaterTime = SurvivalConstants.kWaterTime;
                 * Log.LogDebug($"SurvivalPatches.PreUpdateStats: food = {__instance.food}, water = {__instance.water}, bHasSurvivalSuit = {bHasSurvivalSuit}\nkFoodTime = {kFoodTime}, kWaterTime = {kWaterTime}, kMaxStat = {kMaxStat}, regenRate = {regenRate}");*/

                // now we can calculate the current calorie/water consumption rates and calibrate based on those.
                // Assuming the buggers at UWE don't change the algorithm.

                float foodRestore  = (timePassed / SurvivalConstants.kFoodTime * kMaxStat) * regenRate;
                float waterRestore = (timePassed / SurvivalConstants.kWaterTime * kMaxStat) * regenRate;
                __instance.food  = __instance.food + foodRestore;
                __instance.water = __instance.water + waterRestore;
                //Log.LogDebug($"SurvivalPatches.PreUpdateStats: done running Survival Suit routine; food = {__instance.food}, water = {__instance.water}, foodRestore = {foodRestore}, waterRestore = {waterRestore}");
            }
        }
        public static bool Radiate(RadiatePlayerInRange __instance)
        {
            bool flag = GameModeUtils.HasRadiation() && (NoDamageConsoleCommand.main == null || !NoDamageConsoleCommand.main.GetNoDamageCheat());

            PlayerDistanceTracker tracker = (PlayerDistanceTracker)AccessTools.Field(typeof(RadiatePlayerInRange), "tracker").GetValue(__instance);
            float distanceToPlayer        = GetDistance(tracker);

            if (radiated = distanceToPlayer <= __instance.radiateRadius && flag && __instance.radiateRadius > 0f)
            {
                float num  = Mathf.Clamp01(1f - distanceToPlayer / __instance.radiateRadius);
                float num2 = num;
                if (Inventory.main.equipment.GetCount(TechType.RadiationSuit) > 0)
                {
                    num -= num2 * 0.5f;
                }
                if (Inventory.main.equipment.GetCount(TechType.RadiationHelmet) > 0)
                {
                    num -= num2 * 0.23f * 2f;
                }
                if (Inventory.main.equipment.GetCount(TechType.RadiationGloves) > 0)
                {
                    num -= num2 * 0.23f;
                }
                num = Mathf.Clamp01(num);
                Player.main.SetRadiationAmount(num);
            }
            else
            {
                Player.main.SetRadiationAmount(0f);
            }

            return(false);
        }
Ejemplo n.º 19
0
 public static void QuitGame_Postfix(bool quitToDesktop)
 {
     if (GameModeUtils.IsPermadeath())
     {
         KnownTechFixer.SaveAddedNotifications();
         ConstructableFixer.SaveLadderDirections();
     }
 }
        internal void ConsumePower()
        {
            bool requiresEnergy = GameModeUtils.RequiresPower();

            if (requiresEnergy)
            {
                this.ConnectedRelay.ConsumeEnergy(_energyToConsume, out float amountConsumed);
            }
        }
 public static void Postfix(bool locked, ref TooltipData data)
 {
     if (locked && GameModeUtils.RequiresBlueprints())
     {
         data.prefix.Clear();
         TooltipFactory.WriteTitle(data.prefix, Main.Config.UnKnownTitle);
         TooltipFactory.WriteDescription(data.prefix, Main.Config.UnKnownDescription);
     }
 }
        /// <summary>
        /// Recharges the cyclops' power cells using all charging modules across all upgrade consoles.
        /// </summary>
        /// <returns><c>True</c> if the original code for the vanilla Cyclops Thermal Reactor Module is required; Otherwise <c>false</c>.</returns>
        public bool RechargeCyclops()
        {
            if (!initialized)
            {
                InitializeChargers();
            }

            if (Time.timeScale == 0f) // Is the game paused?
            {
                return(false);
            }

            if (totalChargers < 0)
            {
                return(true);
            }

            // When in Creative mode or using the NoPower cheat, inform the chargers that there is no power deficit.
            // This is so that each charger can decide what to do individually rather than skip the entire charging cycle all together.
            powerDeficit = GameModeUtils.RequiresPower()
                            ? Cyclops.powerRelay.GetMaxPower() - Cyclops.powerRelay.GetPower()
                            : 0f;

            producedPower = 0f;

            // First, get renewable energy first
            for (int i = 0; i < this.Chargers.Length; i++)
            {
                producedPower += this.Chargers[i].Generate(powerDeficit);
            }

            if (powerDeficit > config.EmergencyEnergyDeficit ||
                // Did the renewable energy sources not produce any power?
                (powerDeficit > config.MinimumEnergyDeficit && producedPower < MinimalPowerValue))
            // Is the power deficit over the threshhold to start consuming non-renewable energy?
            {
                // Second, get non-renewable energy if there isn't enough renewable energy
                for (int i = 0; i < this.Chargers.Length; i++)
                {
                    producedPower += this.Chargers[i].Drain(powerDeficit);
                }
            }

            if (producedPower > 0f)
            {
                Cyclops.powerRelay.ModifyPower(producedPower * this.RechargePenalty, out float amountStored);
            }

            // Last, inform the chargers to update their display status
            for (int i = 0; i < this.Chargers.Length; i++)
            {
                this.Chargers[i].UpdateStatus();
            }

            return(requiresVanillaCharging);
        }
Ejemplo n.º 23
0
 private static void OnCraftEndPrefix(EnergyMixin __instance, TechType techType)
 {
     if (!Config.NORMAL.Equals(DeathRun.config.batteryCosts) && !GameModeUtils.IsOptionActive(GameModeOption.Creative))
     {
         if (techType != TechType.MapRoomCamera)
         {
             __instance.defaultBattery = 0;
         }
     }
 }
Ejemplo n.º 24
0
        public static void Postfix(IngameMenu __instance)
        {
            if (GameModeUtils.IsPermadeath())
            {
                return;
            }

            if (__instance != null && quitButton == null)
            {
                // make a new confirmation Menu
                var quitConfirmationPrefab = __instance.gameObject.FindChild("QuitConfirmation");
                quitConfirmation      = GameObject.Instantiate(quitConfirmationPrefab, __instance.gameObject.FindChild("QuitConfirmation").transform.parent);
                quitConfirmation.name = "QuitToDesktopConfirmation";


                // get the No Button and add the needed listeners to it
                var noButtonPrefab = quitConfirmation.gameObject.transform.Find("ButtonNo").GetComponent <Button>();
                noButtonPrefab.onClick.RemoveAllListeners();
                noButtonPrefab.onClick.AddListener(() => { __instance.Close(); });


                // get the Yes Button and add the needed listeners to it
                var yesButtonPrefab = quitConfirmation.gameObject.transform.Find("ButtonYes").GetComponent <Button>();
                yesButtonPrefab.onClick.RemoveAllListeners();
                yesButtonPrefab.onClick.AddListener(() => { __instance.QuitGame(true); });


                // make the Quit To Desktop Button
                var buttonPrefab = __instance.quitToMainMenuButton;
                quitButton      = GameObject.Instantiate(buttonPrefab, __instance.quitToMainMenuButton.transform.parent);
                quitButton.name = "ButtonQuitToDesktop";
                quitButton.onClick.RemoveAllListeners();
                quitButton.onClick.AddListener(() => { __instance.gameObject.FindChild("QuitConfirmationWithSaveWarning").SetActive(false); });  // set the confirmation with save false so it doesn't conflict
                quitButton.onClick.AddListener(() => { __instance.gameObject.FindChild("QuitConfirmation").SetActive(false); });                 // set the Quit To Main Menu confirmation to false so it doesn't conflict
                if (!QPatch.Config.ShowConfirmationDialog)
                {
                    quitButton.onClick.AddListener(() => { __instance.QuitGame(true); });
                }
                else if (QPatch.Config.ShowConfirmationDialog)
                {
                    quitButton.onClick.AddListener(() => { quitConfirmation.SetActive(true); });                     // set our new confirmation to true
                }
                IEnumerable <Text> texts = quitButton.GetComponents <Text>().Concat(quitButton.GetComponentsInChildren <Text>());
                foreach (Text text in texts)
                {
                    text.text = "Quit to Desktop";
                }

                texts = __instance.quitToMainMenuButton.GetComponents <Text>().Concat(__instance.quitToMainMenuButton.GetComponentsInChildren <Text>());
                foreach (Text text in texts)
                {
                    text.text = "Quit to Main Menu";
                }
            }
        }
        public override void UpdateText()
        {
            if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap)
            {
                base.UpperText.FontSize  = 20;
                base.MiddleText.FontSize = 20;
                base.LowerText.FontSize  = 20;

                base.UpperText.TextString  = "CYCLOPS";
                base.MiddleText.TextString = "POWER";
                base.LowerText.TextString  = "LOW";

                base.UpperText.TextColor  = Color.red;
                base.MiddleText.TextColor = Color.red;
                base.LowerText.TextColor  = Color.red;
            }
            else
            {
                base.UpperText.FontSize = 12;
                base.LowerText.FontSize = 12;

                if (zapper.SeamothInBay)
                {
                    base.UpperText.TextString = "Seamoth\n[Connected]";
                    base.UpperText.TextColor  = Color.green;

                    if (zapper.HasSeamothWithElectricalDefense)
                    {
                        if (zapper.IsOnCooldown)
                        {
                            base.LowerText.TextString = "Defense System\n[Cooldown]";
                            base.LowerText.TextColor  = Color.yellow;
                        }
                        else
                        {
                            base.LowerText.TextString = "Defense System\n[Charged]";
                            base.LowerText.TextColor  = Color.white;
                        }
                    }
                    else
                    {
                        base.LowerText.TextString = "Defense System\n[Missing]";
                        base.LowerText.TextColor  = Color.red;
                    }
                }
                else
                {
                    base.UpperText.TextString = "Seamoth\n[Not Connected]";
                    base.UpperText.TextColor  = Color.red;

                    base.MiddleText.TextString = string.Empty;
                    base.LowerText.TextString  = string.Empty;
                }
            }
        }
        private void StartShield()
        {
            sfx.Play();

            if (GameModeUtils.RequiresPower())
            {
                InvokeRepeating("ShieldIteration", 0f, shieldRunningIteration);
            }

            StartSeamothShielded();
        }
Ejemplo n.º 27
0
 private void UpdateLightEnergy()
 {
     if (lightIsActive)
     {
         float energyCost     = DayNightCycle.main.deltaTime * ExosuitSettings.lightEnergyConsumption;
         float consumedEnergy = energyInterface.ConsumeEnergy(energyCost);
         if (consumedEnergy == 0 && energyCost != 0 && GameModeUtils.RequiresPower())
         {
             SetLightsActive(false);
         }
     }
 }
Ejemplo n.º 28
0
        public override void Process(PowerLevelChanged packet)
        {
            GameObject gameObject = GuidHelper.RequireObjectFrom(packet.Guid);

            if (packet.PowerType == PowerType.ENERGY_INTERFACE)
            {
                EnergyInterface energyInterface = gameObject.RequireComponent <EnergyInterface>();

                float amount = packet.Amount;
                float num    = 0f;
                if (GameModeUtils.RequiresPower())
                {
                    int num2 = 0;
                    if (packet.Amount > 0f)
                    {
                        float num3 = energyInterface.TotalCanConsume(out num2);
                        if (num3 > 0f)
                        {
                            float amount2 = amount / (float)num2;
                            for (int i = 0; i < energyInterface.sources.Length; i++)
                            {
                                EnergyMixin energyMixin = energyInterface.sources[i];
                                if (energyMixin != null && energyMixin.charge < energyMixin.capacity)
                                {
                                    num += energyMixin.ModifyCharge(amount2);
                                }
                            }
                        }
                    }
                    else
                    {
                        float num4 = energyInterface.TotalCanProvide(out num2);
                        if (num2 > 0)
                        {
                            amount = ((-amount <= num4) ? amount : (-num4));
                            for (int j = 0; j < energyInterface.sources.Length; j++)
                            {
                                EnergyMixin energyMixin2 = energyInterface.sources[j];
                                if (energyMixin2 != null && energyMixin2.charge > 0f)
                                {
                                    float num5 = energyMixin2.charge / num4;
                                    num += energyMixin2.ModifyCharge(amount * num5);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Log.Error("Unsupported packet power type: " + packet.PowerType);
            }
        }
        public static void Postfix(bool locked, ref string tooltipText)
        {
            var stringBuilder = new StringBuilder();

            if (!locked || !GameModeUtils.RequiresBlueprints())
            {
                return;
            }
            TooltipFactory.WriteTitle(stringBuilder, Main.Config.UnKnownTitle);
            TooltipFactory.WriteDescription(stringBuilder, Main.Config.UnKnownDescription);
            tooltipText = stringBuilder.ToString();
        }
Ejemplo n.º 30
0
        public static bool Prefix(ref NitrogenLevel __instance, Player player)
        {
            Inventory main     = Inventory.main;
            TechType  bodySlot = Inventory.main.equipment.GetTechTypeInSlot("Body");
            TechType  headSlot = Inventory.main.equipment.GetTechTypeInSlot("Head");

            if (GameModeUtils.RequiresOxygen())
            {
                float depthOf = Ocean.main.GetDepthOf(player.gameObject);
                if (__instance.nitrogenEnabled)
                {
                    float modifier = 1f;
                    if (depthOf > 0f)
                    {
                        if (bodySlot == ReinforcedSuitsCore.ReinforcedSuit3ID)
                        {
                            modifier = 0.55f;
                        }
                        else if ((bodySlot == ReinforcedSuitsCore.ReinforcedSuit2ID || bodySlot == ReinforcedSuitsCore.ReinforcedStillSuit) && depthOf <= 1300f)
                        {
                            modifier = 0.75f;
                        }
                        else if (bodySlot == TechType.ReinforcedDiveSuit && depthOf <= 800f)
                        {
                            modifier = 0.85f;
                        }
                        else if ((bodySlot == TechType.RadiationSuit || bodySlot == TechType.Stillsuit) && depthOf <= 500f)
                        {
                            modifier = 0.95f;
                        }
                        if (headSlot == TechType.Rebreather)
                        {
                            modifier -= 0.05f;
                        }
                    }
                    float num = __instance.depthCurve.Evaluate(depthOf / 2048f);
                    __instance.safeNitrogenDepth = UWE.Utils.Slerp(__instance.safeNitrogenDepth, depthOf, num * __instance.kBreathScalar * modifier);
                }

                if (crushEnabled && Player.main.GetDepthClass() == Ocean.DepthClass.Crush)
                {
                    if (UnityEngine.Random.value < 0.5f)
                    {
                        float crushDepth = PlayerGetDepthClassPatcher.divingCrushDepth;
                        if (depthOf > crushDepth)
                        {
                            DamagePlayer(depthOf - crushDepth);
                        }
                    }
                }
            }
            return(false);
        }