/// <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);
        }
示例#2
0
 public bool TryDrop(Vector3 pos)
 {
     if (CheckValidToDrop == null || CheckValidToDrop(pos))
     {
         if (dropChance <= 0)
         {
             return(false);
         }
         if (UnityEngine.Random.value <= dropChance)
         {
             if (isChip || (ItemRegistry.GetTypeByID(itemToDrop.id) & ItemType.NONSTACKING) == ItemType.NONSTACKING)
             {
                 if (itemToDrop != null)
                 {
                     itemToDrop.q = 1;
                 }
                 for (int i = 0; i < Mathf.RoundToInt(UnityEngine.Random.value * (maxDropQuantity - minDropQuantity)) + minDropQuantity; i++)
                 {
                     if ((CustomDropBehavior == null || CustomDropBehavior(itemToDrop, pos)) && itemToDrop != null)
                     {
                         GadgetCoreAPI.SpawnItemLocal(pos, itemToDrop, isChip);
                     }
                 }
             }
             else
             {
                 if (itemToDrop != null)
                 {
                     itemToDrop.q = Mathf.RoundToInt(UnityEngine.Random.value * (maxDropQuantity - minDropQuantity)) + minDropQuantity;
                 }
                 if ((CustomDropBehavior == null || CustomDropBehavior(itemToDrop, pos)) && itemToDrop != null)
                 {
                     GadgetCoreAPI.SpawnItemLocal(pos, itemToDrop, isChip);
                 }
             }
             return(true);
         }
     }
     return(false);
 }