public static bool Prefix(ref SubRoot __instance)
        {
            UpgradeManager upgradeMgr = CyclopsManager.GetUpgradeManager(__instance);

            if (upgradeMgr == null)
            {
                return(true);
            }

            CrushDamage crushDmg = __instance.gameObject.GetComponent <CrushDamage>();

            if (crushDmg == null)
            {
                return(true);
            }

            float orignialCrushDepth = crushDmg.crushDepth;

            crushDmg.SetExtraCrushDepth(upgradeMgr.BonusCrushDepth);

            if (orignialCrushDepth != crushDmg.crushDepth)
            {
                ErrorMessage.AddMessage(Language.main.GetFormat("CrushDepthNow", crushDmg.crushDepth));
            }

            return(false); // Completely override the method and do not continue with original execution
            // The original method execution sucked anyways :P
        }
Ejemplo n.º 2
0
        public static bool Prefix(ref DockedVehicleHandTarget __instance, GUIHand hand)
        {
#if SUBNAUTICA_STABLE
            Vehicle dockedVehicle = __instance.dockingBay.GetDockedVehicle();
#elif BELOWZERO
#endif
            if (!(dockedVehicle != null))
            {
                HandReticle.main.SetInteractInfo("NoVehicleDocked");
                return(false);
            }
            bool        crushDanger = false;
            CrushDamage crushDamage = dockedVehicle.crushDamage;
            if (crushDamage != null)
            {
                float crushDepth = crushDamage.crushDepth;
                if (Ocean.main.GetDepthOf(Player.main.gameObject) > crushDepth)
                {
                    crushDanger = true;
                }
            }
            string text = (dockedVehicle is Exosuit) ? "EnterExosuit" : "EnterSeamoth";
            bool   result;
            string prompt      = "";
            string vehicleName = dockedVehicle.GetName();
            result = Main.TryGetVehiclePrompt(text, Language.main.GetCurrentLanguage(), dockedVehicle.GetName(), out prompt);
            //Logger.Log(Logger.Level.Debug, $"DockedVehicleHandTarget_OnHandHover_Patch.Prefix(): with docked vehicle {vehicleName}, called OnHandHover with text {text}; Main.TryGetVehiclePrompt({text}) returned prompt '{prompt}'", null, true);
            if (result)
            {
                text = prompt;
            }
            if (crushDanger)
            {
                HandReticle.main.SetInteractText(text, "DockedVehicleDepthWarning");
                return(false);
            }
            EnergyMixin component = dockedVehicle.GetComponent <EnergyMixin>();
            LiveMixin   liveMixin = dockedVehicle.liveMixin;
            if (component.charge < component.capacity)
            {
                string format = Language.main.GetFormat <float, float>("VehicleStatusFormat", liveMixin.GetHealthFraction(), component.GetEnergyScalar());
                HandReticle.main.SetInteractText(text, format, true, false, HandReticle.Hand.Left);
            }
            else
            {
                string format2 = Language.main.GetFormat <float>("VehicleStatusChargedFormat", liveMixin.GetHealthFraction());
                HandReticle.main.SetInteractText(text, format2, true, false, HandReticle.Hand.Left);
            }
            HandReticle.main.SetIcon(HandReticle.IconType.Hand, 1f);

            return(false);
        }
        internal static void Postfix(ref CrushDamage __instance)
        {
            var seamoth = __instance.GetComponentInParent <SeaMoth>();
            var exosuit = __instance.GetComponentInParent <Exosuit>();

            if (seamoth != null)
            {
                VehicleUpgrader.UpgradeSeaMoth(seamoth);
            }
            else if (exosuit != null)
            {
                VehicleUpgrader.UpgradeExosuit(exosuit);
            }
        }
        public CrushDepthUpgradesHandler() : base(NoBonusCrushDepth)
        {
            OnFinishedUpgrades += (SubRoot cyclops) =>
            {
                CrushDamage crushDmg = cyclops.gameObject.GetComponent <CrushDamage>();

                crushDmg.SetExtraCrushDepth(this.HighestValue);
            };

            foreach (KeyValuePair <TechType, float> upgrade in SubRoot.hullReinforcement)
            {
                TieredUpgradeHandler <float> tier = CreateTier(upgrade.Key, upgrade.Value);
            }
        }
Ejemplo n.º 5
0
        private static void OverrideCrushDepth(CrushDamage crushDamage, float minimumBonus, bool announce)
        {
            // Can set a minimum crush depth without upgrades
            float bonusCrushDepth = Mathf.Max(minimumBonus, crushDamage.extraCrushDepth);

            float origCrush = crushDamage.crushDepth;

            crushDamage.SetExtraCrushDepth(bonusCrushDepth);

            float nextCrush = crushDamage.crushDepth;

            if (announce && !Mathf.Approximately(origCrush, nextCrush))
            {
                ErrorMessage.AddMessage(Language.main.GetFormat("CrushDepthNow", crushDamage.crushDepth));
            }
        }
Ejemplo n.º 6
0
        public static bool Prefix(ref SubRoot __instance)
        {
            if (__instance.upgradeConsole == null)
            {
                return(true); // safety check
            }
            Equipment coreModules = __instance.upgradeConsole.modules;

            float bonusCrushDepth = GetMaxBonusCrushDepth(coreModules, UpgradeConsoleCache.AuxUpgradeConsoles);

            CrushDamage component = __instance.gameObject.GetComponent <CrushDamage>();

            component.SetExtraCrushDepth(bonusCrushDepth);

            return(false); // Completely override the method and do not continue with original execution
            // The original method execution sucked anyways :P
        }
Ejemplo n.º 7
0
        public static bool GetDepthClass(Player __instance, ref Ocean.DepthClass __result)
        {
            Ocean.DepthClass result      = Ocean.DepthClass.Surface;
            CrushDamage      crushDamage = null;

            var currSub = __instance.currentSub;
            var mode    = (Mode)PlayerPatches.mode.GetValue(__instance);
            var living  = (Living)__instance;

            if ((currSub != null && !currSub.isBase) || mode == Mode.LockedPiloting)
            {
                crushDamage = ((!(currSub != null)) ? living.gameObject.GetComponentInParent <CrushDamage>() : currSub.gameObject.GetComponent <CrushDamage>());
            }
            if (crushDamage != null)
            {
                result = crushDamage.GetDepthClass();
                __instance.crushDepth = crushDamage.crushDepth;
            }
            else
            {
                var c = GameModeUtilsPatches.currentConfig.Oxygen;

                __instance.crushDepth = 0f;
                float depthOf = Ocean.GetDepthOf(living.gameObject);
                if (depthOf > c.DeficiencyDepths[1])
                {
                    result = Ocean.DepthClass.Crush;
                }
                else if (depthOf > c.DeficiencyDepths[0])
                {
                    result = Ocean.DepthClass.Unsafe;
                }
                else if (depthOf > __instance.GetSurfaceDepth())
                {
                    result = Ocean.DepthClass.Safe;
                }
            }

            __result = result;
            return(false);
        }
 internal static bool Prefix(ref CrushDamage __instance)
 {
     // true will return control to the original method
     // false will prevent this method from executing until CrushDepthSet is done
     return(VehicleUpgrader.CrushDepthSet);
 }