Ejemplo n.º 1
0
        public override void Process(PowerLevelChanged packet)
        {
            Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(packet.Guid);

            if (opGameObject.IsPresent())
            {
                GameObject gameObject = opGameObject.Get();

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

                    if (energyInterface != null)
                    {
                        energyInterface.ModifyCharge(packet.Amount);
                    }
                    else
                    {
                        Console.WriteLine("Energy interface was not found on that game object!");
                    }
                }
                else
                {
                    Console.WriteLine("Unsupported packet power type: " + packet.PowerType);
                }
            }
            else
            {
                Console.WriteLine("Could not locate game object with guid: " + packet.Guid);
            }
        }
        public static float highBeamEnergyCost = 0.05f; // starts with energy cost for Turbo mode


        // ######################################################################
        // Helper method
        // ######################################################################

        public static void ConsumeHighBeamEnergy(Vehicle thisVehicle, float thisEnergyCost)
        {
            EnergyInterface thisEnergyInterface = thisVehicle.GetComponent <EnergyInterface>();
            float           amount = DayNightCycle.main.deltaTime * thisEnergyCost;

            thisEnergyInterface.ConsumeEnergy(amount);
        }
Ejemplo n.º 3
0
        public static void ConsumeOxygenEnergy(Vehicle thisVehicle, float thisEnergyCost)
        {
            EnergyInterface thisEnergyInterface = thisVehicle.GetComponent <EnergyInterface>();
            //float amount = __instance.oxygenPerSecond * energyCost;
            float amount = DayNightCycle.main.deltaTime * thisEnergyCost;

            thisEnergyInterface.ConsumeEnergy(amount);
        }
Ejemplo n.º 4
0
        public static void Postfix(EnergyInterface __instance, float amount, float __result)
        {
            PowerMonitor powerMonitor = __instance.gameObject.GetComponent <PowerMonitor>();

            if (powerMonitor == null)
            {
                powerMonitor = __instance.gameObject.AddComponent <PowerMonitor>();
            }

            powerMonitor.ChargeChanged(__result, powerMonitor.gameObject);
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        public override void Process(PowerLevelChanged packet)
        {
            GameObject gameObject = GuidHelper.RequireObjectFrom(packet.Guid);

            if (packet.PowerType == PowerType.ENERGY_INTERFACE)
            {
                EnergyInterface energyInterface = gameObject.RequireComponent <EnergyInterface>();
                energyInterface.ModifyCharge(packet.Amount);
            }
            else
            {
                Log.Error("Unsupported packet power type: " + packet.PowerType);
            }
        }
Ejemplo n.º 7
0
 static void Postfix(EnergyInterface __instance, float amount)
 {
     if (Player.main.currentMountedVehicle.energyInterface == __instance && Player.main.currentSub == null)
     {
         if (amount < 0)
         {
             EnergyInfo.energyConsumption += amount;
         }
         else
         {
             EnergyInfo.energyProduction += amount;
         }
     }
 }
Ejemplo n.º 8
0
        public virtual void Awake()
        {
            TruckHelper.MainCab.EnsureComponent <ImmuneToPropulsioncannon>();
            EnergyInterface energyInterface = TruckHelper.MainCab.EnsureComponent <EnergyInterface>();

            energyInterface.sources            = TruckHelper.MainCab.GetComponentsInChildren <BatterySource>();
            propulsionCannon.energyInterface   = energyInterface;
            propulsionCannon.shootForce        = 60f;
            propulsionCannon.attractionForce   = 145f;
            propulsionCannon.massScalingFactor = 0.005f;
            propulsionCannon.pickupDistance    = 25f;
            propulsionCannon.maxMass           = 1800f;
            propulsionCannon.maxAABBVolume     = 400f;
        }
Ejemplo n.º 9
0
        public static void PostUpdate(uGUI_ExosuitHUD __instance)
        {
            if (__instance == null || !Main.config.bHUDAbsoluteValues || Player.main == null)
            {
                return;
            }

            exosuit = Player.main.GetVehicle() as Exosuit;
            if (exosuit == null)
            {
                return;
            }

            if (exosuit.liveMixin == null)
            {
                return;
            }

            //Log.LogDebug($"ExosuitHUDPatches.PostUpdate() begin");

            int charge;

            //float capacity;

            if (__instance.textHealth != null)
            {
                int health = Mathf.RoundToInt(exosuit.liveMixin.health);
                __instance.textHealth.text = IntStringCache.GetStringForInt(health);
            }

            if (__instance.textPower != null)
            {
                EnergyInterface energy = (EnergyInterface)(ExosuitPatches.energyInterfaceField.GetValue(exosuit));
                if (energy == null)
                {
                    return;
                }

                //energy.GetValues(out charge, out capacity);
                charge = Mathf.RoundToInt(energy.TotalCanProvide(out int i));
                //ErrorMessage.AddMessage($"Current Charge {charge}");
                __instance.textPower.text     = IntStringCache.GetStringForInt(charge);
                __instance.textPower.fontSize = (charge > 9999 ? 28 : 36);
            }
            //Log.LogDebug($"ExosuitHUDPatches.PostUpdate() finish");
        }
        [HarmonyPostfix]      // Harmony postfix
        public static void Postfix(uGUI_SeamothHUD __instance)
        {
            Player main = Player.main;

            if (main != null)
            {
                Vehicle thisSeamoth = (main.GetVehicle() as SeaMoth);

                string colorStart;
                string colorStartDesc;
                string colorWhite  = "<color=white>";
                string colorGrey   = "<color=grey>";
                string colorYellow = "<color=yellow>";
                string colorRed    = "<color=red>";
                string colorEnd    = "</color>";
                string normalFont  = "<size=" + Config.VehicleFontSizeSliderValue.ToString() + ">";
                string smallFont   = "<size=" + (Config.VehicleFontSizeSliderValue / 1.5).ToString() + ">";

                if (SeamothInfo.seamothLinkModuleIn)
                {
                    colorStartDesc = colorYellow;
                }
                else
                {
                    colorStartDesc = colorGrey;
                }

                // ################################################
                // Health display
                // ################################################

                if (thisSeamoth != null)
                {
                    LiveMixin     thisLiveMixin = thisSeamoth.GetComponent <LiveMixin>();
                    float         healthStatus  = thisLiveMixin.GetHealthFraction();
                    StringBuilder stringBuilder = new StringBuilder();

                    // Run only if Electronic Enhancement Module is loaded
                    if (SeamothInfo.electronicModuleIn)
                    {
                        if (Config.MarchThroughHealthValue == 1f) // display maximum health (mh) allways in default colours
                        {
                            float thisMaxHealth = thisLiveMixin.data.maxHealth;
                            stringBuilder.Append(normalFont);
                            stringBuilder.Append(Mathf.Round(thisMaxHealth).ToString());
                            stringBuilder.Append("</size>");
                            stringBuilder.Append(smallFont);
                            stringBuilder.Append(colorStartDesc + "mh" + colorEnd);
                            stringBuilder.Append("</size>");
                            __instance.textHealth.text = stringBuilder.ToString();
                        }
                        else if (Config.MarchThroughHealthValue == 2f) // display health and change colours if damaged as per mod options settings
                        {
                            float thisHealth = thisLiveMixin.health;

                            // Set warning colours of health status as per mod options
                            if (healthStatus * 100f <= Mathf.Floor(Config.HealthLowerLimitSliderValue))
                            {
                                colorStart = colorRed;
                            }
                            else if (healthStatus * 100f > Mathf.Floor(Config.HealthLowerLimitSliderValue) && healthStatus * 100f <= Mathf.Floor(Config.HealthUpperLimitSliderValue))
                            {
                                colorStart = colorYellow;
                            }
                            else
                            {
                                colorStart = colorWhite;
                            }

                            stringBuilder.Append(normalFont);
                            stringBuilder.Append(colorStart + Mathf.Round(thisHealth).ToString() + colorEnd);
                            stringBuilder.Append("</size>");
                            stringBuilder.Append(smallFont);
                            stringBuilder.Append(colorStartDesc + "h" + colorEnd);
                            stringBuilder.Append("</size>");
                            __instance.textHealth.text = stringBuilder.ToString();
                        }
                        else // display health status as a % and change colours if damaged as per mod options settings
                        {
                            // Set warning colours of health status as per mod options
                            if (SeamothInfo.seamothLinkModuleIn)
                            {
                                if (healthStatus * 100f <= Mathf.Floor(Config.HealthLowerLimitSliderValue))
                                {
                                    colorStart = colorRed;
                                }
                                else if (healthStatus * 100f > Mathf.Floor(Config.HealthLowerLimitSliderValue) && healthStatus * 100f <= Mathf.Floor(Config.HealthUpperLimitSliderValue))
                                {
                                    colorStart = colorYellow;
                                }
                                else
                                {
                                    colorStart = colorWhite;
                                }
                            }
                            else
                            {
                                colorStart = colorWhite;
                            }

                            stringBuilder.Append(normalFont);
                            stringBuilder.Append(colorStart + Mathf.Round(healthStatus * 100f).ToString() + colorEnd);
                            stringBuilder.Append("</size>");
                            stringBuilder.Append(smallFont);
                            stringBuilder.Append(colorStartDesc + "%" + colorEnd);
                            stringBuilder.Append("</size>");

                            __instance.textHealth.text = stringBuilder.ToString();
                        }
                    }    // end if (upgradeLoaded)
                    else // display as per vanilla game
                    {
                        stringBuilder.Append(Mathf.Round(healthStatus * 100f).ToString());
                        __instance.textHealth.text = stringBuilder.ToString();
                    }
                } // end if (thisSeamoth != null)


                // ################################################
                // Power display
                // ################################################

                if (thisSeamoth != null)
                {
                    EnergyMixin     thisEnergyMixing    = thisSeamoth.GetComponent <EnergyMixin>();
                    EnergyInterface thisEnergyInterface = thisEnergyMixing.GetComponent <EnergyInterface>();
                    thisEnergyInterface.GetValues(out float charge, out float capacity);
                    StringBuilder stringBuilder = new StringBuilder();

                    // Run only if Electronic Enhancement Module is loaded
                    if (SeamothInfo.electronicModuleIn)
                    {
                        if (Config.MarchThroughPowerValue == 1f) // display maximum cell charge capacity in units(mu) allways in default colours
                        {
                            stringBuilder.Append(normalFont);
                            if (capacity > 999f)
                            {
                                stringBuilder.Append(capacity.ToString("0E+0")); // Displays vehicle cell capacity in scientif number format
                            }
                            else
                            {
                                stringBuilder.Append(capacity.ToString()); // Displays vehicle cell capacity
                            }
                            stringBuilder.Append("</size>");
                            stringBuilder.Append(smallFont);
                            stringBuilder.Append(colorStartDesc + "mu" + colorEnd);
                            stringBuilder.Append("</size>");
                        }
                        else if (Config.MarchThroughPowerValue == 2f) // display cell charge capacity in units(u) and change colours as per mod options settings
                        {
                            // Set warning colours of charge status as per mod options
                            if (SeamothInfo.seamothLinkModuleIn)
                            {
                                if (charge / capacity * 100f <= Mathf.Floor(Config.PowerLowerLimitSliderValue) || SeamothInfo.BatteryInSlot == 0)
                                {
                                    colorStart = colorRed;
                                }
                                else if (charge / capacity * 100f > Mathf.Floor(Config.PowerLowerLimitSliderValue) && charge / capacity * 100f <= Mathf.Floor(Config.PowerUpperLimitSliderValue))
                                {
                                    colorStart = colorYellow;
                                }
                                else
                                {
                                    colorStart = colorWhite;
                                }
                            }
                            else
                            {
                                colorStart = colorWhite;
                            }

                            if (charge > 20f)
                            {
                                stringBuilder.Append(normalFont);
                                stringBuilder.Append(colorStart);
                                if (charge > 999f)
                                {
                                    stringBuilder.Append(Mathf.RoundToInt(charge).ToString("0E+0")); // Displays vehicle cell charge in scientif number format
                                }
                                else
                                {
                                    stringBuilder.Append(Mathf.RoundToInt(charge).ToString()); // Displays vehicle cell charge
                                }
                                stringBuilder.Append(colorEnd);
                                stringBuilder.Append("</size>");
                                stringBuilder.Append(smallFont);
                                stringBuilder.Append(colorStartDesc + "u" + colorEnd);
                                stringBuilder.Append("</size>");
                            }
                            else
                            {
                                // blinking HUD value
                                SeamothInfo.timer = SeamothInfo.timer + Time.deltaTime;
                                if (SeamothInfo.timer >= 0.5)
                                {
                                    stringBuilder.Append(normalFont);
                                    stringBuilder.Append(colorStart);
                                    if (charge > 999f)
                                    {
                                        stringBuilder.Append(Mathf.RoundToInt(charge).ToString("0E+0")); // Displays vehicle cell charge in scientif number format
                                    }
                                    else
                                    {
                                        stringBuilder.Append(Mathf.RoundToInt(charge).ToString()); // Displays vehicle cell charge
                                    }
                                    stringBuilder.Append(colorEnd);
                                    stringBuilder.Append("</size>");
                                    stringBuilder.Append(smallFont);
                                    stringBuilder.Append(colorStartDesc + "u" + colorEnd);
                                    stringBuilder.Append("</size>");
                                }
                                if (SeamothInfo.timer >= 3)
                                {
                                    SeamothInfo.timer = 0;
                                }
                            }
                        }
                        else // display cell charge in % and change colours as per mod options settings
                        {
                            // Set warning colours of charge status as per mod options
                            if (SeamothInfo.seamothLinkModuleIn)
                            {
                                if (charge / capacity * 100f <= Mathf.Floor(Config.PowerLowerLimitSliderValue))
                                {
                                    colorStart = colorRed;
                                }
                                else if (charge / capacity * 100f > Mathf.Floor(Config.PowerLowerLimitSliderValue) && charge / capacity * 100f <= Mathf.Floor(Config.PowerUpperLimitSliderValue))
                                {
                                    colorStart = colorYellow;
                                }
                                else
                                {
                                    colorStart = colorWhite;
                                }
                            }
                            else
                            {
                                colorStart = colorWhite;
                            }

                            if (charge > 20f)
                            {
                                stringBuilder.Append(normalFont + colorStart + Mathf.RoundToInt(charge / capacity * 100f).ToString() + colorEnd + "</size>"); // Displays battery charge
                                stringBuilder.Append(smallFont);
                                stringBuilder.Append(colorStartDesc + "%" + colorEnd);
                                stringBuilder.Append("</size>");
                            }
                            else
                            {
                                SeamothInfo.timer = SeamothInfo.timer + Time.deltaTime;
                                if (SeamothInfo.timer >= 0.5)
                                {
                                    stringBuilder.Append(normalFont + colorStart + Mathf.RoundToInt(charge / capacity * 100f).ToString() + colorEnd + "</size>");
                                    stringBuilder.Append(smallFont);
                                    stringBuilder.Append(colorStartDesc + "%" + colorEnd);
                                    stringBuilder.Append("</size>");
                                }
                                if (SeamothInfo.timer >= 3)
                                {
                                    SeamothInfo.timer = 0;
                                }
                            }
                        } // end else

                        __instance.textPower.text = stringBuilder.ToString();
                    }    // end if (upgradeLoaded)
                    else // display as per vanilla game
                    {
                        stringBuilder.Append(Mathf.RoundToInt(charge / capacity * 100f).ToString());
                        __instance.textPower.text = stringBuilder.ToString();
                    }
                } // end if (thisSeamoth != null)


                // ################################################
                // Temperature display
                // ################################################

                if (thisSeamoth != null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    int           waterTemp     = Traverse.Create(__instance).Field("lastTemperature").GetValue <int>();

                    if (SeamothInfo.electronicModuleIn)
                    {
                        // Set warning colours of water temperature as per mod options
                        if (SeamothInfo.seamothLinkModuleIn)
                        {
                            if (waterTemp <= Mathf.Floor(Config.TempMothLowerLimitSliderValue))
                            {
                                colorStart = colorWhite;
                            }
                            else if (waterTemp > Mathf.Floor(Config.TempMothLowerLimitSliderValue) && waterTemp <= Mathf.Floor(Config.TempMothUpperLimitSliderValue))
                            {
                                colorStart = colorYellow;
                            }
                            else
                            {
                                colorStart = colorRed;
                            }
                        }
                        else
                        {
                            colorStart = colorWhite;
                        }

                        // Set font size and colour
                        stringBuilder.Append("<size=" + Config.VehicleFontSizeSliderValue.ToString() + ">");
                        stringBuilder.Append(colorStart + waterTemp.ToString() + colorEnd);
                        stringBuilder.Append("</size>");
                        __instance.textTemperature.text = stringBuilder.ToString();
                    }    // end if (upgradeLoaded)
                    else // display as per vanilla game
                    {
                        stringBuilder.Append(waterTemp.ToString());
                        __instance.textTemperature.text = stringBuilder.ToString();
                    }
                } // end if (thisSeamoth != null)
            }     // end if (main != null)
        }         // end public static void Postfix(uGUI_SeamothHUD __instance)
Ejemplo n.º 11
0
        //public Dictionary<TechType, string> TechStringCache = new Dictionary<TechType, string>();

        private void Start()
        {
            elecLines       = fxBeam.GetComponentsInChildren <VFXElectricLine>(true);
            shaderParamID   = Shader.PropertyToID("_OverlayStrength");
            energyInterface = GetComponent <EnergyInterface>();
        }
Ejemplo n.º 12
0
 public override void Awake()
 {
     target = GetComponent <EnergyInterface>();
     base.Awake();
 }
        [HarmonyPrefix]      // Harmony prefix
        public static bool Prefix(Vehicle __instance, ref float energyCost, ref bool __result)
        {
            float           enginePowerRating   = Traverse.Create(__instance).Field("enginePowerRating").GetValue <float>();
            EnergyInterface thisEnergyInterface = __instance.GetComponent <EnergyInterface>();
            EnergyMixin     thisEnergyMixing    = __instance.GetComponent <EnergyMixin>();
            float           realEnergyCost      = energyCost / enginePowerRating;

            if (Player.main.currentMountedVehicle != null && Player.main.currentMountedVehicle == __instance)
            {
                if (SeamothInfo.ModeGreenOn) // Only gears 1 to 5 are provided (note that the first number in the division bracket is the desired energy consumption)
                {
                    if (Config.SeamothGearValue == 1f)
                    {
                        realEnergyCost = energyCost * (10f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 2f)
                    {
                        realEnergyCost = energyCost * (20f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 3f)
                    {
                        realEnergyCost = energyCost * (40f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 4f)
                    {
                        realEnergyCost = energyCost / enginePowerRating; // Energy consumption is 80 (80f / 80f)
                    }
                    else if (Config.SeamothGearValue == 5f)
                    {
                        realEnergyCost = energyCost * (120f / 80f) / enginePowerRating;
                    }
                }
                else
                { // note that the first number in the division bracket is the desired energy consumption
                    if (Config.SeamothGearValue == 1f)
                    {
                        realEnergyCost = energyCost * (10f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 2f)
                    {
                        realEnergyCost = energyCost * (30f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 3f)
                    {
                        realEnergyCost = energyCost * (60f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 4f)
                    {
                        realEnergyCost = energyCost * (100f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 5f)
                    {
                        realEnergyCost = energyCost * (150f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 6f)
                    {
                        realEnergyCost = energyCost * (300f / 80f) / enginePowerRating;
                    }
                } // end else
                int   num;
                float energyCanProvide = thisEnergyInterface.TotalCanProvide(out num);
                __result = thisEnergyMixing.ConsumeEnergy(Mathf.Min(realEnergyCost, energyCanProvide));
                return(false);
            } // end if (Player.main.currentMountedVehicle != null)
            return(true);
        }     // end public static bool Prefix(Vehicle __instance, ref float energyCost, ref bool __result)
Ejemplo n.º 14
0
        public void OnShoot()
        {
            EnergyInterface energyInterface = exosuit.GetComponent <EnergyInterface>();

            energyInterface.GetValues(out float charge, out float capacity);

            if (charge > 0f)
            {
                float d = Mathf.Clamp01(charge / 4f);

                Vector3 forward  = MainCamera.camera.transform.forward;
                Vector3 position = MainCamera.camera.transform.position;

                int hits = UWE.Utils.SpherecastIntoSharedBuffer(position, 1f, forward, 35f, ~(1 << LayerMask.NameToLayer("Player")), QueryTriggerInteraction.UseGlobal);

                float targetMass = 0f;

                for (int i = 0; i < hits; i++)
                {
                    RaycastHit raycastHit = UWE.Utils.sharedHitBuffer[i];

                    Vector3 point = raycastHit.point;

                    float magnitude = (position - point).magnitude;

                    float d2 = 1f - Mathf.Clamp01((magnitude - 1f) / 35f);

                    GameObject targetObject = UWE.Utils.GetEntityRoot(raycastHit.collider.gameObject);

                    if (targetObject == null)
                    {
                        targetObject = raycastHit.collider.gameObject;
                    }

                    Rigidbody component = targetObject.GetComponent <Rigidbody>();

                    if (component != null)
                    {
                        targetMass += component.mass;

                        bool flag = true;

                        targetObject.GetComponents(iammo);

                        for (int j = 0; j < iammo.Count; j++)
                        {
                            if (!iammo[j].GetAllowedToShoot())
                            {
                                flag = false;
                                break;
                            }
                        }

                        iammo.Clear();

                        if (flag && !(raycastHit.collider is MeshCollider) && (targetObject.GetComponent <Pickupable>() != null || targetObject.GetComponent <Living>() != null || (component.mass <= 2600f && UWE.Utils.GetAABBVolume(targetObject) <= 800f)))
                        {
                            float   d3       = 1f + component.mass * 0.005f;
                            Vector3 velocity = forward * d2 * d * 140f / d3;
                            ShootObject(component, velocity);
                        }
                    }
                }

                energyInterface.ConsumeEnergy(4f);

                fxControl.Play();

                callBubblesFX = true;

                Utils.PlayFMODAsset(shootSound, transform, 20f);
            }
        }
        public static void Postfix(EnergyInterface __instance, float __result, ref float amount)
        {
            float num = -__instance.ModifyCharge(-Math.Abs(amount * HCPSettings.Instance.PrawnSeamothPowerDrainMultiplier));

            __result = num;
        }
Ejemplo n.º 16
0
        [HarmonyPostfix]      // Harmony postfix
        public static void Postfix(SeaMoth __instance)
        {
            if (__instance.GetPilotingMode())
            {
                EnergyMixin     thisEnergyMixing    = __instance.GetComponent <EnergyMixin>();
                EnergyInterface thisEnergyInterface = thisEnergyMixing.GetComponent <EnergyInterface>();
                thisEnergyInterface.GetValues(out float charge, out float capacity);

                // Display if Player has no Seamoth Link Chip
                if (Config.ShowKeyPromptToggleValue)
                {
                    if (SeamothInfo.electricalModuleIn || SeamothInfo.electronicModuleIn || SeamothInfo.mechanicalModuleIn)
                    {
                        if (!SeamothInfo.seamothLinkModuleIn && !Subtitles.main.popup.isShowingMessage)
                        {
                            DisplayPrompts.DisplayNoLinkPrompts();
                        }
                    }
                }

                // If Seamoth without battery, and electricalModuleIn, show change battery prompt only
                // Display order 1. ELectrical, 2. Electronic, 3. Mechanical (each line adds itself up to the top of player prompts)

                // ###########
                // Mechanical
                // ###########
                if (SeamothInfo.mechanicalModuleIn && SeamothInfo.seamothLinkModuleIn && !FPSInputModule.current.lockMovement && SeamothInfo.BatteryInSlot == 1)
                {
                    // Detect key press and set variable (march up) to set Seamoth gear
                    MonitorGearKeys.MonitorGearKeysDown();

                    if (!Subtitles.main.popup.isShowingMessage && Config.ShowKeyPromptToggleValue && SeamothInfo.BatteryInSlot == 1)
                    {
                        DisplayPrompts.DisplayMechanicalPrompts();
                    }
                }

                // ###########
                // Electronic
                // ###########

                // Adjust gear if SeamothInfo.seamothLinkModuleIn not in
                if (!SeamothInfo.seamothLinkModuleIn && Config.SeamothGearValue != 4f)
                {
                    Config.SeamothGearValue = 4f;
                    PlayerPrefs.SetFloat("SeamothGearValueSlider", Config.SeamothGearValue);
                }

                if (SeamothInfo.electronicModuleIn && SeamothInfo.seamothLinkModuleIn && !FPSInputModule.current.lockMovement && SeamothInfo.BatteryInSlot == 1)
                {
                    // Detect key press and set variable to toggle Cruise Control on / off
                    MonitorCruiseKey.MonitorCruiseKeyDown();

                    // Detect key press and set variable to toggle Turbo on / off
                    if (charge > 20f)
                    {
                        MonitorModeKey.MonitorModeKeyDown();
                    }
                    else
                    {
                        if (!SeamothInfo.ModeGreenOn)
                        {
                            SeamothInfo.ModeGreenOn = true;
                            SeamothInfo.ModeChanged = true;
                        }
                    }

                    // Adjust gear for Green Mode
                    if (SeamothInfo.ModeGreenOn && Config.SeamothGearValue == 6f)
                    {
                        Config.SeamothGearValue = 5f;
                        PlayerPrefs.SetFloat("SeamothGearValueSlider", Config.SeamothGearValue);
                    }

                    // Detect key press and set variable to cycle through health display (mh, h, %)
                    MonitorHealthKey.MonitorHealthKeyDown();

                    // Detect key press and set variable to cycle through power display (mu, u, %)
                    MonitorPowerKey.MonitorPowerKeyDown();

                    if (!Subtitles.main.popup.isShowingMessage && Config.ShowKeyPromptToggleValue)
                    {
                        DisplayPrompts.DisplayElectronicPrompts(charge);
                    }
                } // end if (SeamothInfo.electronicModuleIn)


                // ###########
                // Electrical
                // ###########
                if (SeamothInfo.electricalModuleIn && SeamothInfo.seamothLinkModuleIn && !FPSInputModule.current.lockMovement)
                {
                    // Detect key press for the battery reload button
                    MonitorReloadKey.MonitorReloadKeyDown(__instance);

                    if (SeamothInfo.BatteryInSlot == 1)
                    {
                        // Detect key press and set variable to toggle lights Lo / Hi beam
                        MonitorLightBeamKey.MonitorLightBeamKeyDown(__instance);

                        // Seaglide Map Controls light toggle fix
                        SeaglideMapControlFix.SeaglideMapControlLightFix(__instance);

                        // Show player key prompts
                        if (Player.main != null && !Player.main.GetPDA().isInUse&& !FPSInputModule.current.lockMovement)
                        {
                            if (!Subtitles.main.popup.isShowingMessage && Config.ShowKeyPromptToggleValue)
                            {
                                DisplayPrompts.DisplayElectricalPrompts();
                            }
                            if (SeamothInfo.preventLightToggle == true)
                            {
                                SeamothInfo.preventLightToggle = false;
                            }
                        }
                    }
                    else
                    {
                        if (SeamothInfo.MainBatteryCount > 0)
                        {
                            DisplayPrompts.DisplayInsertBattery();
                        }
                        else
                        {
                            DisplayPrompts.DisplayNoBattery();
                        }
                    }

                    // Display battery prompts when R key was pressed which triggers FPSInputModule.current.lockMovement for 5 seconds
                    if (Player.main != null && FPSInputModule.current.lockMovement)
                    {
                        DisplayPrompts.DisplayBatteryPrompts();
                    }
                }

                if (!SeamothInfo.electricalModuleIn)
                {
                    // Make new default light mode to be a Low Beam mode
                    if (Vehicle_Update_Patch.HighBeamOn)
                    {
                        Vehicle_Update_Patch.HighBeamOn = false;
                    }
                }

                // Update batery count
                MonitorBatteryCount.MonitorSeamothBatteryCount(__instance);

                // Apply Low and High beam light toggle
                ToggleLightBeam.ToggleLoHighBeam(__instance);
            } // end if (__instance.GetPilotingMode())
        }     // end public static void Postfix(SeaMoth __instance)