Exemplo n.º 1
0
        static void Postfix(Player __instance)
        {
            bool keyReplantDown = CRConfig.useCustomReplantKey
                ? Input.GetKeyDown(CRConfig.customReplantKey)
                : (ZInput.GetButtonDown("Remove") || ZInput.GetButtonDown("JoyRemove"));

            if (keyReplantDown)
            {
                if (__instance.CultivatorEquipped())
                {
                    GameObject[] parameters = new GameObject[] { null, null };
                    PlayerExt.FindHoverObject.Invoke(__instance, parameters);
                    var maybePickable = parameters[0]?.GetComponent <Pickable>();
                    if (maybePickable != null)
                    {
                        if (maybePickable.Replantable())
                        {
                            maybePickable.Replant(__instance);
                            if (CRConfig.multipick)
                            {
                                foreach (var crop in maybePickable.FindPickableOfKindInRadius(CRConfig.range))
                                {
                                    crop.Replant(__instance);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
    // Token: 0x060004F2 RID: 1266 RVA: 0x00028E98 File Offset: 0x00027098
    private void Update()
    {
        Player localPlayer = Player.m_localPlayer;

        if (localPlayer && !InventoryGui.IsVisible() && !Menu.IsVisible() && !GameCamera.InFreeFly())
        {
            if (ZInput.GetButtonDown("JoyDPadLeft"))
            {
                this.m_selected = Mathf.Max(0, this.m_selected - 1);
            }
            if (ZInput.GetButtonDown("JoyDPadRight"))
            {
                this.m_selected = Mathf.Min(this.m_elements.Count - 1, this.m_selected + 1);
            }
            if (ZInput.GetButtonDown("JoyDPadUp"))
            {
                localPlayer.UseHotbarItem(this.m_selected + 1);
            }
        }
        if (this.m_selected > this.m_elements.Count - 1)
        {
            this.m_selected = Mathf.Max(0, this.m_elements.Count - 1);
        }
        this.UpdateIcons(localPlayer);
    }
Exemplo n.º 3
0
 static bool Prefix(Player __instance, bool takeInput, float dt, PieceTable ___m_buildPieces, GameObject ___m_placementGhost)
 {
     if (!AllowByKey() || !CheckKeyHeld(pullItemsKey.Value) || !__instance.InPlaceMode() || !takeInput || Hud.IsPieceSelectionVisible())
     {
         return(true);
     }
     if (ZInput.GetButtonDown("Attack") || ZInput.GetButtonDown("JoyPlace"))
     {
         Piece selectedPiece = ___m_buildPieces.GetSelectedPiece();
         if (selectedPiece != null)
         {
             if (selectedPiece.m_repairPiece)
             {
                 return(true);
             }
             if (___m_placementGhost != null)
             {
                 int placementStatus = (int)typeof(Player).GetField("m_placementStatus", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
                 if (placementStatus == 0)
                 {
                     Dbgl($"pulling resources to player inventory for piece {selectedPiece.name}");
                     PullResources(__instance, selectedPiece.m_resources, 0);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        static void Postfix(Player __instance)
        {
            bool keyReplantDown = (CRConfig.useCustomReplantKey || CRConfig.oldStyle)
                ? ZInput.GetButtonDown(CRConfig.replantButton.Name)
                : (ZInput.GetButtonDown("Remove") || ZInput.GetButtonDown("JoyRemove"));

            if (keyReplantDown)
            {
                if (__instance.CultivatorEquipped())
                {
                    __instance.FindHoverObject(out GameObject hover, out Character _);
                    var maybePickable = hover?.GetComponent <Pickable>();
                    if (maybePickable != null)
                    {
                        if (maybePickable.Replantable())
                        {
                            maybePickable.Replant(__instance);
                            if (CRConfig.multipick)
                            {
                                foreach (var crop in maybePickable.FindPickableOfKindInRadius(CRConfig.range))
                                {
                                    crop.Replant(__instance);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        // Called every frame
        private void Update()
        {
            // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads,
            // we need to check that ZInput is ready to use first.
            if (ZInput.instance != null)
            {
                // Check if our button is pressed. This will only return true ONCE, right after our button is pressed.
                // If we hold the button down, it won't spam toggle our menu.
                if (ZInput.GetButtonDown("JotunnModExample_Menu"))
                {
                    showGUI = !showGUI;
                }
            }

            // Use the name of the ButtonConfig to identify the button pressed
            if (evilSwordSpecial != null && ZInput.instance != null && MessageHud.instance != null)
            {
                if (ZInput.GetButtonDown(evilSwordSpecial.Name) && MessageHud.instance.m_msgQeue.Count == 0)
                {
                    MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "$evilsword_beevilmessage");
                }
                if (Input.GetKeyDown(KeyCode.F7))
                {
                    Player.m_localPlayer?.RaiseSkill(testSkillType, 1f);
                }
            }
        }
Exemplo n.º 6
0
 void Update()
 {
     if (m_keyInit && ZInput.GetButtonDown("TogglePins"))
     {
         m_pinsVisible = !m_pinsVisible;
     }
 }
Exemplo n.º 7
0
 private static void UpdateInitialHotkeyBarInput()
 {
     if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyDPadRight"))
     {
         SelectHotkeyBar(0, false);
     }
 }
Exemplo n.º 8
0
        private static void DontShowMinimap_Patch(On.Minimap.orig_SetMapMode orig, Minimap self, int mode)
        {
            if (ConfigUtil.Get <bool>("Map", "showNoMinimap"))
            {
                if ((Chat.instance == null || !Chat.instance.HasFocus()) && !global::Console.IsVisible() && !InventoryGui.IsVisible() && !Minimap.InTextInput())
                {
                    if (ZInput.GetButtonDown("Map") || ZInput.GetButtonDown("JoyMap") || (self.m_mode == Minimap.MapMode.Large &&
                                                                                          (Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyButtonB"))))
                    {
                        if (mode == (int)Minimap.MapMode.Large)
                        {
                            return;
                        }

                        if ((mode == (int)Minimap.MapMode.Small) && (self.m_mode == Minimap.MapMode.Large))
                        {
                            mode = (int)Minimap.MapMode.None;
                        }
                    }
                    else
                    {
                        if ((mode == (int)Minimap.MapMode.Small) && (self.m_mode == Minimap.MapMode.None))
                        {
                            mode = (int)Minimap.MapMode.None;
                        }
                    }
                }
            }

            orig(self, mode);
        }
Exemplo n.º 9
0
 public void Update()
 {
     if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonB") || (ZInput.GetButtonDown("JoyButtonY") || Input.GetKeyDown(KeyCode.Escape)) || ZInput.GetButtonDown("Use"))
     {
         Close();
     }
 }
Exemplo n.º 10
0
            public static bool Prefix(InventoryGui __instance)
            {
                if (!__instance.m_inventoryGroup.IsActive())
                {
                    return(false);
                }
                if (ZInput.GetButtonDown("JoyTabLeft"))
                {
                    __instance.SetActiveGroup(__instance.m_activeGroup - 1);
                }
                if (ZInput.GetButtonDown("JoyTabRight"))
                {
                    __instance.SetActiveGroup(__instance.m_activeGroup + 1);
                }
                if (__instance.m_activeGroup == 0 && !__instance.IsContainerOpen())
                {
                    __instance.SetActiveGroup(1);
                }
                if (__instance.m_activeGroup == __instance.m_uiGroups.Length - 1)
                {
                    __instance.UpdateRecipeGamepadInput();
                }

                return(false);
            }
Exemplo n.º 11
0
 private void Update()
 {
     // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads,
     // we need to check that ZInput is ready to use first.
     if (ZInput.instance != null)
     {
         // Check if our button is pressed. This will only return true ONCE, right after our button is pressed.
         if (ZInput.GetButtonDown("EscapeChallenge"))
         {
             if (Player.m_localPlayer && Player.m_localPlayer.m_intro)
             {
                 Player.m_localPlayer.m_intro = false;
                 var hitData = new HitData();
                 hitData.m_damage.m_damage = 99999f;
                 Player.m_localPlayer.Damage(hitData);
                 var client  = WebSocketObject.GetComponent <WebSocketClient>();
                 var message = new Message
                 {
                     type = "forceQuit"
                 };
                 client.Send(JsonMapper.ToJson(message));
             }
         }
     }
 }
Exemplo n.º 12
0
 // Token: 0x060004EC RID: 1260 RVA: 0x00028D99 File Offset: 0x00026F99
 private void LateUpdate()
 {
     this.m_sendButton.interactable = this.IsValid();
     if (Feedback.IsVisible() && (Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")))
     {
         this.OnBack();
     }
 }
 public void Update()
 {
     //EpicLoot.Log("AugmentsAvailableDialog.Update");
     if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonB") || (ZInput.GetButtonDown("JoyButtonY") || Input.GetKeyDown(KeyCode.Escape)) || ZInput.GetButtonDown("Use"))
     {
         OnClose();
     }
 }
Exemplo n.º 14
0
 public void Update()
 {
     // Not all of these inputs work and I do not know why, only Escape works
     if (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonB") || (ZInput.GetButtonDown("JoyButtonY") || Input.GetKeyDown(KeyCode.Escape)) || ZInput.GetButtonDown("Use"))
     {
         EffectChoiceButtons[0].onClick.Invoke();
     }
 }
Exemplo n.º 15
0
        private void PlayerUpdatePostfix(Player self)
        {
            if (!_isModEnabled.Value ||
                self != Player.m_localPlayer ||
                !self.m_hovering ||
                !ZInput.GetButtonDown(_deleteObjectButton.Name))
            {
                return;
            }

            DeleteHoverObject(self);
        }
Exemplo n.º 16
0
 // Called every second
 private void Update()
 {
     // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads,
     // we need to check that ZInput is ready to use first.
     if (ZInput.instance != null)
     {
         // Check if our button is pressed. This will only return true ONCE, right after our button is pressed.
         // If we hold the button down, it won't spam toggle our menu.
         if (ZInput.GetButtonDown("TestMod_Menu"))
         {
             showMenu = !showMenu;
         }
     }
 }
Exemplo n.º 17
0
 // Token: 0x06000656 RID: 1622 RVA: 0x00035A60 File Offset: 0x00033C60
 private void UpdateGamepadInput()
 {
     if (this.m_texts.Count > 0)
     {
         if (ZInput.GetButtonDown("JoyLStickDown"))
         {
             this.ShowText(Mathf.Min(this.m_texts.Count - 1, this.GetSelectedText() + 1));
         }
         if (ZInput.GetButtonDown("JoyLStickUp"))
         {
             this.ShowText(Mathf.Max(0, this.GetSelectedText() - 1));
         }
     }
 }
Exemplo n.º 18
0
 public static bool Update(ref Menu __instance)
 {
     if (Game.instance.IsShuttingDown())
     {
         __instance.m_root.gameObject.SetActive(false);
         return(false);
     }
     if (__instance.m_root.gameObject.activeSelf)
     {
         AccessTools.Field(typeof(Menu), "m_hiddenFrames").SetValue(__instance, 0);
         if ((Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")) && !(GameObject)AccessTools.Field(typeof(Menu), "m_settingsInstance").GetValue(__instance) && !Feedback.IsVisible())
         {
             if (__instance.m_quitDialog.gameObject.activeSelf)
             {
                 __instance.OnQuitNo();
                 return(false);
             }
             if (__instance.m_logoutDialog.gameObject.activeSelf)
             {
                 __instance.OnLogoutNo();
                 return(false);
             }
             StartTime();
             __instance.m_root.gameObject.SetActive(false);
             return(false);
         }
     }
     else
     {
         int m_hiddenFrames = (int)AccessTools.Field(typeof(Menu), "m_hiddenFrames").GetValue(__instance);
         m_hiddenFrames++;
         AccessTools.Field(typeof(Menu), "m_hiddenFrames").SetValue(__instance, m_hiddenFrames);
         bool flag = !InventoryGui.IsVisible() && !Minimap.IsOpen() && !global::Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible();
         if (((Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")) || (!Application.isFocused && focusPause.Value && ZNet.instance.IsServer())) && flag)
         {
             __instance.m_root.gameObject.SetActive(true);
             __instance.m_menuDialog.gameObject.SetActive(true);
             if (ZNet.instance.IsServer())
             {
                 StopTime();
                 __instance.m_root.Find("OLD_menu").gameObject.SetActive(true);
                 __instance.m_root.Find("Menu").gameObject.SetActive(false);
             }
             Gogan.LogEvent("Screen", "Enter", "Menu", 0L);
             __instance.m_logoutDialog.gameObject.SetActive(false);
             __instance.m_quitDialog.gameObject.SetActive(false);
         }
     }
     return(false);
 }
Exemplo n.º 19
0
 // Token: 0x06000639 RID: 1593 RVA: 0x0003528C File Offset: 0x0003348C
 private void UpdateRecipeGamepadInput()
 {
     if (this.m_itemList.Count > 0)
     {
         if (ZInput.GetButtonDown("JoyLStickDown"))
         {
             this.SelectItem(Mathf.Min(this.m_itemList.Count - 1, this.GetSelectedItemIndex() + 1), true);
         }
         if (ZInput.GetButtonDown("JoyLStickUp"))
         {
             this.SelectItem(Mathf.Max(0, this.GetSelectedItemIndex() - 1), true);
         }
     }
 }
Exemplo n.º 20
0
            public static void UpdateHotkeyBarInput(HotkeyBar hotkeyBar)
            {
                var player = Player.m_localPlayer;

                if (hotkeyBar.m_selected >= 0 && player != null && !InventoryGui.IsVisible() && !Menu.IsVisible() && !GameCamera.InFreeFly())
                {
                    if (ZInput.GetButtonDown("JoyDPadLeft"))
                    {
                        if (hotkeyBar.m_selected == 0)
                        {
                            GotoHotkeyBar(SelectedHotkeyBarIndex - 1);
                        }
                        else
                        {
                            hotkeyBar.m_selected = Mathf.Max(0, hotkeyBar.m_selected - 1);
                        }
                    }
                    else if (ZInput.GetButtonDown("JoyDPadRight"))
                    {
                        if (hotkeyBar.m_selected == hotkeyBar.m_elements.Count - 1)
                        {
                            GotoHotkeyBar(SelectedHotkeyBarIndex + 1);
                        }
                        else
                        {
                            hotkeyBar.m_selected = Mathf.Min(hotkeyBar.m_elements.Count - 1, hotkeyBar.m_selected + 1);
                        }
                    }

                    if (ZInput.GetButtonDown("JoyDPadUp"))
                    {
                        if (hotkeyBar.name == "QuickSlotsHotkeyBar")
                        {
                            var quickSlotInventory = player.GetQuickSlotInventory();
                            var item = quickSlotInventory.GetItemAt(hotkeyBar.m_selected, 0);
                            player.UseItem(null, item, false);
                        }
                        else
                        {
                            player.UseHotbarItem(hotkeyBar.m_selected + 1);
                        }
                    }
                }

                if (hotkeyBar.m_selected > hotkeyBar.m_elements.Count - 1)
                {
                    hotkeyBar.m_selected = Mathf.Max(0, hotkeyBar.m_elements.Count - 1);
                }
            }
Exemplo n.º 21
0
 static void Prefix(Minimap __instance)
 {
     if (isTPmode)
     {
         if (ZInput.GetButtonDown("Map") || ZInput.GetButtonDown("JoyMap") || Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyButtonB"))
         {
             LeaveTPMode();
             SetMapMode(1);
         }
         else if (ZInput.GetButtonDown("JoyButtonA"))
         {
             DoTP();
         }
     }
 }
Exemplo n.º 22
0
        public static bool Prefix(Player __instance)
        {
            var player = __instance;

            isAltHold = Input.GetKey(KeyCode.LeftAlt);

            if (ZInput.GetButtonDown("Use") && isAltHold)
            {
                Log.LogInfo("Alternative Use");
                var hoverObject = player.GetHoverObject();
                if (hoverObject != null)
                {
                    return(AlternativeInteract(player, hoverObject, false));
                }
            }

            return(true); // if we got here then original method should be called
        }
Exemplo n.º 23
0
 // Token: 0x0600064B RID: 1611 RVA: 0x00035540 File Offset: 0x00033740
 private void LateUpdate()
 {
     if (!this.IsVisible())
     {
         return;
     }
     this.m_showTime += Time.deltaTime;
     if (this.m_showTime > 0.2f)
     {
         if (this.m_autoHide && Player.m_localPlayer && Vector3.Distance(Player.m_localPlayer.transform.position, this.m_openPlayerPos) > 3f)
         {
             this.Hide();
         }
         if (ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("JoyUse") || Input.GetKeyDown(KeyCode.Escape))
         {
             this.Hide();
         }
     }
 }
Exemplo n.º 24
0
 // Token: 0x0600052B RID: 1323 RVA: 0x0002B598 File Offset: 0x00029798
 private void UpdateGamepad()
 {
     if (!this.m_uiGroup.IsActive())
     {
         return;
     }
     if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyLStickLeft"))
     {
         this.m_selected.x = Mathf.Max(0, this.m_selected.x - 1);
     }
     if (ZInput.GetButtonDown("JoyDPadRight") || ZInput.GetButtonDown("JoyLStickRight"))
     {
         this.m_selected.x = Mathf.Min(this.m_width - 1, this.m_selected.x + 1);
     }
     if (ZInput.GetButtonDown("JoyDPadUp") || ZInput.GetButtonDown("JoyLStickUp"))
     {
         this.m_selected.y = Mathf.Max(0, this.m_selected.y - 1);
     }
     if (ZInput.GetButtonDown("JoyDPadDown") || ZInput.GetButtonDown("JoyLStickDown"))
     {
         this.m_selected.y = Mathf.Min(this.m_width - 1, this.m_selected.y + 1);
     }
     if (ZInput.GetButtonDown("JoyButtonA"))
     {
         InventoryGrid.Modifier arg = InventoryGrid.Modifier.Select;
         if (ZInput.GetButton("JoyLTrigger"))
         {
             arg = InventoryGrid.Modifier.Split;
         }
         if (ZInput.GetButton("JoyRTrigger"))
         {
             arg = InventoryGrid.Modifier.Move;
         }
         ItemDrop.ItemData gamepadSelectedItem = this.GetGamepadSelectedItem();
         this.m_onSelected(this, gamepadSelectedItem, this.m_selected, arg);
     }
     if (ZInput.GetButtonDown("JoyButtonX"))
     {
         ItemDrop.ItemData gamepadSelectedItem2 = this.GetGamepadSelectedItem();
         this.m_onRightClick(this, gamepadSelectedItem2, this.m_selected);
     }
 }
Exemplo n.º 25
0
        public void Update()
        {
            // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads,
            // we need to check that ZInput is ready to use first.
            if (ZInput.instance == null)
            {
                return;
            }

            if (!CheckInput())
            {
                return;
            }

            if (ZInput.GetButtonDown(hideButton))
            {
                hotkeyToggle = !hotkeyToggle;
                logger.LogInfo("Toggle TransparentSails is " + (hotkeyToggle ? "on" : "off"));
            }
        }
Exemplo n.º 26
0
 // Token: 0x06000582 RID: 1410 RVA: 0x0002F520 File Offset: 0x0002D720
 private void Update()
 {
     if (Game.instance.IsShuttingDown())
     {
         this.m_root.gameObject.SetActive(false);
         return;
     }
     if (this.m_root.gameObject.activeSelf)
     {
         this.m_hiddenFrames = 0;
         if ((Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")) && !this.m_settingsInstance && !Feedback.IsVisible())
         {
             if (this.m_quitDialog.gameObject.activeSelf)
             {
                 this.OnQuitNo();
                 return;
             }
             if (this.m_logoutDialog.gameObject.activeSelf)
             {
                 this.OnLogoutNo();
                 return;
             }
             this.m_root.gameObject.SetActive(false);
             return;
         }
     }
     else
     {
         this.m_hiddenFrames++;
         bool flag = !InventoryGui.IsVisible() && !Minimap.IsOpen() && !global::Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible();
         if ((Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("JoyMenu")) && flag)
         {
             Gogan.LogEvent("Screen", "Enter", "Menu", 0L);
             this.m_root.gameObject.SetActive(true);
             this.m_menuDialog.gameObject.SetActive(true);
             this.m_logoutDialog.gameObject.SetActive(false);
             this.m_quitDialog.gameObject.SetActive(false);
         }
     }
 }
Exemplo n.º 27
0
        public void Update()
        {
            Player player = Player.m_localPlayer;

            if (ZInput.instance == null ||
                player == null)
            {
                return;
            }

            if (!CheckInput())
            {
                return;
            }

            // Check if our button is pressed. This will only return true ONCE, right after our button is pressed.
            // If we hold the button down, it won't spam toggle our menu.
            if (ZInput.GetButtonDown(PlanBuildButton))
            {
                TogglePlanBuildMode();
            }
        }
Exemplo n.º 28
0
            public static void Postfix(InventoryGui __instance)
            {
                var gamepadActive = ZInput.IsGamepadActive();
                var activeIndex   = 0;

                for (int i = 0; i < TabControllers.Count; i++)
                {
                    var tabController = TabControllers[i];
                    if (tabController.GamepadHint == null)
                    {
                        continue;
                    }

                    tabController.GamepadHint.SetActive(gamepadActive && (i == 0 || i == TabControllers.Count - 1));
                    if (tabController.IsActive())
                    {
                        activeIndex = i;
                    }
                }

                if (ZInput.GetButtonDown("JoyLStickLeft"))
                {
                    activeIndex--;
                    if (activeIndex < 0)
                    {
                        activeIndex = TabControllers.Count - 1;
                    }
                    OnTabPressed(TabControllers[activeIndex]);
                }
                else if (ZInput.GetButtonDown("JoyLStickRight"))
                {
                    activeIndex++;
                    if (activeIndex >= TabControllers.Count)
                    {
                        activeIndex = 0;
                    }
                    OnTabPressed(TabControllers[activeIndex]);
                }
            }
Exemplo n.º 29
0
        // Called every frame
        private void Update()
        {
            // Since our Update function in our BepInEx mod class will load BEFORE Valheim loads,
            // we need to check that ZInput is ready to use first.
            if (ZInput.instance != null)
            {
                // Check if custom buttons are pressed.
                // Custom buttons need to be added to the InputManager before we can poll them.
                // GetButtonDown will only return true ONCE, right after our button is pressed.
                // If we hold the button down, it won't spam toggle our menu.
                if (ZInput.GetButtonDown("TestMod_Menu"))
                {
                    showMenu = !showMenu;
                }

                if (ZInput.GetButtonDown("TestMod_GUIManagerTest"))
                {
                    showButton = !showButton;
                }

                // Raise the test skill
                if (Player.m_localPlayer != null && ZInput.GetButtonDown("TestMod_RaiseSkill"))
                {
                    Player.m_localPlayer.RaiseSkill(testSkill, 1f);
                }

                // Use the name of the ButtonConfig to identify the button pressed
                if (evilSwordSpecial != null && MessageHud.instance != null)
                {
                    if (ZInput.GetButtonDown(evilSwordSpecial.Name) && MessageHud.instance.m_msgQeue.Count == 0)
                    {
                        MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "$evilsword_beevilmessage");
                    }
                }
            }
        }
Exemplo n.º 30
0
        private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref Vector3 ___m_lookDir, ref GameObject ___m_placementGhost, Transform ___m_eye)
        {
            if ((Configuration.Current.Player.IsEnabled && Configuration.Current.Player.queueWeaponChanges) && (ZInput.GetButtonDown("Hide") || ZInput.GetButtonDown("JoyHide")))
            {
                if (__instance.InAttack() && (__instance.GetRightItem() != null || __instance.GetLeftItem() != null))
                {
                    // The game ignores this keypress, so queue it and take care of it when able (Player_FixedUpdate_Patch).
                    EquipPatchState.shouldHideItemsAfterAttack = true;
                }
            }

            if (!__instance.m_nview.IsValid() || !__instance.m_nview.IsOwner())
            {
                return;
            }

            if (Configuration.Current.AdvancedEditingMode.IsEnabled)
            {
                AEM.PlayerInstance = __instance;
                AEM.run();
            }

            if (Configuration.Current.AdvancedBuildingMode.IsEnabled)
            {
                ABM.Run(ref __instance);
            }

            if (Configuration.Current.Hotkeys.IsEnabled)
            {
                ApplyDodgeHotkeys(ref __instance, ref ___m_moveDir, ref ___m_lookDir);
            }


            if (Configuration.Current.GameClock.IsEnabled)
            {
                String hours_str   = "";
                String minutes_str = "";
                String amPM_str    = "";

                Hud hud = Hud.instance;

                Text timeText;
                if (timeObj == null)
                {
                    MessageHud msgHud = MessageHud.instance;

                    timeObj = new GameObject();
                    timeObj.transform.SetParent(hud.m_statusEffectListRoot.transform.parent);
                    timeObj.AddComponent <RectTransform>();

                    timeText = timeObj.AddComponent <Text>();

                    float rRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textRedChannel / 255f);
                    float gRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textGreenChannel / 255f);
                    float bRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textBlueChannel / 255f);
                    float aRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textTransparencyChannel / 255f);

                    timeText.color              = new Color(rRatio, gRatio, bRatio, aRatio);
                    timeText.font               = msgHud.m_messageCenterText.font;
                    timeText.fontSize           = Configuration.Current.GameClock.textFontSize;
                    timeText.enabled            = true;
                    timeText.alignment          = TextAnchor.MiddleCenter;
                    timeText.horizontalOverflow = HorizontalWrapMode.Overflow;
                }
                else
                {
                    timeText = timeObj.GetComponent <Text>();
                }

                EnvMan env = EnvMan.instance;
                if (savedEnvSeconds != env.m_totalSeconds)
                {
                    float minuteFrac = Mathf.Lerp(0, 24, env.GetDayFraction());
                    float hr24       = Mathf.Floor(minuteFrac);
                    minuteFrac = minuteFrac - hr24;
                    float minutes = Mathf.Lerp(0, 60, minuteFrac);

                    int hours_int   = Mathf.FloorToInt(hr24);
                    int minutes_int = Mathf.FloorToInt(minutes);

                    if (Configuration.Current.GameClock.useAMPM)
                    {
                        amPM_str = (hours_int < 12) ? " AM" : " PM";
                        if (hours_int > 12)
                        {
                            hours_int -= 12;
                        }
                    }

                    if (hours_int < 10)
                    {
                        hours_str = "0" + hours_int;
                    }
                    if (minutes_int < 10)
                    {
                        minutes_str = "0" + minutes_int;
                    }
                    if (hours_int >= 10)
                    {
                        hours_str = hours_int.ToString();
                    }
                    if (minutes_int >= 10)
                    {
                        minutes_str = minutes_int.ToString();
                    }

                    timeText.text = hours_str + ":" + minutes_str + amPM_str;
                    var staminaBarRec      = hud.m_staminaBar2Root.transform as RectTransform;
                    var statusEffictBarRec = hud.m_statusEffectListRoot.transform as RectTransform;
                    timeObj.GetComponent <RectTransform>().position = new Vector2(staminaBarRec.position.x, statusEffictBarRec.position.y);
                    timeObj.SetActive(true);
                    savedEnvSeconds = env.m_totalSeconds;
                }
            }
        }