Esempio n. 1
0
        // Token: 0x06002845 RID: 10309 RVA: 0x000F3DC0 File Offset: 0x000F21C0
        private void spawnItem(byte x, byte y, ushort id, byte amount, byte quality, byte[] state, Vector3 point, uint instanceID)
        {
            ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, id);

            if (itemAsset != null)
            {
                Transform transform = new GameObject().transform;
                transform.name               = id.ToString();
                transform.transform.parent   = LevelItems.models;
                transform.transform.position = point;
                Transform item = ItemTool.getItem(id, 0, quality, state, false, itemAsset, null);
                item.parent = transform;
                InteractableItem interactableItem = item.gameObject.AddComponent <InteractableItem>();
                interactableItem.item  = new Item(id, amount, quality, state);
                interactableItem.asset = itemAsset;
                item.position          = point + Vector3.up * 0.75f;
                item.rotation          = Quaternion.Euler((float)(-90 + UnityEngine.Random.Range(-15, 15)), (float)UnityEngine.Random.Range(0, 360), (float)UnityEngine.Random.Range(-15, 15));
                item.gameObject.AddComponent <Rigidbody>();
                item.GetComponent <Rigidbody>().interpolation          = RigidbodyInterpolation.Interpolate;
                item.GetComponent <Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Discrete;
                item.GetComponent <Rigidbody>().drag        = 0.5f;
                item.GetComponent <Rigidbody>().angularDrag = 0.1f;
                if (LevelObjects.loads[(int)x, (int)y] != -1)
                {
                    item.GetComponent <Rigidbody>().useGravity  = false;
                    item.GetComponent <Rigidbody>().isKinematic = true;
                }
                ItemDrop item2 = new ItemDrop(transform, interactableItem, instanceID);
                ItemManager.regions[(int)x, (int)y].drops.Add(item2);
                if (ItemManager.onItemDropAdded != null)
                {
                    ItemManager.onItemDropAdded(item, interactableItem);
                }
            }
        }
Esempio n. 2
0
 // Token: 0x0600284D RID: 10317 RVA: 0x000F4A3C File Offset: 0x000F2E3C
 private void onRegionActivated(byte x, byte y)
 {
     if (ItemManager.regions != null && ItemManager.regions[(int)x, (int)y] != null)
     {
         for (int i = 0; i < ItemManager.regions[(int)x, (int)y].drops.Count; i++)
         {
             ItemDrop itemDrop = ItemManager.regions[(int)x, (int)y].drops[i];
             if (itemDrop != null && !(itemDrop.interactableItem == null))
             {
                 Rigidbody component = itemDrop.interactableItem.GetComponent <Rigidbody>();
                 if (!(component == null))
                 {
                     component.useGravity  = true;
                     component.isKinematic = false;
                 }
             }
         }
     }
 }
Esempio n. 3
0
 // Token: 0x0600283D RID: 10301 RVA: 0x000F35E4 File Offset: 0x000F19E4
 public static void getItemsInRadius(Vector3 center, float sqrRadius, List <RegionCoordinate> search, List <InteractableItem> result)
 {
     if (ItemManager.regions == null)
     {
         return;
     }
     for (int i = 0; i < search.Count; i++)
     {
         RegionCoordinate regionCoordinate = search[i];
         if (ItemManager.regions[(int)regionCoordinate.x, (int)regionCoordinate.y] != null)
         {
             for (int j = 0; j < ItemManager.regions[(int)regionCoordinate.x, (int)regionCoordinate.y].drops.Count; j++)
             {
                 ItemDrop itemDrop = ItemManager.regions[(int)regionCoordinate.x, (int)regionCoordinate.y].drops[j];
                 if ((itemDrop.model.position - center).sqrMagnitude < sqrRadius)
                 {
                     result.Add(itemDrop.interactableItem);
                 }
             }
         }
     }
 }