Иконка ресурса

FREE DeployableNature : 1.0.26 1.0.26

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Facepunch;
using Facepunch.Utility;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Oxide.Plugins;
using HarmonyLib;
/* Look at adding NPC Talking.When a player interacts with it, it goes to sleep and they loot it, so it can be dressed.* 
 */
/* 1.0.25 changes
 * Updated for July's surprise patch.*/
namespace Oxide.Plugins {
    [Info("DeployableNature", "imthenewguy", "1.0.26")]
    [Description("Makes nature deployable.")]
    class DeployableNature : RustPlugin {
#region Config
        private Configuration config;
        public class Configuration {
            [JsonProperty("Maximum number of rocks that a player can deploy [0 = no limit]")]
            public int max_rocks = 0;
            [JsonProperty("Maximum number of trees that a player can deploy [0 = no limit]")]
            public int max_trees = 0;
            [JsonProperty("Maximum number of bushes that a player can deploy [0 = no limit]")]
            public int max_bushes = 0;
            [JsonProperty("Maximum number of animals that a player can deploy [0 = no limit]")]
            public int max_animals = 3;
            [JsonProperty("Maximum number of furniture that a player can deploy [0 = no limit]")]
            public int max_furniture = 0;
            [JsonProperty("Mining node drop rate [%] - [0 = off]")]
            public int drop_rate_from_node = 1;
            [JsonProperty("Tree drop rate [%] - [0 = off]")]
            public int drop_rate_from_tree = 1;
            [JsonProperty("Animal drop rate [%] - [0 = off]")]
            public int drop_rate_from_animal = 1;
            [JsonProperty("Roll the chance on each hit [false - will only roll once per tree/node/corpse]")]
            public bool roll_chance_on_each_hit = true;
            [JsonProperty("Animals only drop from their corpse type [bear only drops from harvesting bear corpses]?")]
            public bool animal_specific_drops = true;
            [JsonProperty("Prevent wild animals from targeting and killing deployed animals?")]
            public bool prevent_animal_targeting = true;
            [JsonProperty("Collectable plant drop rate [%] - [0 = off]")]
            public int drop_rate_from_collectables = 5;
            [JsonProperty("Chance for loot to be added to a minecart when it spawns [%] - [0 = off]")]
            public int drop_rate_from_minecart = 10;
            [JsonProperty("Allow players to hold sprint while placing a rock to have it embed into the ground?")]
            public bool shift_place = true;
            [JsonProperty("How much deeper should the rock sink when shift-placing?")]
            public float depth_modifier = 0.5f;
            [JsonProperty("Currency to use [SCRAP, ECONOMICS, SR, CUSTOM]")]
            public string currency = "SCRAP";
            [JsonProperty("Custom currency details")]
            public CustomCurrency custom_currency = new CustomCurrency();
            [JsonProperty("Enable players to buy prfabs from the market?")]
            public bool market_enabled = true;
            [JsonProperty("Nature market command")]
            public string[] market_cmds = new string[] {
            }
            ;
            [JsonProperty("How often should the chat message post telling players how to access the deployable nature market? (seconds) 0 = off")]
            public float chat_delay = 600f;
            [JsonProperty("Prevent deployable items from being recycled")]
            public bool prevent_recycling = true;
            [JsonProperty("Display a chat message when a player pulls out a hammer for the first time, reminding them that they can remove deployables")]
            public bool notify_player_with_hammer = false;
            [JsonProperty("Notify how to remove items after first deploy")]
            public bool notify_after_first_Deploy = true;
            [JsonProperty("Allow players to use their middle mouse button to remove an item with a hammer (they can still use chat command regardless if they have perms)")]
            public bool use_input_command = true;
            [JsonProperty("Automatically add new types to the config?")]
            public bool auto_update = false;
            [JsonProperty("Respawn delay when an entity is collected that isnt supposed to be")]
            public float collectible_respawn_delay = 1f;
            [JsonProperty("Kill all deployed nature when the associated cupboard is destroyed?")]
            public bool cupboard_kill = false;
            [JsonProperty("Allow team mates to pickup their members items")]
            public bool team_pickup = true;
            [JsonProperty("Allow TC authed players to pickup items")]
            public bool auth_pickup = true;
            [JsonProperty("Allow DeployableNature to control stack sizes? [Set to false if using a stacks plugin]")]
            public bool manage_stacks = true;
            [JsonProperty("Respawn entities that did not die from being hit")]
            public bool force_respawn_entities = true;
            [JsonProperty("Names of HumanNPCs that will open the market")]
            public List<string> market_npcs = new List<string>();
            [JsonProperty("IDs of HumanNPCs that will open the market")]
            public List<ulong> market_npc_ids = new List<ulong>();
            [JsonProperty("Prevent damage done to entities deployed by an admin, by players who are not admin?")]
            public bool prevent_damage_to_admin_deployed_entities = false;
            [JsonProperty("Kill all DN entities when the associated TC is destroyed?")]
            public bool kill_on_tc_destroy = false;
            [JsonProperty("Permissions that will receive a discount on the store cost when purchasing [1.0 is full price].Prefix with deployablenature.")]
            public Dictionary<string, float> discount_permissions = new Dictionary<string, float>();
            [JsonProperty("Prefab information", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<ulong, ItemInfo> Prefabs = new Dictionary<ulong, ItemInfo>();
            [JsonProperty("Tree prefabs", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<TreeType, TreeInfo> trees = new Dictionary<TreeType, TreeInfo>();
            [JsonProperty("Bush prefabs", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<BushType, BushInfo> bushes = new Dictionary<BushType, BushInfo>();
            public string ToJson() => JsonConvert.SerializeObject(this);
            public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
        }
        protected override void LoadDefaultConfig() {
            config = new Configuration() {
                Prefabs = DefaultPrefabs, trees = DefaultTrees, bushes = DefaultBushes, custom_currency = new CustomCurrency() {
                    name = "cash", skinID = 2661030582, shortname = "blood"
                }
                , discount_permissions = new Dictionary<string, float>() {
                    ["deployablenature.vip"]
                    = 1.0f
                }
            }
            ;
            config.market_cmds = new string[] {
                "naturemarket", "nm"
            }
            ;
        }
        private Dictionary<ulong, ItemInfo> DefaultPrefabs {
            get {
                return new Dictionary<ulong, ItemInfo> {
                    [2609145017]
                    = new ItemInfo(true, "medium clutter rock", "electric.teslacoil", "assets/bundled/prefabs/modding/admin/admin_rock_clutter_medium_d.prefab", 10, true, true, false, 3, 20, PrefabType.Rock, true, 10), [2668227876] = new ItemInfo(true, "small quarry rock", "electric.teslacoil", "assets/bundled/prefabs/modding/admin/admin_rock_quarry_small_a.prefab", 15, true, true, false, 3, 20, PrefabType.Rock, true, 10), [2668228341] = new ItemInfo(true, "small rock formation", "electric.teslacoil", "assets/bundled/prefabs/modding/admin/admin_rock_formation_small_c.prefab", 15, true, true, false, 3, 20, PrefabType.Rock, true, 10), [2668228500] = new ItemInfo(true, "medium rock formation", "electric.teslacoil", "assets/bundled/prefabs/modding/admin/admin_rock_formation_medium_a.prefab", 15, true, true, false, 3, 20, PrefabType.Rock, true, 10), [2668228817] = new ItemInfo(true, "arid medium cliff", "electric.teslacoil", "assets/bundled/prefabs/modding/admin/admin_cliff_medium_arc_arid_small.prefab", 15, true, true, false, 3, 20, PrefabType.Rock, true, 10), [2668228981] = new ItemInfo(true, "large cliff", "electric.teslacoil", "assets/bundled/prefabs/modding/admin/admin_cliff_low_arc.prefab", 15, true, true, false, 3, 20, PrefabType.Rock, true, 10), [2806644689] = new ItemInfo(true, "polar bear", "telephone", "assets/rust.ai/agents/bear/polarbear.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [2806645092] = new ItemInfo(true, "wolf", "telephone", "assets/rust.ai/agents/wolf/wolf.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [2806645210] = new ItemInfo(true, "stag", "telephone", "assets/rust.ai/agents/stag/stag.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [2806645341] = new ItemInfo(true, "chicken", "telephone", "assets/rust.ai/agents/chicken/chicken.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [2806645547] = new ItemInfo(true, "bear", "telephone", "assets/rust.ai/agents/bear/bear.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [2806645796] = new ItemInfo(true, "boar", "telephone", "assets/rust.ai/agents/boar/boar.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [3216966288] = new ItemInfo(true, "horse", "telephone", "assets/rust.ai/agents/horse/horse.prefab", 15, true, true, false, 1, 20, PrefabType.Animal, true, 10), [2668843731] = new ItemInfo(true, "oak tree", "electric.teslacoil", TreeType.Oak, 15, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2668843336] = new ItemInfo(true, "beech tree", "electric.teslacoil", TreeType.Beech, 15, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2668843556] = new ItemInfo(true, "birch tree", "electric.teslacoil", TreeType.Birch, 15, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2668843841] = new ItemInfo(true, "palm tree", "electric.teslacoil", TreeType.Palm, 15, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2668843981] = new ItemInfo(true, "pine tree", "electric.teslacoil", TreeType.Pine, 15, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2668844123] = new ItemInfo(true, "swamp tree", "electric.teslacoil", TreeType.Swamp, 15, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2830312612] = new ItemInfo(true, "cactus", "electric.teslacoil", TreeType.Cacti, 5, true, true, false, 3, 20, PrefabType.Tree, true, 10), [2668860584] = new ItemInfo(true, "creosote bush", "electric.teslacoil", BushType.Creosote, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668861030] = new ItemInfo(true, "snow willow bush", "electric.teslacoil", BushType.Willow_snow, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668861281] = new ItemInfo(true, "willow bush", "electric.teslacoil", BushType.Willow, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668861630] = new ItemInfo(true, "spice bush", "electric.teslacoil", BushType.Spice, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668861850] = new ItemInfo(true, "snow spice bush", "electric.teslacoil", BushType.Spice_snow, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [3027624096] = new ItemInfo(true, "ocotillo bush", "electric.teslacoil", BushType.Ocotillo, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668807382] = new ItemInfo(true, "decorative corn", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/corn/corn-collectable.prefab", 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668906806] = new ItemInfo(true, "decorative pumpkin", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/pumpkin/pumpkin-collectable.prefab", 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668914014] = new ItemInfo(true, "decorative potato", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/potato/potato-collectable.prefab", 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668913894] = new ItemInfo(true, "decorative berries", "electric.teslacoil", BushType.Berries, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2668914545] = new ItemInfo(true, "dect' mushroom", "electric.teslacoil", BushType.Mushrooms, 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [2726178501] = new ItemInfo(true, "dect' hemp plant", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/hemp/hemp-collectable.prefab", 0, true, true, false, 3, 20, PrefabType.Bush, true, 10), [3055146089] = new ItemInfo(true, "halloween wood", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/stone/halloween/halloween-wood-collectable.prefab", 0, true, true, false, 5, 20, PrefabType.Bush, true, 10), [3055146304] = new ItemInfo(true, "halloween metal", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/stone/halloween/halloween-metal-collectable.prefab", 0, true, true, false, 5, 20, PrefabType.Bush, true, 10), [3055146795] = new ItemInfo(true, "halloween stone", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/stone/halloween/halloween-stone-collectable.prefab", 0, true, true, false, 5, 20, PrefabType.Bush, true, 10), [3055147361] = new ItemInfo(true, "halloween sulfur", "electric.teslacoil", "assets/bundled/prefabs/autospawn/collectable/stone/halloween/halloween-sulfur-collectible.prefab", 0, true, true, false, 5, 20, PrefabType.Bush, true, 10), [3027617264] = new ItemInfo(true, "elevator door", "barricade.concrete", "assets/bundled/prefabs/static/door.hinged.elevator_door.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.elevator"), [3027621036] = new ItemInfo(true, "desk - blue", "box.wooden.large", "assets/bundled/prefabs/static/desk_a.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.desk"), [3027620925] = new ItemInfo(true, "desk - red", "box.wooden.large", "assets/bundled/prefabs/static/desk_b.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.desk"), [3027620794] = new ItemInfo(true, "desk - yellow", "box.wooden.large", "assets/bundled/prefabs/static/desk_c.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.desk"), [3027620190] = new ItemInfo(true, "desk - grey", "box.wooden.large", "assets/bundled/prefabs/static/desk_d.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.desk"), [3027621575] = new ItemInfo(true, "control chair", "chair", "assets/bundled/prefabs/static/controlchair.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.chair"), [3027621861] = new ItemInfo(true, "office chair", "chair", "assets/bundled/prefabs/static/chair_a.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.chair"), [3027622087] = new ItemInfo(true, "dining chair", "chair", "assets/bundled/prefabs/static/chair_b.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.chair"), [3027622226] = new ItemInfo(true, "farm chair", "chair", "assets/bundled/prefabs/static/chair_c.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.chair"), [3223954199] = new ItemInfo(true, "cantina chair", "chair", "assets/bundled/prefabs/static/cantina_chair.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.chair"), [3027622334] = new ItemInfo(true, "toilet - chain", "chair", "assets/bundled/prefabs/static/toilet_a.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.toilet"), [3027622773] = new ItemInfo(true, "toilet - normal", "chair", "assets/bundled/prefabs/static/toilet_b.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.toilet"), [3027622962] = new ItemInfo(true, "door table", "box.wooden.large", "assets/bundled/prefabs/static/tabledoor_a.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.table"), [3027623860] = new ItemInfo(true, "door poker table", "box.wooden.large", "assets/bundled/prefabs/static/tabledoor_b.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.table"), [3223953302] = new ItemInfo(true, "lab table 1", "box.wooden.large", "assets/bundled/prefabs/static/lab_table1.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.table"), [3223953450] = new ItemInfo(true, "lab table 2", "box.wooden.large", "assets/bundled/prefabs/static/lab_table2.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.table"), [3223953558] = new ItemInfo(true, "lab table 3", "box.wooden.large", "assets/bundled/prefabs/static/lab_table3.static.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.table"), [3105560624] = new ItemInfo(true, "snow covered tree", "electric.teslacoil", TreeType.Snow, 5, true, true, false, 3, 20, PrefabType.Tree, true, 10), [3105561422] = new ItemInfo(true, "gingerbread house", "barricade.concrete", "assets/content/props/gingerbread_barricades/gingerbread_barricades_house.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.xmas"), [3105562074] = new ItemInfo(true, "gingerbread snowman", "barricade.concrete", "assets/content/props/gingerbread_barricades/gingerbread_barricades_snowman.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.xmas"), [3105562389] = new ItemInfo(true, "gingerbread tree", "barricade.concrete", "assets/content/props/gingerbread_barricades/gingerbread_barricades_tree.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.xmas"), [3105562678] = new ItemInfo(true, "gingerbread crate", "barricade.concrete", "assets/content/props/wooden_crates/wooden_crate_gingerbread.prefab", 20, true, true, false, 3, 10, PrefabType.Furniture, true, 10, "deployablenature.xmas"),
                }
                ;
            }
        }
        private Dictionary<TreeType, TreeInfo> DefaultTrees {
            get {
                return new Dictionary<TreeType, TreeInfo> {
                    [TreeType.Beech]
                    = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_temp_field/american_beech_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field/american_beech_e.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/american_beech_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/american_beech_a_dead.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/american_beech_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/american_beech_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/american_beech_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/american_beech_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/american_beech_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside/american_beech_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside/american_beech_e.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside/american_beech_e_dead.prefab"
                    }
                    ), [TreeType.Birch] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_temp_beachside/birch_small_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_beachside/birch_tiny_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field/birch_small_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field/birch_tiny_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/birch_big_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/birch_large_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest/birch_medium_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/birch_big_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/birch_large_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside/birch_medium_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside/birch_small_temp.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside/birch_tiny_temp.prefab"
                    }
                    ), [TreeType.Oak] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_temp_field/oak_e.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field/oak_f.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field_large/oak_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field_large/oak_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field_large/oak_d.prefab"
                    }
                    ), [TreeType.Palm] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_arid_beachside/palm_tree_short_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_beachside/palm_tree_short_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_beachside/palm_tree_short_c_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_beachside/palm_tree_small_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_beachside/palm_tree_small_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_beachside/palm_tree_small_c_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_field/palm_tree_short_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_field/palm_tree_short_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_field/palm_tree_short_c_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_field/palm_tree_small_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_field/palm_tree_small_c_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forest/palm_tree_med_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forest/palm_tree_short_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forest/palm_tree_short_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forest/palm_tree_short_c_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forest/palm_tree_tall_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forest/palm_tree_tall_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forestside/palm_tree_short_a_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forestside/palm_tree_short_b_entity.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_forestside/palm_tree_short_c_entity.prefab"
                    }
                    ), [TreeType.Pine] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_temp_field/pine_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_field/pine_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/pine_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forest_pine/pine_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside_pine/pine_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_temp_forestside_pine/pine_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_field/pine_dead_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_field/pine_dead_e.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_field/pine_dead_f.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_field_pines/pine_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_field_pines/pine_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_field_pines/pine_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_forest/pine_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_tundra_forest/pine_c.prefab"
                    }
                    ), [TreeType.Swamp] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/swamp-trees/swamp_tree_a.prefab", "assets/bundled/prefabs/autospawn/resource/swamp-trees/swamp_tree_b.prefab", "assets/bundled/prefabs/autospawn/resource/swamp-trees/swamp_tree_c.prefab", "assets/bundled/prefabs/autospawn/resource/swamp-trees/swamp_tree_d.prefab", "assets/bundled/prefabs/autospawn/resource/swamp-trees/swamp_tree_e.prefab", "assets/bundled/prefabs/autospawn/resource/swamp-trees/swamp_tree_f.prefab"
                    }
                    ), [TreeType.Cacti] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-1.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-2.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-3.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-4.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-5.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-6.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arid_cactus/cactus-7.prefab"
                    }
                    ), [TreeType.Snow] = new TreeInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest/pine_a_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forestside/pine_b snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest/pine_c_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forestside/pine_d_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest_saplings/pine_sapling_a_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest_saplings/pine_sapling_b_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest_saplings/pine_sapling_c_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest_saplings/pine_sapling_d_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forestside/pine_sapling_d_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest_saplings/pine_sapling_e_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest/douglas_fir_a_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest/douglas_fir_b_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_arctic_forest/douglas_fir_c_snow.prefab"
                    }
                    )
                }
                ;
            }
        }
        private Dictionary<BushType, BushInfo> DefaultBushes {
            get {
                return new Dictionary<BushType, BushInfo> {
                    [BushType.Creosote]
                    = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_desert/creosote_bush_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_desert/creosote_bush_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_dry/creosote_bush_dry_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_dry/creosote_bush_dry_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_grass/creosote_bush_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_grass/creosote_bush_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_grass/creosote_bush_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_grass/creosote_bush_d.prefab"
                    }
                    ), [BushType.Spice] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_spicebush_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_spicebush_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_spicebush_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_spicebush_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_tundra/bush_spicebush_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_tundra/bush_spicebush_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_tundra/bush_spicebush_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_tundra/bush_spicebush_d.prefab"
                    }
                    ), [BushType.Spice_snow] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic_forest/bush_spicebush_a_snow.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic_forest/bush_spicebush_c_snow.prefab"
                    }
                    ), [BushType.Willow] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_willow_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_willow_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_willow_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_temp/bush_willow_d.prefab"
                    }
                    ), [BushType.Willow_snow] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic/bush_willow_snow_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic/bush_willow_snow_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic/bush_willow_snow_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic/bush_willow_snow_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic/bush_willow_snow_small_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic/bush_willow_snow_small_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic_forest/bush_willow_snow_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic_forest/bush_willow_snow_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic_forest/bush_willow_snow_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arctic_forest/bush_willow_snow_d.prefab"
                    }
                    ), [BushType.Berries] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/collectable/berry-black/berry-black-collectable.prefab", "assets/bundled/prefabs/autospawn/collectable/berry-blue/berry-blue-collectable.prefab", "assets/bundled/prefabs/autospawn/collectable/berry-green/berry-green-collectable.prefab", "assets/bundled/prefabs/autospawn/collectable/berry-red/berry-red-collectable.prefab", "assets/bundled/prefabs/autospawn/collectable/berry-white/berry-white-collectable.prefab", "assets/bundled/prefabs/autospawn/collectable/berry-yellow/berry-yellow-collectable.prefab"
                    }
                    ), [BushType.Mushrooms] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/collectable/mushrooms/mushroom-cluster-5.prefab", "assets/bundled/prefabs/autospawn/collectable/mushrooms/mushroom-cluster-6.prefab"
                    }
                    ), [BushType.Ocotillo] = new BushInfo(new List<string>() {
                        "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_d.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_dry_a.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_dry_b.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_dry_c.prefab", "assets/bundled/prefabs/autospawn/resource/v3_bushes_arid_ocotillo/ocotillo_dry_d.prefab",
                    }
                    ),
                }
                ;
            }
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                config = Config.ReadObject<Configuration>();
                if (!config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys)) {
                    PrintToConsole("Configuration appears to be outdated; updating and saving");
                }
            }
            catch (Exception ex) {
                Debug.LogException(ex);
                LoadDefaultConfig();
            }
        }
        protected override void SaveConfig() {
            PrintToConsole($"Configuration changes saved to {Name}.json");
            Config.WriteObject(config, true);
        }
#endregion
#region Data
        PlayerEntity pcdData;
        private DynamicConfigFile PCDDATA;
        public static DeployableNature Instance;
        void Init() {
            Instance = this;
            PCDDATA = Interface.Oxide.DataFileSystem.GetFile(this.Name);
            permission.RegisterPermission("deployablenature.admin", this);
            permission.RegisterPermission("deployablenature.ignore.restrictions", this);
            permission.RegisterPermission("deployablenature.market.chat", this);
            permission.RegisterPermission("deployablenature.gather", this);
            permission.RegisterPermission("deployablenature.free", this);
            permission.RegisterPermission("deployablenature.use", this);
            //if (!config.cupboard_kill) Unsubscribe("OnEntityDeath");
            var updated = false;
            if (config.market_cmds == null || config.market_cmds.Length == 0) {
                config.market_cmds = new string[] {
                    "naturemarket", "nm"
                }
                ;
            }
            if (config.auto_update) {
                if (UpdateBushes()) updated = true;
                if (UpdateTrees()) updated = true;
                if (UpdateItems()) updated = true;
            }
            foreach (var kvp in config.Prefabs) {
                if (string.IsNullOrEmpty(kvp.Value.permission_required)) continue;
                if (!kvp.Value.permission_required.StartsWith("deployablenature.")) {
                    kvp.Value.permission_required = "deployablenature." + kvp.Value.permission_required;
                    updated = true;
                }
                if (!permission.PermissionExists(kvp.Value.permission_required, this)) permission.RegisterPermission(kvp.Value.permission_required, this);
            }
            if (updated) SaveConfig();
            if (!config.prevent_animal_targeting) Unsubscribe(nameof(OnNpcTarget));
            if (config.drop_rate_from_node == 0 && config.drop_rate_from_animal == 0 && config.drop_rate_from_collectables == 0) {
                Unsubscribe(nameof(OnDispenserBonus));
                Unsubscribe(nameof(OnDispenserGather));
            }
            else if (config.roll_chance_on_each_hit) Unsubscribe(nameof(OnDispenserBonus));
        }
        bool UpdateBushes() {
            var result = false;
            foreach (var def in DefaultBushes) {
                if (!config.bushes.ContainsKey(def.Key)) {
                    config.bushes.Add(def.Key, def.Value);
                    Puts($"Added new bush type: {def.Key}");
                    result = true;
                }
                else {
                    foreach (var path in def.Value.prefabs) {
                        if (!config.bushes[def.Key].prefabs.Contains(path)) {
                            config.bushes[def.Key].prefabs.Add(path);
                            Puts($"Added new bush to {def.Key}: {path}");
                            result = true;
                        }
                    }
                }
            }
            return result;
        }
        bool UpdateTrees() {
            var result = false;
            foreach (var def in DefaultTrees) {
                if (!config.trees.ContainsKey(def.Key)) {
                    config.trees.Add(def.Key, def.Value);
                    Puts($"Added new tree type: {def.Key}");
                    result = true;
                }
                else {
                    foreach (var path in def.Value.prefabs) {
                        if (!config.trees[def.Key].prefabs.Contains(path)) {
                            config.trees[def.Key].prefabs.Add(path);
                            Puts($"Added new tree to {def.Key}: {path}");
                            result = true;
                        }
                    }
                }
            }
            return result;
        }
        bool UpdateItems() {
            var result = false;
            foreach (var def in DefaultPrefabs) {
                if (!config.Prefabs.ContainsKey(def.Key)) {
                    config.Prefabs.Add(def.Key, def.Value);
                    result = true;
                    Puts($"Added new item: {def.Value.displayName}[{def.Key}]");
                }
            }
            return result;
        }
        void Unload() {
            foreach (var _command in config.market_cmds) cmd.RemoveChatCommand(_command, this);
            SaveData();
            foreach (var player in BasePlayer.activePlayerList) {
                CuiHelper.DestroyUi(player, "NatureMarket");
                CuiHelper.DestroyUi(player, "MenuBackPanel");
            }
#if CARBON
            _harmony.UnpatchAll(Name + "Patch");
#endif
        }
#if CARBON
        private Harmony _harmony;
#endif
        void Loaded() {
            LoadData();
#if CARBON
            _harmony = new Harmony(Name + "Patch");
            _harmony.PatchAll();
#endif
        }
        void SaveData() {
            PCDDATA.WriteObject(pcdData);
        }
        void LoadData() {
            try {
                pcdData = Interface.Oxide.DataFileSystem.ReadObject<PlayerEntity>(this.Name);
            }
            catch {
                Puts("Couldn't load player data, creating new Playerfile");
                pcdData = new PlayerEntity();
            }
        }
        class PlayerEntity {
            public Dictionary<ulong, PCDInfo> pEntity = new Dictionary<ulong, PCDInfo>();
            public Dictionary<ulong, PrefabInfo> rEntity = new Dictionary<ulong, PrefabInfo>();
            public bool purgeEnabled = false;
        }
        public class CustomCurrency {
            public string name = null;
            public ulong skinID = 0;
            public string shortname = null;
        }
        class PCDInfo {
            public int deployed_rocks;
            public int deployed_trees;
            public int deployed_bushes;
            public int deployed_animals;
            public int deployed_furniture;
        }
        class PrefabInfo {
            public bool AuthDamageOnly;
            public int hits_taken;
            public int max_hits;
            public ulong skinID;
            public bool prevent_gather;
            public PrefabType type;
            public ulong ownerID;
            public Vector3 loc;
            public Vector3 rot;
            public string path;
            public ulong tool_cupboard_id;
            public bool admin_deployed = false;
            public bool deployedOnTugboat = false;
        }
        public class ItemInfo {
            public bool enabled;
            public string displayName;
            public string item_shortname;
            public string prefab_path;
            public int prefab_durability;
            public bool TCAuthRequired;
            public bool canBePickedUp;
            public bool authDamageOnly;
            public int max_spawn_quantity;
            public int max_stack_size;
            public PrefabType prefab_type;
            public bool prevent_gather;
            public TreeType treeType = TreeType.None;
            public BushType bushType = BushType.None;
            public double market_price;
            public string permission_required;
            [JsonConstructor]
            public ItemInfo() {
            }
            public ItemInfo(bool enabled, string displayName, string item_shortname, string prefab_path, int prefab_durability, bool TCAuthRequired, bool canBePickedUp, bool authDamageOnly, int max_spawn_quantity, int max_stack_size, PrefabType prefab_type, bool prevent_gather, float market_price, string permission_required = null) {
                this.enabled = enabled;
                this.displayName = displayName;
                this.item_shortname = item_shortname;
                this.prefab_path = prefab_path;
                this.prefab_durability = prefab_durability;
                this.TCAuthRequired = TCAuthRequired;
                this.canBePickedUp = canBePickedUp;
                this.authDamageOnly = authDamageOnly;
                this.max_spawn_quantity = max_spawn_quantity;
                this.max_stack_size = max_stack_size;
                this.prefab_type = prefab_type;
                this.prevent_gather = prevent_gather;
                this.market_price = market_price;
                this.permission_required = permission_required;
            }
            public ItemInfo(bool enabled, string displayName, string item_shortname, TreeType treeType, int prefab_durability, bool TCAuthRequired, bool canBePickedUp, bool authDamageOnly, int max_spawn_quantity, int max_stack_size, PrefabType prefab_type, bool prevent_gather, float market_price, string permission_required = null) {
                this.enabled = enabled;
                this.displayName = displayName;
                this.item_shortname = item_shortname;
                this.treeType = treeType;
                this.prefab_durability = prefab_durability;
                this.TCAuthRequired = TCAuthRequired;
                this.canBePickedUp = canBePickedUp;
                this.authDamageOnly = authDamageOnly;
                this.max_spawn_quantity = max_spawn_quantity;
                this.max_stack_size = max_stack_size;
                this.prefab_type = prefab_type;
                this.prevent_gather = prevent_gather;
                this.market_price = market_price;
                this.permission_required = permission_required;
            }
            public ItemInfo(bool enabled, string displayName, string item_shortname, BushType bushType, int prefab_durability, bool TCAuthRequired, bool canBePickedUp, bool authDamageOnly, int max_spawn_quantity, int max_stack_size, PrefabType prefab_type, bool prevent_gather, float market_price, string permission_required = null) {
                this.enabled = enabled;
                this.displayName = displayName;
                this.item_shortname = item_shortname;
                this.bushType = bushType;
                this.prefab_durability = prefab_durability;
                this.TCAuthRequired = TCAuthRequired;
                this.canBePickedUp = canBePickedUp;
                this.authDamageOnly = authDamageOnly;
                this.max_spawn_quantity = max_spawn_quantity;
                this.max_stack_size = max_stack_size;
                this.prefab_type = prefab_type;
                this.prevent_gather = prevent_gather;
                this.market_price = market_price;
                this.permission_required = permission_required;
            }
        }
        public class TreeInfo {
            public List<string> prefabs = new List<string>();
            public TreeInfo(List<string> prefabs) {
                this.prefabs = prefabs;
            }
        }
        public class BushInfo {
            public List<string> prefabs = new List<string>();
            public BushInfo(List<string> prefabs) {
                this.prefabs = prefabs;
            }
        }
        public enum PrefabType {
            Rock, Tree, Bush, Animal, Furniture
        }
        public enum TreeType {
            None, Palm, Oak, Swamp, Birch, Beech, Pine, Cacti, Snow
        }
        public enum BushType {
            None, Willow, Willow_snow, Spice, Spice_snow, Creosote, Berries, Mushrooms, Ocotillo
        }
        public string Prefix;
        public Dictionary<ulong, ItemInfo> loot_table_rocks = new Dictionary<ulong, ItemInfo>();
        public Dictionary<ulong, ItemInfo> loot_table_animals = new Dictionary<ulong, ItemInfo>();
        public Dictionary<ulong, ItemInfo> loot_table_trees = new Dictionary<ulong, ItemInfo>();
        public Dictionary<ulong, ItemInfo> loot_table_bushes = new Dictionary<ulong, ItemInfo>();
        public Dictionary<ulong, ItemInfo> loot_table_furniture = new Dictionary<ulong, ItemInfo>();
        public Dictionary<TreeType, List<string>> trees = new Dictionary<TreeType, List<string>>();
#endregion;
#region Localization
        protected override void LoadDefaultMessages() {
            lang.RegisterMessages(new Dictionary<string, string> {
                ["Prefix"]
                = "<color=#DFF008>[DN]</color>", ["WarnMarketCooldown"] = "{0} Please wait a second before buying another item.", ["NoPickup"] = "{0} You cannot collect this entity as it is decorative.", ["NoGather"] = "{0} You cannot gather from this entity as it is decorative.", ["PlacementLimit"] = "{0} You have reached your placement limit for this item type.", ["BuildAuthReq"] = "{0} You must have building auth in order to deploy this item.", ["NP"] = "{0} You cannot pick this entity up.", ["WP"] = "{0} Please wait a second before picking up another entity.", ["GiveItem"] = "{0} You Received {1}x {2}.", ["NotifyConsoleInvalid"] = "{0} Invalid skin: {1}.A list of valid keys has been printed to console.", ["NotifyOfConsole"] = "{0} Usage: /giveprefab <skin id> <optional: quantity>\nA list of valid keys has been printed to console.", ["NotifyInConsole"] = "{0}", ["NEC"] = "{0} You do not have enough {1} to purchase {2}x {3}.", ["broadcastmsg"] = "{0} You can type <color=#51ff00>/{1}</color> to access the Nature Market and purchase deployable nature items.", ["itemDisabled"] = "{0} This item has been disabled.", ["dnkillentities"] = "Removed all deployable nature entities", ["dnkillentitiesdata"] = "Removed all deployable nature entities and cleared data.", ["NoUsePerms"] = "You do not have permission to use Deployable Nature items.", ["PickupNotify"] = "You can collect your deployable nature items by looking a
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху