private void Update()
        {
            if (!modEnabled.Value || !Player.m_localPlayer || !Player.m_localPlayer.InPlaceMode() || Hud.IsPieceSelectionVisible())
            {
                if (lastOriginalRadius != 0)
                {
                    lastOriginalRadius = 0;
                    lastModdedRadius   = 0;
                    lastTotalDelta     = 0;
                    SetRadius(0);
                }
                return;
            }

            if (useScrollWheel.Value && AedenthornUtils.CheckKeyHeld(scrollModKey.Value, false) && Input.mouseScrollDelta.y != 0)
            {
                SetRadius(Input.mouseScrollDelta.y * scrollWheelScale.Value);
            }
            else if (AedenthornUtils.CheckKeyDown(increaseHotKey.Value))
            {
                SetRadius(hotkeyScale.Value);
            }
            else if (AedenthornUtils.CheckKeyDown(decreaseHotKey.Value))
            {
                SetRadius(-hotkeyScale.Value);
            }
        }
            static void Postfix(bool __result, Piece piece, GameObject ___m_placementGhost)
            {
                if (!modEnabled.Value || !__result || !AedenthornUtils.CheckKeyHeld(modKey.Value))
                {
                    return;
                }

                Door door = piece.gameObject.GetComponent <Door>();

                if (door)
                {
                    var pos  = ___m_placementGhost.transform.position;
                    var guid = Guid.NewGuid();
                    newDoors.Add(pos, guid);

                    if (promptNameOnCreate.Value)
                    {
                        RenameDoor(guid + "");
                    }

                    GameObject keyPrefab = ZNetScene.instance.GetPrefab("DoorKey");
                    GameObject go        = Instantiate(keyPrefab, Player.m_localPlayer.transform.position + Vector3.up, Quaternion.identity);
                    go.GetComponent <ItemDrop>().m_itemData.m_crafterName = guid + "";
                    Dbgl($"Spawned door key for door {guid} at {pos}");
                }
            }
Exemple #3
0
            static void Postfix(Hud __instance)
            {
                if (!modEnabled.Value || !addEquipmentRow.Value || Player.m_localPlayer == null)
                {
                    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;
            }
Exemple #4
0
 static bool Prefix(InventoryGrid __instance, UIInputHandler element, Inventory ___m_inventory)
 {
     if (modEnabled.Value && AedenthornUtils.CheckKeyHeld(modKey.Value) && !leftClick.Value && InventoryGui.instance)
     {
         RepairClickedItem(__instance, element, ___m_inventory);
         return(false);
     }
     return(true);
 }
Exemple #5
0
 static bool Prefix(TerrainOp.Settings ___m_settings)
 {
     //Dbgl($"{___m_settings.m_smooth} {AedenthornUtils.CheckKeyHeld(modKey.Value)}");
     if (!modEnabled.Value || !___m_settings.m_smooth || !AedenthornUtils.CheckKeyHeld(modKey.Value))
     {
         return(true);
     }
     return(false);
 }
            static bool Prefix(Door __instance, ZNetView ___m_nview, bool __result, Humanoid character)
            {
                if (!modEnabled.Value || ___m_nview.GetZDO() == null || !(character is Player) || !___m_nview.GetZDO().GetBool("LockedDoor"))
                {
                    return(true);
                }

                string guid = ___m_nview.GetZDO().GetString("DoorGUID");

                Dbgl($"trying to open door {___m_nview.GetZDO().GetString("DoorGUID")}");
                if (AedenthornUtils.CheckKeyHeld(modKey.Value) && (character as Player).GetInventory().GetAllItems().Exists(i => i.m_crafterName == guid))
                {
                    ___m_nview.GetZDO().Set("DoorLocked", !___m_nview.GetZDO().GetBool("DoorLocked"));
                    __result = true;
                    character.Message(MessageHud.MessageType.Center, string.Format(lockedMessage.Value, ___m_nview.GetZDO().GetBool("DoorLocked")), 0, null);

                    Dbgl($"Door locked: {___m_nview.GetZDO().GetBool("DoorLocked")}");
                    return(false);
                }
                else if (AedenthornUtils.CheckKeyHeld(renameModKey.Value) && (character as Player).GetInventory().GetAllItems().Exists(i => i.m_crafterName == guid))
                {
                    __result = true;

                    RenameDoor(guid);

                    Dbgl($"Door name set to : {___m_nview.GetZDO().GetBool("DoorLocked")}");
                    return(false);
                }
                else if (___m_nview.GetZDO().GetBool("DoorLocked") && (needKeyToClose.Value || ___m_nview.GetZDO().GetInt("state", 0) == 0))
                {
                    Dbgl($"Trying to open door {___m_nview.GetZDO().GetString("DoorGUID")} {(character as Player).GetInventory().GetAllItems().Find(i => i.m_crafterName == ___m_nview.GetZDO().GetString("DoorGUID"))?.m_crafterName}");

                    if (!(character as Player).GetInventory().GetAllItems().Exists(i => i.m_crafterName == ___m_nview.GetZDO().GetString("DoorGUID")))
                    {
                        __instance.m_lockedEffects.Create(__instance.transform.position, __instance.transform.rotation, null, 1f);
                        character.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_door_needkey", new string[]
                        {
                            GetDoorName(guid)
                        }), 0, null);
                        __result = true;
                        Dbgl($"player doesn't have key for {__instance.transform.position}");
                        return(false);
                    }
                    else
                    {
                        Dbgl($"player has key for {__instance.transform.position}");
                    }
                }

                return(true);
            }
Exemple #7
0
            static bool Prefix(Vector3 pos, TerrainOp.Settings modifier, bool ___m_initialized)
            {
                if (!___m_initialized)
                {
                    return(false);
                }

                if (!modEnabled.Value || !modifier.m_smooth || !AedenthornUtils.CheckKeyHeld(modKey.Value))
                {
                    return(true);
                }

                ResetTerrain(pos, toolRadius.Value > 0 ? toolRadius.Value : modifier.GetRadius());

                return(false);
            }
            static bool Prefix(Bed __instance, Humanoid human, bool repeat, ref bool __result, ZNetView ___m_nview)
            {
                if (___m_nview.GetZDO().GetLong("owner", 0L) == Game.instance.GetPlayerProfile().GetPlayerID())
                {
                    return(true);
                }
                if (repeat || !AedenthornUtils.CheckKeyHeld(modKey.Value) || (unclaimedOnly.Value && ___m_nview.GetZDO().GetLong("owner", 0L) != 0))
                {
                    Dbgl($"something's wrong: {repeat} {!AedenthornUtils.CheckKeyHeld(modKey.Value)} {unclaimedOnly.Value && ___m_nview.GetZDO().GetLong("owner", 0L) != 0}");
                    return(true);
                }
                Dbgl($"trying to sleep on bed");

                Player player = human as Player;

                if (!EnvMan.instance.IsAfternoon() && !EnvMan.instance.IsNight())
                {
                    human.Message(MessageHud.MessageType.Center, "$msg_cantsleep", 0, null);
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckEnemies", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckExposure", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckFire", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckWet", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                human.AttachStart(__instance.m_spawnPoint, true, true, "attach_bed", new Vector3(0f, 0.5f, 0f));
                __result = false;
                return(false);
            }
        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)));
                }
            }
        }
Exemple #10
0
            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);
                    }
                }
            }
Exemple #11
0
            static void Prefix(Hud __instance)
            {
                if (!modEnabled.Value || !Player.m_localPlayer)
                {
                    return;
                }

                Vector3 hudPos = new Vector3(hudPosition.Value.x, hudPosition.Value.y, 0);

                if (__instance.m_rootObject.transform.localPosition.x > 1000f)
                {
                    maskObject.SetActive(false);
                    partialObject.SetActive(false);
                    fullObject.SetActive(false);
                    infoObject.SetActive(false);
                    return;
                }
                maskObject.SetActive(true);
                partialObject.SetActive(true);
                fullObject.SetActive(true);
                infoObject.SetActive(true);

                Inventory inv       = Player.m_localPlayer.GetInventory();
                Vector3   weightPos = hudPos + new Vector3(weightOffset.Value.x, weightOffset.Value.y, 0);

                float weight      = inv.GetTotalWeight();
                float totalWeight = Player.m_localPlayer.GetMaxCarryWeight();

                if (fullObject != null)
                {
                    float hudScale = GameObject.Find("GUI").GetComponent <CanvasScaler>().scaleFactor;

                    float maskOffset = (1 - weight / totalWeight) * weightTexture.height * weightScale.Value * hudScale;

                    if (AedenthornUtils.CheckKeyHeld(modKey.Value, true) && Input.GetKeyDown(KeyCode.Mouse0))
                    {
                        Dbgl($"{lastPosition} {hudPos} {Vector3.Distance(lastPosition, hudPos)} {(weightTexture.height + weightTexture.width) / 4f} {maskOffset}");

                        if (Vector3.Distance(Input.mousePosition, hudPos) < (weightTexture.height + weightTexture.width) / 4f * weightScale.Value * hudScale)
                        {
                            Dbgl("dragging start");
                            lastPosition = Input.mousePosition;
                        }
                    }
                    else if (AedenthornUtils.CheckKeyHeld(modKey.Value, true) && Input.GetKey(KeyCode.Mouse0) && Vector3.Distance(lastPosition, weightPos) < (weightTexture.height + weightTexture.width) / 4f * weightScale.Value * hudScale)
                    {
                        hudPos           += Input.mousePosition - lastPosition;
                        hudPosition.Value = new Vector2(hudPos.x, hudPos.y);
                    }
                    lastPosition = Input.mousePosition;

                    partialObject.GetComponent <Image>().color = fillColor.Value;
                    fullObject.GetComponent <Image>().color    = weightColor.Value;

                    maskObject.transform.position    = weightPos - new Vector3(0, maskOffset, 0);
                    partialObject.transform.position = weightPos;
                    fullObject.transform.position    = weightPos;
                }
                if (infoObject != null)
                {
                    infoObject.transform.position = hudPos + new Vector3(infoStringOffset.Value.x, infoStringOffset.Value.y, 0);

                    int  items = inv.GetAllItems().Count;
                    int  slots = inv.GetWidth() * inv.GetHeight() + extraSlots.Value;
                    Text text  = infoObject.GetComponent <Text>();
                    text.text      = string.Format(infoString.Value, items, slots, weight, totalWeight);
                    text.color     = infoStringColor.Value;
                    text.alignment = infoStringAlignment.Value;
                    text.fontSize  = infoStringSize.Value;
                }

                /*
                 *
                 * Rect rect = parentObject.GetComponent<Image>().sprite.rect;
                 * partialObject.transform.parent.GetComponent<RectTransform>().localScale = Vector3.one * weightScale.Value;
                 */
            }
        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;
        }
Exemple #13
0
            static void Postfix(InventoryGui __instance, ItemDrop.ItemData ___m_dragItem, Inventory ___m_dragInventory, int ___m_dragAmount, ref GameObject ___m_dragGo)
            {
                if (AedenthornUtils.CheckKeyHeld(modKey.Value, false) && ___m_dragItem != null && ___m_dragInventory.ContainsItem(___m_dragItem))
                {
                    Dbgl($"Recycling {___m_dragAmount}/{___m_dragItem.m_stack} {___m_dragItem.m_dropPrefab.name}");

                    if (returnResources.Value > 0)
                    {
                        Recipe recipe = ObjectDB.instance.GetRecipe(___m_dragItem);

                        if (recipe != null)
                        {
                            Dbgl($"Recipe stack: {recipe.m_amount} num of stacks: {___m_dragAmount / recipe.m_amount}");
                        }

                        if (recipe != null && ___m_dragAmount / recipe.m_amount > 0)
                        {
                            for (int i = 0; i < ___m_dragAmount / recipe.m_amount; i++)
                            {
                                foreach (Piece.Requirement req in recipe.m_resources)
                                {
                                    int quality = ___m_dragItem.m_quality;
                                    for (int j = quality; j > 0; j--)
                                    {
                                        GameObject        prefab  = ObjectDB.instance.m_items.FirstOrDefault(item => item.GetComponent <ItemDrop>().m_itemData.m_shared.m_name == req.m_resItem.m_itemData.m_shared.m_name);
                                        ItemDrop.ItemData newItem = prefab.GetComponent <ItemDrop>().m_itemData;
                                        int numToAdd = Mathf.RoundToInt(req.GetAmount(j) * returnResources.Value);
                                        Dbgl($"Returning {numToAdd}/{req.GetAmount(j)} {prefab.name}");
                                        while (numToAdd > 0)
                                        {
                                            int stack = Mathf.Min(req.m_resItem.m_itemData.m_shared.m_maxStackSize, numToAdd);
                                            numToAdd -= stack;

                                            if (Player.m_localPlayer.GetInventory().AddItem(prefab.name, stack, req.m_resItem.m_itemData.m_quality, req.m_resItem.m_itemData.m_variant, 0, "") == null)
                                            {
                                                ItemDrop component = Instantiate(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward + Player.m_localPlayer.transform.up, Player.m_localPlayer.transform.rotation).GetComponent <ItemDrop>();
                                                component.m_itemData = newItem.Clone();
                                                component.m_itemData.m_dropPrefab = prefab;
                                                component.m_itemData.m_stack      = stack;
                                                Traverse.Create(component).Method("Save").GetValue();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (___m_dragAmount == ___m_dragItem.m_stack)
                    {
                        Player.m_localPlayer.RemoveFromEquipQueue(___m_dragItem);
                        Player.m_localPlayer.UnequipItem(___m_dragItem, false);
                        ___m_dragInventory.RemoveItem(___m_dragItem);
                    }
                    else
                    {
                        ___m_dragInventory.RemoveItem(___m_dragItem, ___m_dragAmount);
                    }
                    Destroy(___m_dragGo);
                    ___m_dragGo = null;
                    __instance.GetType().GetMethod("UpdateCraftingPanel", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { false });
                }
            }