private void Update() { if (!modEnabled.Value || !Player.m_localPlayer || !ZNetScene.instance) { return; } if (backpack) { if (!saving && backpack.transform.parent != Player.m_localPlayer.transform) { Dbgl("Moving backpack to player"); backpack.transform.SetParent(Player.m_localPlayer.transform); InitBackpack(); } backpack.transform.position = Player.m_localPlayer.transform.position; if (!AedenthornUtils.IgnoreKeyPresses(true) && AedenthornUtils.CheckKeyDown(hotKey.Value)) { opening = true; Traverse.Create(backpack.GetComponent <Container>()).Field("m_nview").GetValue <ZNetView>().ClaimOwnership(); Traverse.Create(backpack.GetComponent <Container>()).Field("m_nview").GetValue <ZNetView>().InvokeRPC("RequestOpen", new object[] { Player.m_localPlayer.GetPlayerID() }); } } }
static void Postfix(InventoryGui __instance, Container ___m_currentContainer, int ___m_activeGroup) { Vector3 mousePos = Input.mousePosition; if (!modEnabled.Value) { return; } if (AedenthornUtils.CheckKeyHeld(ascModKey.Value, false) || AedenthornUtils.CheckKeyHeld(descModKey.Value, false)) { bool asc = AedenthornUtils.CheckKeyHeld(ascModKey.Value, false); if (AedenthornUtils.CheckKeyHeld(descModKey.Value, true)) { asc = false; } string name = ""; SortType type = SortType.Name; PointerEventData eventData = new PointerEventData(EventSystem.current) { position = mousePos }; List <RaycastResult> raycastResults = new List <RaycastResult>(); EventSystem.current.RaycastAll(eventData, raycastResults); foreach (RaycastResult rcr in raycastResults) { if (rcr.gameObject.layer == LayerMask.NameToLayer("UI") && rcr.gameObject.name == "Bkg" && (rcr.gameObject.transform.parent.name == "Player" || rcr.gameObject.transform.parent.name == "Container")) { if (AedenthornUtils.CheckKeyDown(sortByNameKey.Value)) { name = rcr.gameObject.transform.parent.name; type = SortType.Name; break; } else if (AedenthornUtils.CheckKeyDown(sortByWeightKey.Value)) { name = rcr.gameObject.transform.parent.name; type = SortType.Weight; break; } else if (AedenthornUtils.CheckKeyDown(sortByValueKey.Value)) { name = rcr.gameObject.transform.parent.name; type = SortType.Value; break; } return; } } if (name == "" && useGamePad.Value) { if (___m_activeGroup == 0 && !__instance.IsContainerOpen()) { return; } if (___m_activeGroup == 0 || ___m_activeGroup == 1) { if (AedenthornUtils.CheckKeyDown(sortByNameKey.Value)) { name = ___m_activeGroup == 0 ? "Container" : "Player"; type = SortType.Name; } else if (AedenthornUtils.CheckKeyDown(sortByWeightKey.Value)) { name = ___m_activeGroup == 0 ? "Container" : "Player"; type = SortType.Weight; } else if (AedenthornUtils.CheckKeyDown(sortByValueKey.Value)) { name = ___m_activeGroup == 0 ? "Container" : "Player"; type = SortType.Value; } } } if (name == "" || (name == "Player" && !allowPlayerInventorySort.Value)) { return; } Dbgl($"Sorting {name} inventory by {type} {(asc ? "asc" : "desc")}"); if (name == "Player") { playerSortType.Value = type; playerSortAsc.Value = asc; context.Config.Save(); SortByType(type, Player.m_localPlayer.GetInventory(), asc, true); } else if (name == "Container") { containerSortType.Value = type; containerSortAsc.Value = asc; context.Config.Save(); SortByType(type, ___m_currentContainer.GetInventory(), asc, false); } } }
private void Update() { if (!AedenthornUtils.IgnoreKeyPresses(true) && AedenthornUtils.CheckKeyDown(hotKey.Value)) { Player player = Player.m_localPlayer; Dbgl($"Ka-boom"); Collider[] array = Physics.OverlapSphere(player.transform.position, destroyRadius.Value, destroyMask); for (int i = 0; i < array.Length; i++) { Piece piece = array[i].GetComponentInParent <Piece>(); if (piece) { if (!piece.IsCreator()) { continue; } if (!piece.m_canBeRemoved) { continue; } if (Location.IsInsideNoBuildLocation(piece.transform.position)) { continue; } if (!PrivateArea.CheckAccess(piece.transform.position, 0f, true)) { continue; } if (!Traverse.Create(player).Method("CheckCanRemovePiece", new object[] { piece }).GetValue <bool>()) { continue; } ZNetView component = piece.GetComponent <ZNetView>(); if (component == null) { continue; } if (!piece.CanBeRemoved()) { continue; } WearNTear component2 = piece.GetComponent <WearNTear>(); if (component2) { component2.Remove(); } else { component.ClaimOwnership(); piece.DropResources(); piece.m_placeEffect.Create(piece.transform.position, piece.transform.rotation, piece.gameObject.transform, 1f); player.m_removeEffects.Create(piece.transform.position, Quaternion.identity, null, 1f); ZNetScene.instance.Destroy(piece.gameObject); } ItemDrop.ItemData rightItem = player.GetRightItem(); if (rightItem != null) { player.FaceLookDirection(); Traverse.Create(player).Field("m_zanim").GetValue <ZSyncAnimation>().SetTrigger(rightItem.m_shared.m_attack.m_attackAnimation); } } } } }
private void Update() { if (modEnabled.Value && Player.m_localPlayer != null && AedenthornUtils.CheckKeyHeld(modKey.Value, true) && (AedenthornUtils.CheckKeyDown(deleteKey.Value) || AedenthornUtils.CheckKeyDown(checkKey.Value))) { Dbgl($"modkey {AedenthornUtils.CheckKeyHeld(modKey.Value, true)}, del key {AedenthornUtils.CheckKeyDown(deleteKey.Value)}, check key {AedenthornUtils.CheckKeyDown(checkKey.Value)}"); LayerMask layerMask = LayerMask.GetMask(layerMaskString.Value.Split(',')); RaycastHit raycastHit; if (Physics.Raycast(GameCamera.instance.transform.position, GameCamera.instance.transform.forward, out raycastHit, maxDeleteDistance.Value) && Vector3.Distance(raycastHit.point, Player.m_localPlayer.m_eye.position) < maxDeleteDistance.Value) { Transform t = raycastHit.collider.transform; while (t.parent.parent && t.parent.name != "_NetSceneRoot" && !t.name.Contains("(Clone)")) { Dbgl($"name: {t.name}, parent name: {t.parent.name}"); t = t.parent; } string name = ZNetView.GetPrefabName(t.gameObject); if (AedenthornUtils.CheckKeyDown(checkKey.Value)) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, string.Format(checkMessage.Value, name, Vector3.Distance(raycastHit.point, Player.m_localPlayer.m_eye.position))); return; } else if (t.GetComponent <ZNetView>()) { t.GetComponent <ZNetView>().Destroy(); } else { Destroy(t.gameObject); } Player.m_localPlayer.Message(MessageHud.MessageType.Center, string.Format(deletedMessage.Value, name, Vector3.Distance(raycastHit.point, Player.m_localPlayer.m_eye.position))); } } }
static void Postfix(InventoryGui __instance, Animator ___m_animator, Container ___m_currentContainer) { if (!modEnabled.Value || !backpack || !Player.m_localPlayer || !___m_animator.GetBool("visible") || !AedenthornUtils.CheckKeyDown(hotKey.Value)) { return; } if (opening) { opening = false; return; } if (___m_currentContainer == backpack.GetComponent <Container>()) { Traverse.Create(__instance).Method("CloseContainer").GetValue(); } else { Traverse.Create(backpack.GetComponent <Container>()).Field("m_nview").GetValue <ZNetView>().ClaimOwnership(); Traverse.Create(backpack.GetComponent <Container>()).Field("m_nview").GetValue <ZNetView>().InvokeRPC("RequestOpen", new object[] { Player.m_localPlayer.GetPlayerID() }); } }
private void Update() { /* * if (AedenthornUtils.CheckKeyDown(openUIKey.Value)) * { * storeOpen = !storeOpen; * * } * return; */ if (ZNet.instance && Player.m_localPlayer && !AedenthornUtils.IgnoreKeyPresses(true) && AedenthornUtils.CheckKeyDown(openUIKey.Value)) { Dbgl("Pressed hotkey"); if (storeOpen) { Dbgl("Closing store"); storeOpen = false; } else { ZRpc serverRPC = ZNet.instance.GetServerRPC(); if (serverRPC != null) { Dbgl("Requesting store data"); JsonCommand command = new JsonCommand() { command = "RequestStoreInfo", id = SteamUser.GetSteamID().ToString() }; string commandJson = JsonUtility.ToJson(command); Dbgl(commandJson); serverRPC.Invoke("SendServerRewardsJSON", new object[] { commandJson }); } } } }
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; }
private void Update() { if (!modEnabled.Value) { return; } if (testing.Value) { if (AedenthornUtils.CheckKeyDown(openUIKey.Value)) { storeOpen = !storeOpen; } return; } if (ZNet.instance && Player.m_localPlayer && !AedenthornUtils.IgnoreKeyPresses(true) && AedenthornUtils.CheckKeyDown(openUIKey.Value)) { Dbgl("Pressed hotkey"); if (storeOpen) { Traverse.Create(GameCamera.instance).Field("m_mouseCapture").SetValue(true); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; Dbgl("Closing store"); storeOpen = false; } else { ZRpc serverRPC = ZNet.instance.GetServerRPC(); if (serverRPC != null) { Dbgl("Requesting store data"); JsonCommand command = new JsonCommand() { command = "RequestStoreInfo", id = SteamUser.GetSteamID().ToString() }; string commandJson = JsonUtility.ToJson(command); Dbgl(commandJson); serverRPC.Invoke("SendServerRewardsJSON", new object[] { commandJson }); } } } }