Exemplo n.º 1
0
    public void SetThirst(int multiplier)
    {
        multiplier *= -1;
        float adjustedRate;

        if (multiplier != 0)
        {
            adjustedRate = (multiplier > 0) ? (defaultThirstRate / multiplier) : (defaultThirstRate * (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedRate = defaultThirstRate;
        }
        Stat_Thirst thirst = network.GetLocalPlayer().Stats.stat_thirst;

        PrivateValueAccessor.GetPrivateFieldInfo(typeof(Stat_Thirst), "thirstLostPerSecondDefault").SetValue(thirst, adjustedRate);
        RConsole.Log(modPrefix + "Thirst rate set.");
    }
Exemplo n.º 2
0
    public void SetSharkAttackInterval(int multiplier)
    {
        var   sharks = FindObjectsOfType <Shark>();
        float adjustedInterval;

        if (multiplier != 0)
        {
            adjustedInterval = (multiplier > 0) ? (defaultBiteRaftInterval * multiplier) : (defaultBiteRaftInterval / (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedInterval = defaultBiteRaftInterval;
        }
        foreach (Shark shark in sharks)
        {
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Shark), "searchBlockInterval").SetValue(shark, adjustedInterval);
        }
        RConsole.Log(modPrefix + "Shark bite raft interval set.");
    }
Exemplo n.º 3
0
    public void SetHunger(int multiplier)
    {
        multiplier *= -1;
        float adjustedRate;

        if (multiplier != 0)
        {
            adjustedRate = (multiplier > 0) ? (defaultHungerRate / multiplier) : (defaultHungerRate * (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedRate = defaultHungerRate;
        }
        var hunger = network.GetLocalPlayer().Stats.stat_hunger;

        PrivateValueAccessor.GetPrivateFieldInfo(typeof(Stat_Hunger), "hungerLostPerSecondDefault").SetValue(hunger.Bonus, adjustedRate);
        PrivateValueAccessor.GetPrivateFieldInfo(typeof(Stat_Hunger), "hungerLostPerSecondDefault").SetValue(hunger.Normal, adjustedRate);
        RConsole.Log(modPrefix + "Hunger rate set.");
    }
Exemplo n.º 4
0
    public void SetSharkAttackDamage(int multiplier)
    {
        var sharks = FindObjectsOfType <Shark>();
        int adjustedRaftDamage, adjustedPlayerDamage;

        if (multiplier != 0)
        {
            adjustedRaftDamage   = (multiplier > 0) ? (defaultSharkDamageRaft / multiplier) : (defaultSharkDamageRaft * (Math.Abs(multiplier) + 1));
            adjustedPlayerDamage = (multiplier > 0) ? (defaultSharkDamagePerson / multiplier) : (defaultSharkDamagePerson * (Math.Abs(multiplier) + 1));
        }
        else
        {
            adjustedRaftDamage   = defaultSharkDamageRaft;
            adjustedPlayerDamage = defaultSharkDamagePerson;
        }
        foreach (Shark shark in sharks)
        {
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Shark), "biteRaftDamage").SetValue(shark, adjustedRaftDamage);
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Shark), "attackPlayerDamage").SetValue(shark, adjustedPlayerDamage);
        }
        RConsole.Log(modPrefix + "Shark damage set.");
    }
Exemplo n.º 5
0
    public void SetDurability(int multiplier)
    {
        List <Item_Base> items = ItemManager.GetAllItems();

        foreach (var item in items)
        {
            int defaultSize = defaultMaxUses[item.UniqueIndex];
            int adjustedSize;
            if (defaultSize <= 1)
            {
                continue;
            }                                   // Avoid changing durability of items that "dont have" durability (like cups)
            if (multiplier != 0)
            {
                adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
            }
            else
            {
                adjustedSize = defaultSize;
            }
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(Item_Base), "maxUses").SetValue(item, adjustedSize);
        }
        RConsole.Log(modPrefix + "Durability multiplier set.");
    }
Exemplo n.º 6
0
    public void SetStackSize(int multiplier)
    {
        List <Item_Base> items = ItemManager.GetAllItems();

        // Change base object
        foreach (var item in items)
        {
            int defaultSize = defaultStackSizes[item.UniqueIndex];
            if (defaultSize <= 1)
            {
                continue;
            }                                   // Avoid changing stack size of items that shouldn't stack (like cups)
            int adjustedSize;
            if (multiplier != 0)
            {
                adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
            }
            else
            {
                adjustedSize = defaultSize;
            }
            ItemInstance_Inventory inventory = item.settings_Inventory;
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(ItemInstance_Inventory), "stackSize").SetValue(inventory, adjustedSize);
        }
        RConsole.Log(modPrefix + "BaseItem stack size set.");

        // Change items in players inventory
        foreach (Slot slot in network.GetLocalPlayer().Inventory.allSlots)
        {
            if (!slot.HasValidItemInstance())
            {
                continue;
            }

            Item_Base item        = slot.itemInstance.baseItem;
            int       defaultSize = defaultStackSizes[item.UniqueIndex];
            if (defaultSize <= 1)
            {
                continue;
            }                                   // Avoid changing stack size of items that shouldn't stack (like cups)
            int adjustedSize;
            if (multiplier != 0)
            {
                adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
            }
            else
            {
                adjustedSize = defaultSize;
            }
            ItemInstance_Inventory settings = slot.itemInstance.settings_Inventory;
            PrivateValueAccessor.GetPrivateFieldInfo(typeof(ItemInstance_Inventory), "stackSize").SetValue(settings, adjustedSize);
        }
        RConsole.Log(modPrefix + "Inventory items stack size set.");

        // Change items in storage boxes
        foreach (var storage in StorageManager.allStorages)
        {
            foreach (var slot in storage.GetInventoryReference().allSlots)
            {
                if (!slot.HasValidItemInstance())
                {
                    continue;
                }

                Item_Base item        = slot.itemInstance.baseItem;
                int       defaultSize = defaultStackSizes[item.UniqueIndex];
                if (defaultSize <= 1)
                {
                    continue;
                }                                   // Avoid changing stack size of items that shouldn't stack (like cups)
                int adjustedSize;
                if (multiplier != 0)
                {
                    adjustedSize = (multiplier > 0) ? (defaultSize * multiplier) : (defaultSize / (Math.Abs(multiplier) + 1));
                }
                else
                {
                    adjustedSize = defaultSize;
                }
                ItemInstance_Inventory settings = slot.itemInstance.settings_Inventory;
                PrivateValueAccessor.GetPrivateFieldInfo(typeof(ItemInstance_Inventory), "stackSize").SetValue(settings, adjustedSize);
            }
        }
        RConsole.Log(modPrefix + "Storage items stack size set.");
    }