/// <summary> /// Spawns this entity's drops locally. /// </summary> protected virtual void DropLocal() { GadgetCoreAPI.SpawnExp(transform.position, EXP); foreach (Tuple <int, int, int> currencyDrop in currencyDrops) { int quantity = currencyDrop.Item2 + UnityEngine.Random.Range(0, currencyDrop.Item3 + 1); if (quantity > 0) { GadgetCoreAPI.SpawnItemLocal(transform.position, new Item(currencyDrop.Item1, quantity, 0, 0, 0, new int[3], new int[3])); } } if (vanillaStyleDrops != null) { int num = UnityEngine.Random.Range(0, 100); int num2 = UnityEngine.Random.Range(0, 90); num2 += (int)(PlayerGearModsTracker.GetGearMods(FindObjectsOfType <PlayerScript>().MinBy(x => (x.transform.position - transform.position).sqrMagnitude))[21] * 1.5); int num3 = 1; if (num2 > 110) { num3 = 5; } else if (num2 > 100) { num3 = 4; } else if (num2 > 90) { num3 = 3; } else if (num2 > 80) { num3 = 2; } Item vanillaDrop = new Item(num < 20 ? vanillaStyleDrops[2] : num < 45 ? vanillaStyleDrops[1] : num < 75 ? vanillaStyleDrops[0] : vanillaStyleDrops[3], num3, 0, 0, 0, new int[3], new int[3]); if (vanillaDrop.id > 0) { GadgetCoreAPI.SpawnItemLocal(transform.position, vanillaDrop); } } LootTables.DropLoot(LootTableID, transform.position); }
/// <summary> /// Adds an item to this entity's loot table. /// </summary> public void AddLootTableDrop(Item item, float dropChance, int minDropQuantity, int maxDropQuantity = -1, Func <Vector3, bool> CheckValidToDrop = null, Func <Item, Vector3, bool> CustomDropBehavior = null) { LootTables.AddItemToLootTable(item, LootTableID, dropChance, minDropQuantity, maxDropQuantity, CheckValidToDrop, CustomDropBehavior); }