예제 #1
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);
        }