示例#1
0
        public static void MonitorModeKeyDown()
        {
            // Detect key press and set variable to toggle Seamoth engine Turbo / Green mode

            // Toggle Turbo / Green mode
            if (KeyCodeUtils.GetKeyDown(Config.ModeKeybindValue))
            {
                if (SeamothInfo.ModeGreenOn)
                {
                    if (Config.SeamothGearValue == 6f)
                    {
                        Config.SeamothGearValue = 5f;
                    }

                    SeamothInfo.ModeGreenOn = false;
                    SeamothInfo.ModeChanged = true;
                    PlayerPrefs.SetFloat("SeamothGearValueSlider", Config.SeamothGearValue);
                }
                else
                {
                    SeamothInfo.ModeGreenOn = true;
                    SeamothInfo.ModeChanged = true;
                }
            }
        }
示例#2
0
        public static bool Prefix()
        {
            bool flag  = MainCameraControlPatcher.IsInSeamoth && !Config.EnableSeamoth;
            bool flag2 = MainCameraControlPatcher.IsInPrawnSuit && !Config.EnablePrawn;
            bool flag3 = !Config.EnableSnapTurning || flag || flag2;
            bool result;

            if (flag3)
            {
                result = true;
            }
            else
            {
                bool flag4       = GameInput.GetButtonDown(26) || KeyCodeUtils.GetKeyDown(Config.KeybindKeyRight);
                bool flag5       = GameInput.GetButtonDown(25) || KeyCodeUtils.GetKeyDown(Config.KeybindKeyLeft);
                bool buttonHeld  = GameInput.GetButtonHeld(25);
                bool buttonHeld2 = GameInput.GetButtonHeld(26);
                bool flag6       = flag5 || flag4 || buttonHeld || buttonHeld2;
                bool flag7       = XRSettings.enabled && flag6;
                bool flag8       = flag7;
                if (flag8)
                {
                    MainCameraControlPatcher.UpdatePlayerOrVehicleRotation(flag4, flag5);
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
        public static string FormatButton(Toggle toggle)
        {
            string displayText = null;

            if (toggle.KeyCode == KeyCode.None)
            {
                displayText = GetLanguage("NoInputAssigned");
            }
            else
            {
#pragma warning disable CS0436 // Type conflicts with imported type
                string bindingName =
                    KeyCodeUtils.KeyCodeToString(toggle.KeyCode);
#pragma warning restore CS0436 // Type conflicts with imported type
                if (!string.IsNullOrEmpty(bindingName))
                {
                    displayText = uGUI.GetDisplayTextForBinding(bindingName);
                }
                if (string.IsNullOrEmpty(displayText))
                {
                    displayText = GetLanguage("NoInputAssigned");
                }
            }
            return($"<color=#ADF8FFFF>{displayText}</color>{(toggle.KeyMode == Toggle.Mode.Hold ? " (Hold)" : string.Empty)}");
        }
示例#4
0
        internal static GameObject AddBindingOptionWithCallback(uGUI_OptionsPanel panel, int tab, string label, KeyCode key, GameInput.Device device, UnityAction <KeyCode> callback)
        {
            // Add item
            GameObject gameObject = panel.AddItem(tab, panel.bindingOptionPrefab);

            // Update text
            Text text = gameObject.GetComponentInChildren <Text>();

            if (text != null)
            {
                gameObject.GetComponentInChildren <TranslationLiveUpdate>().translationKey = label;
                text.text = Language.main.Get(label);
                //text.text = label;
            }

            // Create bindings
            uGUI_Bindings bindings = gameObject.GetComponentInChildren <uGUI_Bindings>();
            uGUI_Binding  binding  = bindings.bindings.First();

            // Destroy secondary bindings
            UnityEngine.Object.Destroy(bindings.bindings.Last().gameObject);
            UnityEngine.Object.Destroy(bindings);

            // Update bindings
            binding.device = device;
            binding.value  = KeyCodeUtils.KeyCodeToString(key);
            binding.onValueChanged.RemoveAllListeners();
            binding.onValueChanged.AddListener(new UnityAction <string>((string s) => callback?.Invoke(KeyCodeUtils.StringToKeyCode(s))));

            return(gameObject);
        }
示例#5
0
        internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
        {
            // Add item
            OptionGameObject = panel.AddItem(tabIndex, panel.bindingOptionPrefab);

            // Update text
            Text text = OptionGameObject.GetComponentInChildren <Text>();

            if (text != null)
            {
                OptionGameObject.GetComponentInChildren <TranslationLiveUpdate>().translationKey = Label;
                text.text = Language.main.Get(Label);
            }

            // Create bindings
            uGUI_Bindings bindings = OptionGameObject.GetComponentInChildren <uGUI_Bindings>();
            uGUI_Binding  binding  = bindings.bindings[0];

            // Destroy secondary bindings
            int last = bindings.bindings.Length - 1;

            UnityEngine.Object.Destroy(bindings.bindings[last].gameObject);
            UnityEngine.Object.Destroy(bindings);

            // Update bindings
            binding.device = Device;
            binding.value  = KeyCodeUtils.KeyCodeToString(Key);
            binding.onValueChanged.RemoveAllListeners();
            var callback = new UnityAction <KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));

            binding.onValueChanged.AddListener(new UnityAction <string>((string s) => callback?.Invoke(KeyCodeUtils.StringToKeyCode(s))));

            base.AddToPanel(panel, tabIndex);
        }
示例#6
0
        /// <summary>
        /// The method for reading the <see cref="KeyCode"/> data from the <paramref name="reader"/>.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="objectType"></param>
        /// <param name="existingValue"></param>
        /// <param name="serializer"></param>
        /// <returns></returns>
        public override object ReadJson(JsonReader reader, Type objectType,
                                        object existingValue, JsonSerializer serializer)
        {
            var s = (string)reader.Value;

            return(KeyCodeUtils.StringToKeyCode(s));
        }
        private void Update()
        {
            if (musicSource != null)
            {
                musicSource.volume = volume;
            }

            if (VirtualKey.GetKeyDown(VK.VK_MEDIA_STOP) || KeyCodeUtils.GetKeyDown(Config.StopKey))
            {
                stopped = true;
                paused  = false;
                Stop();
            }
            if (VirtualKey.GetKeyDown(VK.VK_MEDIA_PLAY_PAUSE) || KeyCodeUtils.GetKeyDown(Config.PlayPauseKey))
            {
                if (!stopped)
                {
                    Pause();
                }
                else
                {
                    stopped         = false;
                    paused          = false;
                    timeOfLastMusic = Time.time;
                    var filename = OST.Concat(CustomMusic).First(x => x.Value == musicSource.clip).Key;
                    musicSource.Play();
                }
            }
            if (VirtualKey.GetKeyDown(VK.VK_MEDIA_NEXT_TRACK) || KeyCodeUtils.GetKeyDown(Config.NextTrackKey))
            {
                NextTrack();
            }
            if (VirtualKey.GetKeyDown(VK.VK_MEDIA_PREV_TRACK) || KeyCodeUtils.GetKeyDown(Config.PreviousTrackKey))
            {
                if (CurrentTrackIndex > 0 && Time.time - timeOfLastMusic <= 1)
                {
                    PreviousTrack();
                }
                else
                {
                    Stop();
                    timeOfLastMusic = Time.time;
                    var filename = OST.Concat(CustomMusic).First(x => x.Value == musicSource.clip).Key;
                    musicSource.Play();
                }
            }
        }
        public static void MonitorLightBeamKeyDown(SeaMoth thisSeaMoth)
        {
            // Detect key press and set variable to toggle lights Lo / Hi beam
            if (KeyCodeUtils.GetKeyDown(Config.LightsLoHiKeybindValue))
            {
                ToggleLights thisToggleLights = thisSeaMoth.GetComponentInChildren <ToggleLights>();

                if (Vehicle_Update_Patch.HighBeamOn)
                {
                    Utils.PlayEnvSound(thisToggleLights.lightsOffSound, thisToggleLights.lightsOffSound.gameObject.transform.position, 20f);
                    Vehicle_Update_Patch.HighBeamOn = false;
                }
                else
                {
                    Utils.PlayEnvSound(thisToggleLights.lightsOnSound, thisToggleLights.lightsOnSound.gameObject.transform.position, 20f);
                    Vehicle_Update_Patch.HighBeamOn = true;
                }
            }
        }
示例#9
0
        internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
        {
            // Add item
            OptionGameObject = panel.AddItem(tabIndex, panel.bindingOptionPrefab);

            // Update text
            Text text = OptionGameObject.GetComponentInChildren <Text>();

            if (text != null)
            {
                OptionGameObject.GetComponentInChildren <TranslationLiveUpdate>().translationKey = Label;
                text.text = Language.main.Get(Label);
            }

            // Create bindings
            uGUI_Bindings bindings = OptionGameObject.GetComponentInChildren <uGUI_Bindings>();
            uGUI_Binding  binding  = bindings.bindings[0];

            // Destroy secondary bindings
            int last = bindings.bindings.Length - 1;

            UnityEngine.Object.Destroy(bindings.bindings[last].gameObject);
            UnityEngine.Object.Destroy(bindings);

            // Update bindings
            binding.device = Device;
            binding.value  = KeyCodeUtils.KeyCodeToString(Key);
#if SUBNAUTICA
            binding.onValueChanged.RemoveAllListeners();
            var callback = new UnityAction <KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));
            binding.onValueChanged.AddListener(new UnityAction <string>((string s) => callback?.Invoke(KeyCodeUtils.StringToKeyCode(s))));
#elif BELOWZERO
            binding.action     = ButtonPatcher.EnsureButton(Label, KeyCodeUtils.KeyCodeToString(Key), Device);
            binding.bindingSet = GameInput.BindingSet.Primary;
            var callback = new UnityAction <KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));
            binding.bindCallback = new Action <GameInput.Device, GameInput.Button, GameInput.BindingSet, string>((GameInput.Device device, GameInput.Button button, GameInput.BindingSet bindingSet, string s) => { callback?.Invoke(KeyCodeUtils.StringToKeyCode(s)); panel.TryBind1_0(device, button, bindingSet, s); binding.RefreshValue(); });
#endif

            base.AddToPanel(panel, tabIndex);
        }
        public static string FormatButton(Toggle toggle)
        {
            string displayText = null;

            if (toggle.KeyCode == KeyCode.None)
            {
                displayText = SMLHelper.Language.Get("NoInputAssigned");
            }
            else
            {
                string bindingName = KeyCodeUtils.KeyCodeToString(toggle.KeyCode);
                if (!string.IsNullOrEmpty(bindingName))
                {
                    displayText = uGUI.GetDisplayTextForBinding(bindingName);
                }
                if (string.IsNullOrEmpty(displayText))
                {
                    displayText = SMLHelper.Language.Get("NoInputAssigned");
                }
            }
            return($"<color=#ADF8FFFF>{displayText}</color>{(toggle.KeyMode == Toggle.Mode.Hold ? " (Hold)" : string.Empty)}");
        }
        public static void MonitorCruiseKeyDown()
        {
            // Detect key press and set variable to toggle Cruise Control on / off
            // Turn cruise off if forward or reverse buttonis pressed
            if (KeyCodeUtils.GetKeyDown(KeyCode.W) || KeyCodeUtils.GetKeyDown(KeyCode.S))
            {
                SeamothInfo.CruiseControlOn = false;
            }

            // Toggle cruise control
            if (KeyCodeUtils.GetKeyDown(Config.CruiseKeybindValue))
            {
                if (SeamothInfo.CruiseControlOn)
                {
                    SeamothInfo.CruiseControlOn = false;
                }
                else
                {
                    SeamothInfo.CruiseControlOn = true;
                }
            }
        }
示例#12
0
        private static void RegisterNewButton(string name, string key, Button button, Device device)
        {
            var bind = new Tuple <Device, Button, string>(device, button, key);

            if (RegisteredButtons.Contains(bind))
            {
                return;
            }

            RegisteredButtons.Add(bind);
            LanguageHandler.SetLanguageLine($"Option{name}", name);
            Language.main.LoadLanguageFile(Language.main.GetCurrentLanguage());
            GameInput.AddKeyInput(name, KeyCodeUtils.StringToKeyCode(key), device);
            GameInput.instance.Initialize();
            for (int i = 0; i < GameInput.numDevices; i++)
            {
                GameInput.SetupDefaultBindings((GameInput.Device)i);
            }
            foreach (Tuple <Device, Button, string> binding in RegisteredButtons)
            {
                GameInput.SafeSetBinding(binding.Item1, binding.Item2, BindingSet.Primary, binding.Item3);
            }
        }
        public static void MonitorHealthKeyDown()
        {
            // Detect key press and set variable to cycle through health display (mh, h, %)
            if (KeyCodeUtils.GetKeyDown(Config.HealthKeybindValue))
            {
                switch (Config.MarchThroughHealthValue)
                {
                case 1:
                    Config.MarchThroughHealthValue = 2f;
                    PlayerPrefs.SetFloat("MarchThroughHealthValueSlider", 2f);
                    break;

                case 2:
                    Config.MarchThroughHealthValue = 3f;
                    PlayerPrefs.SetFloat("MarchThroughHealthValueSlider", 3f);
                    break;

                default:
                    Config.MarchThroughHealthValue = 1f;
                    PlayerPrefs.SetFloat("MarchThroughHealthValueSlider", 1f);
                    break;
                }
            }
        }
示例#14
0
        public static void MonitorGearKeysDown()
        {
            // Detect key press and set variable (march up) to set Seamoth gear
            if (KeyCodeUtils.GetKeyDown(Config.GearUpKeybindValue))
            {
                var gearVal = Config.SeamothGearValue + 1f;
                if (SeamothInfo.ModeGreenOn)
                {
                    if (gearVal > 5f)
                    {
                        return;
                    }
                }
                if (!SeamothInfo.ModeGreenOn)
                {
                    if (gearVal > 6f)
                    {
                        return;
                    }
                }
                Config.SeamothGearValue = gearVal;
                PlayerPrefs.SetFloat("SeamothGearValueSlider", gearVal);
            } // end if (KeyCodeUtils.GetKeyDown(KeyCode.LeftShift))

            // Detect key press and set variable (march down) to set Seamoth gear
            if (KeyCodeUtils.GetKeyDown(Config.GearDownKeybindValue))
            {
                var gearVal = Config.SeamothGearValue - 1f;
                if (gearVal < 1f)
                {
                    return;
                }
                Config.SeamothGearValue = gearVal;
                PlayerPrefs.SetFloat("SeamothGearValueSlider", gearVal);
            } // end if (KeyCodeUtils.GetKeyDown(KeyCode.LeftControl))
        }
示例#15
0
        /// <summary>
        /// The method for writing the <paramref name="value"/> data to the <paramref name="writer"/>.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="value"></param>
        /// <param name="serializer"></param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var keyCode = (KeyCode)value;

            writer.WriteValue(KeyCodeUtils.KeyCodeToString(keyCode));
        }
示例#16
0
        internal static void DisplayVehicleInfoForPSTD(Exosuit thisExosuit)
        {
            GameObject gameObject  = GameObject.Find("HUD");
            GameObject gameObject2 = GameObject.Find("AirVentsDisplayUI");

            if (Player.main.currentMountedVehicle == thisExosuit)
            {
                if (gameObject2 == null)
                {
                    gameObject2 = new GameObject("AirVentsDisplayUI");
                }

                gameObject2.transform.SetParent(gameObject.transform, false);
                Text text = gameObject2.GetComponent <Text>();

                if (text == null)
                {
                    text = gameObject2.gameObject.AddComponent <Text>();
                }

                text.font      = Player.main.textStyle.font;
                text.fontSize  = Mathf.RoundToInt(Config.AirVentsFontSizeSliderValue);
                text.alignment = TextAnchor.LowerCenter;
                text.color     = Color.white;
                RectTransform component = text.GetComponent <RectTransform>();
                component.localPosition = AirVentHUDPosition;
                component.sizeDelta     = AirVentHUDSize;
                AirVentDisplayText      = text;
                gameObject = gameObject2;
                StringBuilder stringBuilder = new StringBuilder();

                // Air vents display
                if (Player.main.GetDepth() > DepthDetection)
                {
                    if (Config.AirVentsAutoToggleValue)
                    {
                        stringBuilder.Append(colorYellow);
                        stringBuilder.Append(AirVentHUDTextAutoClosed);
                        stringBuilder.Append(colorEnd);
                    }
                    //AirVentDisplayText.text = colorYellow + AirVentHUDTextAutoClosed + colorEnd;
                    else
                    //AirVentDisplayText.text = colorYellow + AirVentHUDTextClosed + colorEnd;
                    {
                        stringBuilder.Append(colorYellow);
                        stringBuilder.Append(AirVentHUDTextClosed);
                        stringBuilder.Append(colorEnd);
                    }
                }
                else
                {
                    if (Config.AirVentsAutoToggleValue)
                    {
                        // AirVentDisplayText.text = colorYellow + AirVentHUDTextAutoOpened + colorEnd;
                        stringBuilder.Append(colorYellow);
                        stringBuilder.Append(AirVentHUDTextAutoOpened);
                        stringBuilder.Append(colorEnd);
                    }
                    else
                    {
                        if (!AirVentsOn)
                        {
                            stringBuilder.Append(colorRed);
                            stringBuilder.Append(AirVentHUDTextPromptOpen);
                            stringBuilder.Append(colorEnd);
                            stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", Config.ToggleAirVentsKeybindValue.ToString());
                            //AirVentDisplayText.text = AirVentDisplayText.text + stringBuilder.ToString();
                        }
                        else
                        {
                            stringBuilder.Append(AirVentHUDTextPromptClose);
                            stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", Config.ToggleAirVentsKeybindValue.ToString());
                            //AirVentDisplayText.text = AirVentDisplayText.text + stringBuilder.ToString();
                        }
                    }
                }

                if (OtherModsInfo.Rm_VehicleLightsImprovedPresent)
                {
                    stringBuilder.Append('\n');
                    stringBuilder.Append("Exit ");
                    stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", KeyCodeUtils.KeyCodeToString(KeyCode.E));
                    stringBuilder.Append('\n');

                    stringBuilder.Append("Toggle lights ");
                    string displayMidMouseButton = uGUI.GetDisplayTextForBinding("MouseButtonMiddle");
                    stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", displayMidMouseButton);
                }

                // AirVentDisplayText.text = AirVentDisplayText.text + stringBuilder.ToString();
                AirVentDisplayText.text = stringBuilder.ToString();

                gameObject2.SetActive(true);
            }
            else
            {
                if (gameObject2 != null)
                {
                    gameObject2.SetActive(false);
                }
            }
        }
示例#17
0
 /// <summary>
 /// Adds a new <see cref="ModKeybindOption"/> to this instance.
 /// </summary>
 /// <param name="id">The internal ID for the toggle option.</param>
 /// <param name="label">The display text to use in the in-game menu.</param>
 /// <param name="device">The device name.</param>
 /// <param name="key">The starting keybind value.</param>
 protected void AddKeybindOption(string id, string label, GameInput.Device device, string key)
 {
     AddKeybindOption(id, label, device, KeyCodeUtils.StringToKeyCode(key));
 }
示例#18
0
 public KeybindChangedEventArgs(string id, KeyCode key)
 {
     Id      = id;
     Key     = key;
     KeyName = KeyCodeUtils.KeyCodeToString(key);
 }
示例#19
0
 private static void UpdateFields()
 {
     _didLookRight         = GameInput.GetButtonDown(GameInput.Button.LookRight) || KeyCodeUtils.GetKeyDown(Config.instance.KeybindKeyRight);
     _didLookLeft          = GameInput.GetButtonDown(GameInput.Button.LookLeft) || KeyCodeUtils.GetKeyDown(Config.instance.KeybindKeyLeft);
     _isLookingRight       = GameInput.GetButtonHeld(GameInput.Button.LookRight) || KeyCodeUtils.GetKeyHeld(Config.instance.KeybindKeyRight);
     _isLookingLeft        = GameInput.GetButtonHeld(GameInput.Button.LookLeft) || KeyCodeUtils.GetKeyHeld(Config.instance.KeybindKeyLeft);
     _isLookingLeftOrRight = _didLookLeft || _didLookRight || _isLookingLeft || _isLookingRight;
     _shouldSnapTurn       = XRSettings.enabled && _isLookingLeftOrRight;
     _isLookingUpOrDown    = GameInput.GetButtonDown(GameInput.Button.LookUp) ||
                             GameInput.GetButtonDown(GameInput.Button.LookDown) ||
                             GameInput.GetButtonHeld(GameInput.Button.LookUp) ||
                             GameInput.GetButtonHeld(GameInput.Button.LookDown);
 }
示例#20
0
            static void TooltipFactory_ItemActions_Postfix(StringBuilder sb, InventoryItem item)
            {
                if (item.item.GetTechType() != TechType.Beacon)
                {
                    return;
                }

                string btn = Main.config.renameBeaconsKey == default? Strings.Mouse.middleButton: KeyCodeUtils.KeyCodeToString(Main.config.renameBeaconsKey);

                TooltipFactory.WriteAction(sb, btn, L10n.str(L10n.ids_beaconRename));

                if (Main.config.renameBeaconsKey != default && Input.GetKeyDown(Main.config.renameBeaconsKey))
                {
                    renameBeacon(item.item.GetComponent <Beacon>());
                }
            }
示例#21
0
        public static bool Prefix()
        {
            var isIgnoringSeamoth = IsInSeamoth && !Config.EnableSeamoth;
            var isIgnoringPrawn   = IsInPrawnSuit && !Config.EnablePrawn;

            if (!Config.EnableSnapTurning || isIgnoringSeamoth || isIgnoringPrawn)
            {
                return(true); //Enter vanilla method
            }

            var didLookRight   = GameInput.GetButtonDown(GameInput.Button.LookRight) || KeyCodeUtils.GetKeyDown(Config.KeybindKeyRight);
            var didLookLeft    = GameInput.GetButtonDown(GameInput.Button.LookLeft) || KeyCodeUtils.GetKeyDown(Config.KeybindKeyLeft);
            var isLookingLeft  = GameInput.GetButtonHeld(GameInput.Button.LookLeft);
            var isLookingRight = GameInput.GetButtonHeld(GameInput.Button.LookRight);
            var isLooking      = didLookLeft || didLookRight || isLookingLeft || isLookingRight;

            var shouldSnapTurn = XRSettings.enabled && isLooking;

            if (shouldSnapTurn)
            {
                UpdatePlayerOrVehicleRotation(didLookRight, didLookLeft);
                return(false); //Don't enter vanilla method if we snap turn
            }

            return(true);
        }
示例#22
0
    private void Update()
    {
        if (partition != null)
        {
            if (pads != null)
            {
                pads.Update();
                for (int i = 0; i < 4; i++)
                {
                    if (pads.GetKeyDown(i))
                    {
                        //Send TrackKey input
                        partition.PlayerInputted(i);
                    }
                }
            }
            else
            {
                if (ControllerId >= 0)
                {
                    for (int i = 0; i < trackKey.Length; i++)
                    {
                        if (Input.GetKeyDown(trackKey[i]) && partition != null)
                        {
                            //Send TrackKey input
                            partition.PlayerInputted(i);
                        }
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.A))
                    {
                        partition.PlayerInputted(0);
                    }
                    if (Input.GetKeyDown(KeyCode.Z))
                    {
                        partition.PlayerInputted(1);
                    }
                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        partition.PlayerInputted(2);
                    }
                    if (Input.GetKeyDown(KeyCode.R))
                    {
                        partition.PlayerInputted(3);
                    }
                }
            }


            if (partition != null && Personnage.AvailableRole.Length > 1)
            {
                if (pads != null)
                {
                    if (pads.GetKeyDown(4))
                    {
                        if (!BossManager.Instance.goHurlement)
                        {
                            SwitchRole();
                        }
                        else
                        {
                            SoundMgr.Instance.PlaySound("Snd_Cant_Switch");
                        }
                    }
                }
                else if (ControllerId >= 0)
                {
                    if (Input.GetKeyDown(KeyCodeUtils.GetKeyCode("Joystick" + ControllerId + "Button5")))
                    {
                        if (!BossManager.Instance.goHurlement)
                        {
                            SwitchRole();
                        }
                        else
                        {
                            SoundMgr.Instance.PlaySound("Snd_Cant_Switch");
                        }
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        if (!BossManager.Instance.goHurlement)
                        {
                            SwitchRole();
                        }
                        else
                        {
                            SoundMgr.Instance.PlaySound("Snd_Cant_Switch");
                        }
                    }
                }
            }
        }
    }
示例#23
0
        [HarmonyPostfix]      // Harmony postfix
        public static void Postfix(Vehicle __instance)
        {
            if (Player.main.currentMountedVehicle != null)
            {
                if (Player.main.currentMountedVehicle == __instance && Config.UseEnergyToggleValue && !AirVentInfo.AirVentsOn)
                {
                    var efficiencyLoaded = __instance.modules.GetCount(TechType.VehiclePowerUpgradeModule);
                    //float energyCost = 0.1f; // vanilla 0.1f per sec
                    float energyCost = Player.main.currentMountedVehicle.oxygenEnergyCost;

                    if (Config.UseEasyEnergyToggleValue)
                    {
                        switch (efficiencyLoaded)
                        {
                        case 0:
                            energyCost *= 0.4f;
                            break;

                        case 1:
                            energyCost *= 0.25f;
                            break;

                        default:
                            energyCost *= 0.1f;
                            break;
                        }
                    }
                    else
                    {
                        switch (efficiencyLoaded)
                        {
                        case 0:
                            energyCost *= 0.5f;
                            break;

                        case 1:
                            energyCost *= 0.4f;
                            break;

                        case 2:
                            energyCost *= 0.3f;
                            break;

                        case 3:
                            energyCost *= 0.2f;
                            break;

                        default:
                            energyCost *= 0.1f;
                            break;
                        }
                    }

                    // Consume energy for continuously replenishing oxygen
                    OxygenManager oxygenMgr = Player.main.oxygenMgr;
                    oxygenMgr.GetTotal(out float oxygenAvailable, out float oxygenCapacity);

                    if (!OtherModsInfo.RefillableOxygenTankPresent)
                    {
                        if (oxygenAvailable == oxygenCapacity)
                        {
                            ConsumeOxygenEnergy(__instance, energyCost);
                        }
                    }
                    else
                    {
                        //if (!Player.main.oxygenMgr.HasOxygenTank())
                        if (Player.main.currentMountedVehicle.modules.GetCount(VehicleOxygenUpgradeModule.TechTypeID) > 0)
                        {
                            ConsumeOxygenEnergy(__instance, energyCost);
                        }
                    }
                } // end if (main.currentMountedVehicle != null && Config.UseEnergyToggleValue)

                if (KeyCodeUtils.GetKeyDown(Config.ToggleAirVentsKeybindValue))
                {
                    //if (Mathf.RoundToInt(Player.main.GetDepth()) < Objects.AirVentInfo.DepthDetection)
                    if (Player.main.GetDepth() < AirVentInfo.DepthDetection)
                    {
                        if (AirVentInfo.AirVentsOn == false)
                        {
                            AirVentInfo.AirVentsOn = true;
                        }
                        else
                        {
                            AirVentInfo.AirVentsOn = false;
                        }
                    }
                }

                // (Mathf.RoundToInt(Player.main.GetDepth()) > Objects.AirVentInfo.DepthDetection)
                if (Player.main.GetDepth() > AirVentInfo.DepthDetection)
                {
                    if (AirVentInfo.AirVentsOn == true)
                    {
                        AirVentInfo.AirVentsOn = false;
                    }
                }
                else
                {
                    if (Config.AirVentsAutoToggleValue)
                    {
                        if (AirVentInfo.AirVentsOn == false)
                        {
                            AirVentInfo.AirVentsOn = true;
                        }
                    }
                }
            } // end if (Player.main.currentMountedVehicle != null)
        }     // end public static void Postfix(Vehicle __instance)