Esempio n. 1
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);
    }
Esempio n. 2
0
 private bool CheckInput()
 {
     return((!Chat.instance || !Chat.instance.HasFocus()) &&
            !Console.IsVisible() &&
            !InventoryGui.IsVisible() &&
            !StoreGui.IsVisible() &&
            !Menu.IsVisible() &&
            !Minimap.IsOpen() &&
            !Player.m_localPlayer.InCutscene());
 }
Esempio n. 3
0
 // Some logic from GameCamera class
 private bool canAdjustCameraDistance()
 {
     return((!Chat.instance || !Chat.instance.HasFocus()) &&
            !Console.IsVisible() &&
            !InventoryGui.IsVisible() &&
            !StoreGui.IsVisible() &&
            !Menu.IsVisible() &&
            !Minimap.IsOpen() &&
            attachedToPlayer &&
            !getPlayerCharacter().InCutscene() ? !getPlayerCharacter().InPlaceMode() : false);
 }
Esempio n. 4
0
            static void Prefix(Player __instance, float ___m_lastToolUseTime, ref float ___m_placePressedTime)
            {
                __instance.m_placeDelay = placeDelay;

                if (!modEnabled.Value)
                {
                    return;
                }

                string rightItem = __instance.GetRightItem()?.m_shared.m_name;

                if (rightItem == "$item_hammer")
                {
                    if (!repeatBuildPlace.Value)
                    {
                        return;
                    }
                    __instance.m_placeDelay = repeatBuildPlaceDelay.Value;
                }
                else if (rightItem == "$item_hoe")
                {
                    if (!repeatTerrainMod.Value)
                    {
                        return;
                    }
                    __instance.m_placeDelay = repeatTerrainModDelay.Value;
                }
                else if (rightItem == "$item_cultivator")
                {
                    if (!repeatPlanting.Value)
                    {
                        return;
                    }
                    __instance.m_placeDelay = repeatPlantingDelay.Value;
                }

                if (!wasSelecting && (ZInput.GetButton("Attack") || ZInput.GetButton("JoyPlace")) && Time.time - ___m_lastToolUseTime > __instance.m_placeDelay)
                {
                    if (InventoryGui.IsVisible() || Minimap.IsOpen() || StoreGui.IsVisible() || Hud.IsPieceSelectionVisible())
                    {
                        wasSelecting = true;
                    }
                    else
                    {
                        ___m_placePressedTime = Time.time;
                    }
                }
                else if (wasSelecting && !ZInput.GetButton("Attack") && !ZInput.GetButton("JoyPlace"))
                {
                    wasSelecting = false;
                }
            }
Esempio n. 5
0
        public static void Postfix(CraftingStation __instance)
        {
            if (InventoryGui.IsVisible())
            {
                var container = GetOrCreateContainer(__instance);
                if (container)
                {
                    InventoryGui.instance.m_currentContainer = container;
                }

                InventoryGui.instance.UpdateCraftingPanel();
            }
        }
Esempio n. 6
0
 private bool shouldUpdateRayVectors()
 {
     if ((Chat.instance != null && Chat.instance.HasFocus()) || Console.IsVisible() || TextInput.IsVisible())
     {
         return(false);
     }
     return(inPlaceMode &&
            !StoreGui.IsVisible() &&
            !InventoryGui.IsVisible() &&
            !Menu.IsVisible() &&
            !(TextViewer.instance && TextViewer.instance.IsVisible()) &&
            !Minimap.IsOpen() &&
            !Hud.IsPieceSelectionVisible());
 }
Esempio n. 7
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);
 }
Esempio n. 8
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);
                }
            }
Esempio n. 9
0
 // Token: 0x06000ADF RID: 2783 RVA: 0x0004DFF4 File Offset: 0x0004C1F4
 private void UpdateMouseCapture()
 {
     if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.F1))
     {
         this.m_mouseCapture = !this.m_mouseCapture;
     }
     if (this.m_mouseCapture && !InventoryGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible())
     {
         Cursor.lockState = CursorLockMode.Locked;
         Cursor.visible   = false;
         return;
     }
     Cursor.lockState = CursorLockMode.None;
     Cursor.visible   = ZInput.IsMouseActive();
 }
Esempio n. 10
0
 public static bool Prefix(GameCamera __instance, ref bool ___m_mouseCapture)
 {
     if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.F1))
     {
         ___m_mouseCapture = !___m_mouseCapture;
     }
     if (___m_mouseCapture && !InventoryGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !StoreGui.IsVisible() && !Hud.IsPieceSelectionVisible() && !Manager.MenuOpen)
     {
         Cursor.lockState = CursorLockMode.Locked;
         Cursor.visible   = false;
         return(false);
     }
     Cursor.lockState = CursorLockMode.None;
     Cursor.visible   = ZInput.IsMouseActive();
     return(false);
 }
Esempio n. 11
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);
         }
     }
 }
Esempio n. 12
0
    // Token: 0x06000627 RID: 1575 RVA: 0x0003484C File Offset: 0x00032A4C
    private void Update()
    {
        if (!this.m_rootPanel.activeSelf)
        {
            this.m_hiddenFrames++;
            return;
        }
        this.m_hiddenFrames = 0;
        if (!this.m_trader)
        {
            this.Hide();
            return;
        }
        Player localPlayer = Player.m_localPlayer;

        if (localPlayer == null || localPlayer.IsDead() || localPlayer.InCutscene())
        {
            this.Hide();
            return;
        }
        if (Vector3.Distance(this.m_trader.transform.position, Player.m_localPlayer.transform.position) > this.m_hideDistance)
        {
            this.Hide();
            return;
        }
        if (InventoryGui.IsVisible() || Minimap.IsOpen())
        {
            this.Hide();
            return;
        }
        if ((Chat.instance == null || !Chat.instance.HasFocus()) && !global::Console.IsVisible() && !Menu.IsVisible() && TextViewer.instance && !TextViewer.instance.IsVisible() && !localPlayer.InCutscene() && (ZInput.GetButtonDown("JoyButtonB") || Input.GetKeyDown(KeyCode.Escape) || ZInput.GetButtonDown("Use")))
        {
            ZInput.ResetButtonStatus("JoyButtonB");
            this.Hide();
        }
        this.UpdateBuyButton();
        this.UpdateSellButton();
        this.UpdateRecipeGamepadInput();
        this.m_coinText.text = this.GetPlayerCoins().ToString();
    }
Esempio n. 13
0
            static void Postfix(Hud __instance)
            {
                if (!modEnabled.Value || Player.m_localPlayer == null || InventoryGui.IsVisible() == true)
                {
                    return;
                }

                float gameScale = GameObject.Find("GUI").GetComponent <CanvasScaler>().scaleFactor;
                int   healthRot = 90 - (healthbarRotation.Value / 90 % 4 * 90);

                Vector3 mousePos = Input.mousePosition;

                if (!modEnabled.Value)
                {
                    lastMousePos = mousePos;
                    return;
                }

                SetElementPositions();

                if (lastMousePos == Vector3.zero)
                {
                    lastMousePos = mousePos;
                }


                Transform hudRoot = Hud.instance.transform.Find("hudroot");


                Rect healthRect = Rect.zero;

                switch (healthRot)
                {
                case 90:     // 0 - good
                    healthRect = new Rect(
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale,
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value
                        );
                    break;

                case 0:     // 90 - good
                    healthRect = new Rect(
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale,
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value
                        );
                    break;

                case -90:     // 180
                    healthRect = new Rect(
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value
                        );
                    break;

                case -180:     // 270
                    healthRect = new Rect(
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.x) * gameScale - hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                        (hudRoot.Find("healthpanel").GetComponent <RectTransform>().anchoredPosition.y) * gameScale,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.x *gameScale *healthbarScale.Value,
                        hudRoot.Find("healthpanel").GetComponent <RectTransform>().sizeDelta.y *gameScale *healthbarScale.Value
                        );
                    break;
                }
                if (hudRoot.Find("healthpanel").Find("Health").Find("QuickSlotsHotkeyBar"))
                {
                    hudRoot.Find("healthpanel").Find("Health").Find("QuickSlotsHotkeyBar").SetParent(hudRoot);
                    hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().anchoredPosition += new Vector2(healthRect.x, healthRect.y);
                    hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().localEulerAngles  = new Vector3(0, 0, 0);
                }


                if (CheckKeyHeld(modKeyOne.Value) && CheckKeyHeld(modKeyTwo.Value))
                {
                    Rect hotkeyRect = new Rect(
                        hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMin.x *Screen.width + hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchoredPosition.x *gameScale,
                        hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchorMax.y *Screen.height + hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().anchoredPosition.y *gameScale - hudRoot.Find("HotKeyBar").GetComponent <HotkeyBar>().m_elementSpace *gameScale *toolbarItemScale.Value *(7 / toolbarItemsPerRow.Value + 1),
                        hudRoot.Find("HotKeyBar").GetComponent <RectTransform>().sizeDelta.x *gameScale *toolbarItemScale.Value *(toolbarItemsPerRow.Value / 8f),
                        hudRoot.Find("HotKeyBar").GetComponent <HotkeyBar>().m_elementSpace *gameScale *toolbarItemScale.Value *(7 / toolbarItemsPerRow.Value + 1)
                        );


                    Rect guardianRect = new Rect(
                        (hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition.x + hudRoot.Find("GuardianPower").GetComponent <RectTransform>().rect.x *guardianScale.Value) * gameScale,
                        (hudRoot.Find("GuardianPower").GetComponent <RectTransform>().anchoredPosition.y + hudRoot.Find("GuardianPower").GetComponent <RectTransform>().rect.y *guardianScale.Value) * gameScale,
                        hudRoot.Find("GuardianPower").GetComponent <RectTransform>().sizeDelta.x *gameScale *guardianScale.Value,
                        hudRoot.Find("GuardianPower").GetComponent <RectTransform>().sizeDelta.y *gameScale *guardianScale.Value
                        );
                    Rect statusRect = new Rect(
                        Screen.width + (hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition.x + hudRoot.Find("StatusEffects").GetComponent <RectTransform>().rect.x *statusScale.Value) * gameScale,
                        Screen.height + (hudRoot.Find("StatusEffects").GetComponent <RectTransform>().anchoredPosition.y + hudRoot.Find("StatusEffects").GetComponent <RectTransform>().rect.y *statusScale.Value) * gameScale,
                        hudRoot.Find("StatusEffects").GetComponent <RectTransform>().sizeDelta.x *gameScale *statusScale.Value,
                        hudRoot.Find("StatusEffects").GetComponent <RectTransform>().sizeDelta.y *gameScale *statusScale.Value
                        );
                    Rect mapRect = new Rect(
                        (hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition.x - hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.x *mapScale.Value) * gameScale + Screen.width,
                        (hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().anchoredPosition.y - hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.y *mapScale.Value) * gameScale + Screen.height,
                        hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.x *gameScale *mapScale.Value,
                        hudRoot.Find("MiniMap").Find("small").GetComponent <RectTransform>().sizeDelta.y *gameScale *mapScale.Value
                        );

                    Rect quickSlotsRect = Rect.zero;
                    if (hudRoot.Find("QuickSlotsHotkeyBar")?.GetComponent <RectTransform>() != null)
                    {
                        quickSlotsRect = new Rect(
                            hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().anchoredPosition.x *gameScale,
                            hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().anchoredPosition.y *gameScale + Screen.height - hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().sizeDelta.y *gameScale *quickSlotsScale.Value,
                            hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().sizeDelta.x *gameScale *quickSlotsScale.Value *(3 / 8f),
                            hudRoot.Find("QuickSlotsHotkeyBar").GetComponent <RectTransform>().sizeDelta.y *gameScale *quickSlotsScale.Value
                            );
                    }

                    if (hotkeyRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "HotKeyBar"))
                    {
                        //Dbgl("in hotkeybar");
                        toolbarX.Value   += mousePos.x - lastMousePos.x;
                        toolbarY.Value   += mousePos.y - lastMousePos.y;
                        currentlyDragging = "HotKeyBar";
                    }
                    else if (healthRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "healthpanel"))
                    {
                        //Dbgl("in healthpanel");
                        healthbarX.Value += (mousePos.x - lastMousePos.x) / gameScale;
                        healthbarY.Value += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "healthpanel";
                    }
                    else if (guardianRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "GuardianPower"))
                    {
                        //Dbgl("in guardianPower");
                        guardianX.Value  += (mousePos.x - lastMousePos.x) / gameScale;
                        guardianY.Value  += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "GuardianPower";
                    }
                    else if (mapRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "MiniMap"))
                    {
                        //Dbgl("in MiniMap");
                        mapX.Value       += (mousePos.x - lastMousePos.x) / gameScale;
                        mapY.Value       += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "MiniMap";
                    }
                    else if (statusRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "StatusEffects"))
                    {
                        //Dbgl("in StatusEffects");
                        statusX.Value    += (mousePos.x - lastMousePos.x) / gameScale;
                        statusY.Value    += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging = "StatusEffects";
                    }
                    else if (quickSlotsRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "QuickSlots"))
                    {
                        //Dbgl("in QuickSlots");
                        quickSlotsX.Value += (mousePos.x - lastMousePos.x) / gameScale;
                        quickSlotsY.Value += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging  = "QuickSlots";
                    }
                    else
                    {
                        //Dbgl($"mouse {mousePos}, hotkey rect {hotkeyRect}, health rect {healthRect}, guardian rect {guardianRect}, map rect {mapRect}");
                        //Dbgl($"mouse {mousePos} qs rect {quickSlotsRect}");
                        currentlyDragging = "";
                    }
                }
                else
                {
                    currentlyDragging = "";
                }

                lastMousePos = mousePos;
            }
Esempio n. 14
0
            private static void Prefix()
            {
                if (CheckPlayerNull() || Player.m_localPlayer.IsTeleporting() || global::Console.instance.m_chatWindow.gameObject.activeInHierarchy || Chat.instance.m_chatWindow.gameObject.activeInHierarchy || Player.m_localPlayer.InPlaceMode() || TextInput.IsVisible() || StoreGui.IsVisible() || InventoryGui.IsVisible() || Menu.IsVisible())
                {
                    return;
                }
                Vector3 dir  = Traverse.Create(Player.m_localPlayer).Field <Vector3>("m_lookDir").Value;
                Vector3 rdir = Traverse.Create(Player.m_localPlayer).Field <Vector3>("m_moveDir").Value;

                dir.y  = 0;
                rdir.y = 0;
                rdir   = rdir.normalized;
                dir    = dir.normalized;
                if (Input.GetKeyDown(KS_Dodge.Value.MainKey))
                {
                    Dodge(rdir);
                    return;
                }
                if (KS_Dodge_Forward.Value.IsDown())
                {
                    Dodge(dir);
                }
                if (KS_Dodge_Backward.Value.IsDown())
                {
                    Dodge(dir * -1);
                }
                if (KS_Dodge_Right.Value.IsDown())
                {
                    Dodge(Quaternion.Euler(0, 90, 0) * dir);
                }
                if (KS_Dodge_Left.Value.IsDown())
                {
                    Dodge(Quaternion.Euler(0, 90, 0) * dir * -1);
                }
            }
Esempio n. 15
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);
        }
Esempio n. 16
0
    // Token: 0x0600024A RID: 586 RVA: 0x00012870 File Offset: 0x00010A70
    private void FixedUpdate()
    {
        if (this.m_nview && !this.m_nview.IsOwner())
        {
            return;
        }
        if (!this.TakeInput())
        {
            this.m_character.SetControls(Vector3.zero, false, false, false, false, false, false, false, false, false);
            return;
        }
        bool    flag = this.InInventoryEtc();
        Vector3 zero = Vector3.zero;

        if (ZInput.GetButton("Forward"))
        {
            zero.z += 1f;
        }
        if (ZInput.GetButton("Backward"))
        {
            zero.z -= 1f;
        }
        if (ZInput.GetButton("Left"))
        {
            zero.x -= 1f;
        }
        if (ZInput.GetButton("Right"))
        {
            zero.x += 1f;
        }
        zero.x += ZInput.GetJoyLeftStickX();
        zero.z += -ZInput.GetJoyLeftStickY();
        if (zero.magnitude > 1f)
        {
            zero.Normalize();
        }
        bool flag2      = (ZInput.GetButton("Attack") || ZInput.GetButton("JoyAttack")) && !flag;
        bool attackHold = flag2;
        bool attack     = flag2 && !this.m_attackWasPressed;

        this.m_attackWasPressed = flag2;
        bool flag3           = (ZInput.GetButton("SecondAttack") || ZInput.GetButton("JoySecondAttack")) && !flag;
        bool secondaryAttack = flag3 && !this.m_secondAttackWasPressed;

        this.m_secondAttackWasPressed = flag3;
        bool flag4     = (ZInput.GetButton("Block") || ZInput.GetButton("JoyBlock")) && !flag;
        bool blockHold = flag4;
        bool block     = flag4 && !this.m_blockWasPressed;

        this.m_blockWasPressed = flag4;
        bool button = ZInput.GetButton("Jump");
        bool jump   = (button && !this.m_lastJump) || ZInput.GetButtonDown("JoyJump");

        this.m_lastJump = button;
        bool flag5  = InventoryGui.IsVisible();
        bool flag6  = (ZInput.GetButton("Crouch") || ZInput.GetButton("JoyCrouch")) && !flag5;
        bool crouch = flag6 && !this.m_lastCrouch;

        this.m_lastCrouch = flag6;
        bool run     = ZInput.GetButton("Run") || ZInput.GetButton("JoyRun");
        bool button2 = ZInput.GetButton("AutoRun");

        this.m_character.SetControls(zero, attack, attackHold, secondaryAttack, block, blockHold, jump, crouch, run, button2);
    }
Esempio n. 17
0
 // Token: 0x0600024D RID: 589 RVA: 0x00012BD3 File Offset: 0x00010DD3
 private bool InInventoryEtc()
 {
     return(InventoryGui.IsVisible() || Minimap.IsOpen() || StoreGui.IsVisible() || Hud.IsPieceSelectionVisible());
 }
Esempio n. 18
0
        private void Update()
        {
            if (!modEnabled.Value || !Player.m_localPlayer || !InventoryGui.IsVisible() || (!Player.m_localPlayer.GetCurrentCraftingStation() && !Player.m_localPlayer.NoCostCheat()))
            {
                lastCategoryIndex = 0;
                UpdateDropDown(false);
                return;
            }
            if (!InventoryGui.instance.InCraftTab())
            {
                UpdateDropDown(false);
                return;
            }

            bool hover = false;

            Vector3 mousePos = Input.mousePosition;

            if (lastMousePos == Vector3.zero)
            {
                lastMousePos = mousePos;
            }

            PointerEventData eventData = new PointerEventData(EventSystem.current)
            {
                position = lastMousePos
            };

            List <RaycastResult> raycastResults = new List <RaycastResult>();

            EventSystem.current.RaycastAll(eventData, raycastResults);
            foreach (RaycastResult rcr in raycastResults)
            {
                if (rcr.gameObject.layer == LayerMask.NameToLayer("UI"))
                {
                    if (rcr.gameObject.name == "Craft")
                    {
                        hover = true;
                        if (tabCraftPressed == 0)
                        {
                            if (useScrollWheel.Value && AedenthornUtils.CheckKeyHeld(scrollModKey.Value, false) && Input.mouseScrollDelta.y != 0)
                            {
                                SwitchFilter(Input.mouseScrollDelta.y < 0);
                            }
                            if (showMenu.Value)
                            {
                                UpdateDropDown(true);
                            }
                        }
                    }
                    else if (dropDownList.Contains(rcr.gameObject))
                    {
                        hover = true;
                    }
                }
            }

            if (!hover)
            {
                if (tabCraftPressed > 0)
                {
                    tabCraftPressed--;
                }
                UpdateDropDown(false);
            }

            if (AedenthornUtils.CheckKeyDown(prevHotKey.Value))
            {
                SwitchFilter(false);
            }
            else if (AedenthornUtils.CheckKeyDown(nextHotKey.Value))
            {
                SwitchFilter(true);
            }

            lastMousePos = Input.mousePosition;
        }
Esempio n. 19
0
 public static bool IgnoreKeyPresses(bool extra = false)
 {
     return(ZNetScene.instance == null || Player.m_localPlayer == null || Minimap.IsOpen() || Console.IsVisible() || TextInput.IsVisible() || ZNet.instance.InPasswordDialog() || Chat.instance?.HasFocus() == true || StoreGui.IsVisible() || InventoryGui.IsVisible() || Menu.IsVisible() || TextViewer.instance?.IsVisible() == true);
 }
Esempio n. 20
0
            static void Postfix(Hud __instance)
            {
                if (!modEnabled.Value || !addEquipmentRow.Value || Player.m_localPlayer == null || InventoryGui.IsVisible() == true)
                {
                    return;
                }

                float gameScale = GameObject.Find("GUI").GetComponent <CanvasScaler>().scaleFactor;

                Vector3 mousePos = Input.mousePosition;

                if (!modEnabled.Value)
                {
                    lastMousePos = mousePos;
                    return;
                }

                SetElementPositions();

                if (lastMousePos == Vector3.zero)
                {
                    lastMousePos = mousePos;
                }


                Transform hudRoot = Hud.instance.transform.Find("hudroot");


                if (AedenthornUtils.CheckKeyHeld(modKeyOne.Value) && AedenthornUtils.CheckKeyHeld(modKeyTwo.Value))
                {
                    Rect quickSlotsRect = Rect.zero;
                    if (hudRoot.Find("QuickAccessBar")?.GetComponent <RectTransform>() != null)
                    {
                        quickSlotsRect = new Rect(
                            hudRoot.Find("QuickAccessBar").GetComponent <RectTransform>().anchoredPosition.x *gameScale,
                            hudRoot.Find("QuickAccessBar").GetComponent <RectTransform>().anchoredPosition.y *gameScale + Screen.height - hudRoot.Find("QuickAccessBar").GetComponent <RectTransform>().sizeDelta.y *gameScale *quickAccessScale.Value,
                            hudRoot.Find("QuickAccessBar").GetComponent <RectTransform>().sizeDelta.x *gameScale *quickAccessScale.Value *(3 / 8f),
                            hudRoot.Find("QuickAccessBar").GetComponent <RectTransform>().sizeDelta.y *gameScale *quickAccessScale.Value
                            );
                    }

                    if (quickSlotsRect.Contains(lastMousePos) && (currentlyDragging == "" || currentlyDragging == "QuickAccessBar"))
                    {
                        quickAccessX.Value += (mousePos.x - lastMousePos.x) / gameScale;
                        quickAccessY.Value += (mousePos.y - lastMousePos.y) / gameScale;
                        currentlyDragging   = "QuickAccessBar";
                    }
                    else
                    {
                        currentlyDragging = "";
                    }
                }
                else
                {
                    currentlyDragging = "";
                }

                lastMousePos = mousePos;
            }
        public static void Postfix(GameCamera __instance, ref float ___m_distance, ref float ___m_zoomSens)
        {
            if (!isEnabled.Value || GameCamera.InFreeFly())
            {
                return;
            }

            Player localPlayer = Player.m_localPlayer;

            if (!localPlayer)
            {
                return;
            }

            checkInteriorChange(localPlayer);
            ___m_zoomSens = cameraZoomSensitivity.Value;

            // Separate camera distances for different scenarios.
            if (canChangeCameraDistance)
            {
                if (cameraDistanceInteriorsEnabled.Value && playerInInterior)
                {
                    targetDistance = cameraDistanceInteriors.Value;
                }
                else if (cameraDistanceShelterEnabled.Value && playerInShelter)
                {
                    targetDistance = cameraDistanceShelter.Value;
                }
                else if (cameraDistanceBoatEnabled.Value && characterControlledShip)
                {
                    targetDistance = cameraDistanceBoat.Value;
                }
                else if (cameraDistanceBoatEnabled.Value && characterStoppedShipControl)
                {
                    targetDistance = cameraDistance.Value;
                }
                else if (cameraDistanceExteriorsEnabled.Value && (!playerInShelter && !playerInInterior))
                {
                    targetDistance = cameraDistance.Value;
                }

                canChangeCameraDistance = false;
            }

            if (smoothZoomEnabled.Value)
            {
                // Disable the games default zooming in and out. Otherwise, the distance will flicker.
                ___m_zoomSens = 0;

                if ((Chat.instance && Chat.instance.HasFocus() || (Console.IsVisible() || InventoryGui.IsVisible()) || (StoreGui.IsVisible() || Menu.IsVisible() || (Minimap.IsOpen() || localPlayer.InCutscene())) ? 0 : (!localPlayer.InPlaceMode() ? 1 : 0)) != 0)
                {
                    float minDistance = __instance.m_minDistance;
                    float maxDistance = localPlayer.GetControlledShip() != null ? cameraMaxDistanceBoat.Value : cameraMaxDistance.Value;

                    float prevTargetDistance = targetDistance;
                    targetDistance -= Input.GetAxis("Mouse ScrollWheel") * cameraZoomSensitivity.Value;
                    targetDistance  = Mathf.Clamp(targetDistance, minDistance, maxDistance);

                    // Reset time when player changes zoom distance (scrollwheel)
                    if (prevTargetDistance != targetDistance)
                    {
                        timePos = 0;
                    }
                }

                targetDistanceHasBeenReached = checkLerpDuration(timePos);

                if (!targetDistanceHasBeenReached)
                {
                    timePos += Time.deltaTime;
                    moveToNewCameraDistance(timePos / timeDuration, ref ___m_distance);
                }
            }
        }
Esempio n. 22
0
 // Token: 0x0600024C RID: 588 RVA: 0x00012B4C File Offset: 0x00010D4C
 private bool TakeInput()
 {
     return(!GameCamera.InFreeFly() && ((!Chat.instance || !Chat.instance.HasFocus()) && !Menu.IsVisible() && !global::Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && (!ZInput.IsGamepadActive() || !Minimap.IsOpen()) && (!ZInput.IsGamepadActive() || !InventoryGui.IsVisible()) && (!ZInput.IsGamepadActive() || !StoreGui.IsVisible())) && (!ZInput.IsGamepadActive() || !Hud.IsPieceSelectionVisible()));
 }
Esempio n. 23
0
        public static void setValuesBasedOnHud(bool pressedHideKey, bool pressedShowKey)
        {
            Player localPlayer = Player.m_localPlayer;

            // Store previous target alpha for timer reset.
            foreach (string name in hudElementNames)
            {
                if (hudElements[name].element != null)
                {
                    hudElements[name].targetAlphaPrev = hudElements[name].targetAlpha;
                }
            }

            // Hide hud key
            if (pressedHideKey)
            {
                hudHidden = !hudHidden;

                // Hud hidden notification
                if (hudHiddenNotification.Value)
                {
                    if (hudHidden)
                    {
                        MessageHud.instance.ShowMessage(MessageHud.MessageType.TopLeft, "Hud is hidden.");
                    }
                    else
                    {
                        MessageHud.instance.ShowMessage(MessageHud.MessageType.TopLeft, "Hud is visible.");
                    }
                }

                foreach (string name in hudElementNames)
                {
                    hudElements[name].resetTimers();
                }
            }

            // Hunger notification
            if (hungerNotification.Value && ((hungerNotificationOption.Value == hungerNotificationOptions.FoodHungerAmount && playerHungerCount >= foodHungerAmount.Value) || (hungerNotificationOption.Value == hungerNotificationOptions.FoodPercentage && playerFoodPercentage <= foodPercentage.Value)))
            {
                notificationTimer += Time.deltaTime;

                if ((int)notificationTimer % hungerNotificationInterval.Value == 0)
                {
                    switch (hungerNotificationType.Value)
                    {
                    case notificationTypes.SmallTopLeft:
                        MessageHud.instance.ShowMessage(MessageHud.MessageType.TopLeft, hungerNotificationText.Value);
                        break;

                    case notificationTypes.LargeCenter:
                        MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, hungerNotificationText.Value);
                        break;

                    default:
                        break;
                    }

                    notificationTimer = 1;
                }
            }

            if (hudHidden)
            {
                foreach (string name in hudElementNames)
                {
                    hudElements[name].targetAlpha = 0;
                }

                if (isMiniMapActive)
                {
                    hudElements["MiniMap"].targetAlpha = 0;
                }
                else
                {
                    hudElements["MiniMap"].targetAlpha = 1;
                }
            }
            else if (pressedShowKey)
            {
                // Health
                if (showHealthOnKeyPressed.Value)
                {
                    hudElements["healthpanel"].showHudForDuration();
                    hudElements["BetterUI_HPBar"].showHudForDuration();
                }

                // Food Bar
                if (showFoodBarOnKeyPressed.Value)
                {
                    hudElements["BetterUI_FoodBar"].showHudForDuration();
                }

                // Stamina
                if (showStaminaBarOnKeyPressed.Value)
                {
                    hudElements["staminapanel"].showHudForDuration();
                    hudElements["BetterUI_StaminaBar"].showHudForDuration();
                }

                // Forsaken Power
                if (showPowerOnKeyPressed.Value)
                {
                    hudElements["GuardianPower"].showHudForDuration();
                }

                // Hot Key Bar
                if (showHotKeyBarOnKeyPressed.Value)
                {
                    hudElements["HotKeyBar"].showHudForDuration();
                }

                // Status Effects
                if (showStatusEffectsOnKeyPressed.Value)
                {
                    hudElements["StatusEffects"].showHudForDuration();
                }

                // Mini Map
                if (showMiniMapOnKeyPressed.Value)
                {
                    hudElements["MiniMap"].showHudForDuration();
                }

                // Compass
                if (showCompassOnKeyPressed.Value)
                {
                    hudElements["Compass"].showHudForDuration();
                }

                // Day and Time
                if (showTimeOnKeyPressed.Value && oryxenTimeEnabled.Value)
                {
                    hudElements["DayTimePanel"].showHudForDuration();
                }

                // Quick Slots
                if (showQuickSlotsOnKeyPressed.Value)
                {
                    hudElements["QuickSlotsHotkeyBar"].showHudForDuration();
                }
            }
            else
            {
                // Health Display
                if (displayHealthAlways.Value || (displayHealthInInventory.Value && InventoryGui.IsVisible()))
                {
                    hudElements["healthpanel"].targetAlpha    = 1;
                    hudElements["BetterUI_HPBar"].targetAlpha = 1;

                    if (!displayHealthInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["healthpanel"].hudSetTargetAlpha(0);
                        hudElements["BetterUI_HPBar"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    // Display health panel when eating food
                    if (displayHealthWhenEating.Value && playerAteFood)
                    {
                        hudElements["healthpanel"].showHudForDuration();
                        hudElements["BetterUI_HPBar"].showHudForDuration();
                    }

                    // Display health panel when below a given percentage.
                    if (displayHealthWhenBelow.Value && localPlayer.GetHealthPercentage() <= healthPercentage.Value)
                    {
                        hudElements["healthpanel"].hudSetTargetAlpha(1);
                        hudElements["BetterUI_HPBar"].hudSetTargetAlpha(1);
                    }
                    else if (displayHealthWhenFoodBelow.Value && playerFoodPercentage <= foodPercentage.Value)
                    {
                        hudElements["healthpanel"].hudSetTargetAlpha(1);
                        hudElements["BetterUI_HPBar"].hudSetTargetAlpha(1);
                    }
                    else if (displayHealthWhenHungry.Value && playerHungerCount >= foodHungerAmount.Value)
                    {
                        hudElements["healthpanel"].hudSetTargetAlpha(1);
                        hudElements["BetterUI_HPBar"].hudSetTargetAlpha(1);
                    }
                    else
                    {
                        hudElements["healthpanel"].hudSetTargetAlpha(0);
                        hudElements["BetterUI_HPBar"].hudSetTargetAlpha(0);
                    }
                }

                // Food Bar Display
                if (displayBetterUIFoodAlways.Value || (displayFoodBarInInventory.Value && InventoryGui.IsVisible()))
                {
                    hudElements["BetterUI_FoodBar"].targetAlpha = 1;

                    if (!displayFoodBarInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    if (betterUIFoodEnabled.Value && hudElements["BetterUI_FoodBar"].doesExist)
                    {
                        // Display food bar when eating food
                        if (displayFoodBarWhenEating.Value && playerAteFood)
                        {
                            hudElements["BetterUI_FoodBar"].showHudForDuration();
                        }

                        // Display food bar when below a given percentage.
                        if (displayFoodBarWhenBelow.Value && playerFoodPercentage <= foodPercentage.Value)
                        {
                            hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(1);
                        }
                        else if (displayFoodBarWhenHungry.Value && playerHungerCount >= foodHungerAmount.Value)
                        {
                            hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(1);
                        }
                        else
                        {
                            hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(0);
                        }
                    }
                }

                // Stamina Bar Display
                if (displayStaminaBarAlways.Value || (displayStaminaBarInInventory.Value && InventoryGui.IsVisible()))
                {
                    hudElements["staminapanel"].targetAlpha        = 1;
                    hudElements["BetterUI_StaminaBar"].targetAlpha = 1;

                    if (!displayStaminaBarInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["staminapanel"].hudSetTargetAlpha(0);
                        hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    // Display stamina bar when stamina is used
                    if (displayStaminaBarOnUse.Value && playerUsedStamina)
                    {
                        hudElements["staminapanel"].showHudForDuration();
                        hudElements["BetterUI_StaminaBar"].showHudForDuration();
                    }

                    // Display stamina bar when eating food
                    if (displayStaminaBarWhenEating.Value && playerAteFood)
                    {
                        hudElements["staminapanel"].showHudForDuration();
                        hudElements["BetterUI_StaminaBar"].showHudForDuration();
                    }

                    // Display stamina bar when below a given percentage.
                    if (displayStaminaBarWhenBelow.Value && localPlayer.GetStaminaPercentage() <= staminaPercentage.Value)
                    {
                        hudElements["staminapanel"].hudSetTargetAlpha(1);
                        hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(1);
                    }
                    else if (displayStaminaBarWhenFoodBelow.Value && playerFoodPercentage <= foodPercentage.Value)
                    {
                        hudElements["staminapanel"].hudSetTargetAlpha(1);
                        hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(1);
                    }
                    else if (displayStaminaBarWhenHungry.Value && playerHungerCount >= foodHungerAmount.Value)
                    {
                        hudElements["staminapanel"].hudSetTargetAlpha(1);
                        hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(1);
                    }
                    else
                    {
                        hudElements["staminapanel"].hudSetTargetAlpha(0);
                        hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(0);
                    }
                }

                // Forsaken Power Display
                if (displayForsakenPowerAlways.Value || (displayPowerInInventory.Value && InventoryGui.IsVisible()))
                {
                    hudElements["GuardianPower"].targetAlpha = 1;

                    if (!displayPowerInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["GuardianPower"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    // Show the forsaken power for a duration when the key is pressed.
                    if (displayPowerOnActivation.Value && (ZInput.GetButtonDown("GPower") || ZInput.GetButtonDown("JoyGPower")))
                    {
                        hudElements["GuardianPower"].showHudForDuration();
                    }

                    hudElements["GuardianPower"].hudSetTargetAlpha(0);
                }

                // Hot Key Bar Display
                if (displayHotKeyBarAlways.Value || (displayHotKeyBarInInventory.Value && InventoryGui.IsVisible()))
                {
                    hudElements["HotKeyBar"].targetAlpha = 1;

                    if (!displayHotKeyBarInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["HotKeyBar"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    // Display on item switch/use
                    if (displayHotKeyBarOnItemSwitch.Value && playerUsedHotBarItem)
                    {
                        hudElements["HotKeyBar"].showHudForDuration();
                    }
                    else if (displayHotKeyBarWhenItemEquipped.Value && playerHasItemEquipped)
                    {
                        hudElements["HotKeyBar"].hudSetTargetAlpha(1);
                    }
                    else
                    {
                        hudElements["HotKeyBar"].hudSetTargetAlpha(0);
                    }
                }

                // Status Effects Display
                if (displayStatusEffectsAlways.Value || (displayStatusEffectsInInventory.Value && InventoryGui.IsVisible()))
                {
                    hudElements["StatusEffects"].targetAlpha = 1;

                    if (!displayStatusEffectsInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["StatusEffects"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    hudElements["StatusEffects"].hudSetTargetAlpha(0);
                }

                // Mini Map Display
                if (displayMiniMapAlways.Value || (displayMiniMapInInventory.Value && InventoryGui.IsVisible()) || !isMiniMapActive)
                {
                    hudElements["MiniMap"].targetAlpha = 1;

                    if (!displayMiniMapInInventory.Value && InventoryGui.IsVisible())
                    {
                        hudElements["MiniMap"].hudSetTargetAlpha(0);
                    }
                }
                else
                {
                    hudElements["MiniMap"].hudSetTargetAlpha(0);
                }

                // Compass Display
                if (aedenCompassEnabled.Value && hudElements["Compass"].doesExist)
                {
                    if (displayCompassAlways.Value || (displayCompassInInventory.Value && InventoryGui.IsVisible()))
                    {
                        hudElements["Compass"].targetAlpha = 1;

                        if (!displayCompassInInventory.Value && InventoryGui.IsVisible())
                        {
                            hudElements["Compass"].hudSetTargetAlpha(0);
                        }
                    }
                    else
                    {
                        hudElements["Compass"].hudSetTargetAlpha(0);
                    }
                }

                // Day and Time Display
                if (oryxenTimeEnabled.Value && hudElements["DayTimePanel"].doesExist)
                {
                    if (displayTimeAlways.Value || (displayTimeInInventory.Value && InventoryGui.IsVisible()))
                    {
                        hudElements["DayTimePanel"].targetAlpha = 1;

                        if (!displayTimeInInventory.Value && InventoryGui.IsVisible())
                        {
                            hudElements["DayTimePanel"].hudSetTargetAlpha(0);
                        }
                    }
                    else
                    {
                        hudElements["DayTimePanel"].hudSetTargetAlpha(0);
                    }
                }

                // QuickSlots Display
                if (quickSlotsEnabled.Value && hudElements["QuickSlotsHotkeyBar"].doesExist)
                {
                    if (displayQuickSlotsAlways.Value || (displayQuickSlotsInInventory.Value && InventoryGui.IsVisible()))
                    {
                        hudElements["QuickSlotsHotkeyBar"].targetAlpha = 1;

                        if (!displayQuickSlotsInInventory.Value && InventoryGui.IsVisible())
                        {
                            hudElements["QuickSlotsHotkeyBar"].hudSetTargetAlpha(0);
                        }
                    }
                    else
                    {
                        hudElements["QuickSlotsHotkeyBar"].hudSetTargetAlpha(0);
                    }
                }
            }

            // Reset timer when the target alpha changed.
            foreach (string name in hudElementNames)
            {
                hudElements[name].hudCheckDisplayTimer();

                if (!hudElements[name].doesExist || hudElements[name].element == null)
                {
                    continue;
                }

                if (hudElements[name].targetAlphaPrev != hudElements[name].targetAlpha)
                {
                    hudElements[name].timeFade = 0;
                }
            }

            playerUsedHotBarItem = false;
            playerUsedStamina    = false;
            playerAteFood        = false;
        }
Esempio n. 24
0
 private static void Postfix(ref GameCamera __instance, float dt)
 {
     if (Configuration.Current.FirstPerson.IsEnabled)
     {
         // This is from game code, not sure if need it though
         if (__instance.m_freeFly)
         {
             __instance.UpdateFreeFly(dt);
             __instance.UpdateCameraShake(dt);
             return;
         }
         Player localPlayer = Player.m_localPlayer;
         if (Input.GetKeyDown(Configuration.Current.FirstPerson.hotkey))
         {
             DynamicPerson.isFirstPerson = !DynamicPerson.isFirstPerson;
             if (DynamicPerson.isFirstPerson)
             {
                 SetupFP(ref __instance, ref localPlayer);
             }
             else
             {
                 // We are not in First Person any more, reload old values
                 __instance.m_3rdOffset = DynamicPerson.noVPFP_3rdOffset;
                 __instance.m_fpsOffset = DynamicPerson.noVPFP_fpsOffset;
                 // Set the camera stuff to our constant stored values
                 __instance.m_minDistance = CameraConstants.minDistance;
                 __instance.m_maxDistance = CameraConstants.maxDistance;
                 __instance.m_zoomSens    = CameraConstants.zoomSens;
                 // Default Field Of View value
                 __instance.m_fov = 65f;
                 // Make head stuff be normal again
                 localPlayer.m_head.localScale = Vector3.one;
                 localPlayer.m_eye.localScale  = Vector3.one;
             }
         }
         // FOV of cameras needs to be reset too
         __instance.m_camera.fieldOfView    = __instance.m_fov;
         __instance.m_skyCamera.fieldOfView = __instance.m_fov;
         if (localPlayer)
         {
             // Same game check
             if ((!Chat.instance || !Chat.instance.HasFocus()) &&
                 !Console.IsVisible() && !InventoryGui.IsVisible() &&
                 !StoreGui.IsVisible() && !Menu.IsVisible() &&
                 !Minimap.IsOpen() && !localPlayer.InCutscene() &&
                 !localPlayer.InPlaceMode())
             {
                 if (DynamicPerson.isFirstPerson)
                 {
                     // I dont think either of these two ifs needs explain....
                     if (Input.GetKeyDown(Configuration.Current.FirstPerson.raiseFOVHotkey))
                     {
                         __instance.m_fov += 1f;
                         Console.instance.AddString($"Changed fov to: {__instance.m_fov}");
                     }
                     else if (Input.GetKeyDown(Configuration.Current.FirstPerson.lowerFOVHotkey))
                     {
                         __instance.m_fov -= 1f;
                         Console.instance.AddString($"Changed fov to: {__instance.m_fov}");
                     }
                 }
                 else
                 {
                     // Not first camera, just do main game thing
                     float minDistance = __instance.m_minDistance;
                     float axis        = Input.GetAxis("Mouse ScrollWheel");
                     __instance.m_distance -= axis * __instance.m_zoomSens;
                     float max = (localPlayer.GetControlledShip() != null) ? __instance.m_maxDistanceBoat : __instance.m_maxDistance;
                     __instance.m_distance = Mathf.Clamp(__instance.m_distance, 0f, max);
                 }
             }
             if (localPlayer.IsDead() && localPlayer.GetRagdoll())
             {
                 // THe weird death cam actually:
                 //  - Breaks body into ragdoll
                 //  - Gives momentum to pieces
                 //  - Then finds the average point of them all to make camera look at
                 __instance.transform.LookAt(localPlayer.GetRagdoll().GetAverageBodyPosition());
             }
             else if (DynamicPerson.isFirstPerson)
             {
                 // Place camera at head level, plus a tiny bit more
                 __instance.transform.position = localPlayer.m_head.position + new Vector3(0, 0.2f, 0);
             }
             else
             {
                 // Not even sure why we need to reset the base transform
                 // But game does it so...
                 // ¯\_(ツ)_/¯
                 Vector3    position;
                 Quaternion rotation;
                 __instance.GetCameraPosition(dt, out position, out rotation);
                 __instance.transform.position = position;
                 __instance.transform.rotation = rotation;
             }
             __instance.UpdateCameraShake(dt);
         }
     }
 }
Esempio n. 25
0
    // Token: 0x06000AE2 RID: 2786 RVA: 0x0004E194 File Offset: 0x0004C394
    private void UpdateCamera(float dt)
    {
        if (this.m_freeFly)
        {
            this.UpdateFreeFly(dt);
            this.UpdateCameraShake(dt);
            return;
        }
        this.m_camera.fieldOfView    = this.m_fov;
        this.m_skyCamera.fieldOfView = this.m_fov;
        Player localPlayer = Player.m_localPlayer;

        if (localPlayer)
        {
            if ((!Chat.instance || !Chat.instance.HasFocus()) && !global::Console.IsVisible() && !InventoryGui.IsVisible() && !StoreGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !localPlayer.InCutscene() && !localPlayer.InPlaceMode())
            {
                float minDistance = this.m_minDistance;
                float axis        = Input.GetAxis("Mouse ScrollWheel");
                this.m_distance -= axis * this.m_zoomSens;
                float max = (localPlayer.GetControlledShip() != null) ? this.m_maxDistanceBoat : this.m_maxDistance;
                this.m_distance = Mathf.Clamp(this.m_distance, minDistance, max);
            }
            if (localPlayer.IsDead() && localPlayer.GetRagdoll())
            {
                Vector3 averageBodyPosition = localPlayer.GetRagdoll().GetAverageBodyPosition();
                base.transform.LookAt(averageBodyPosition);
            }
            else
            {
                Vector3    position;
                Quaternion rotation;
                this.GetCameraPosition(dt, out position, out rotation);
                base.transform.position = position;
                base.transform.rotation = rotation;
            }
            this.UpdateCameraShake(dt);
        }
    }