예제 #1
0
        private void Update()
        {
            if (!NetworkServer.active || !IsMaster)
            {
                return;
            }

            // TODO(kookehs): Needs to be optimized.
            foreach (ItemIcon itemIcon in Api.GetItemIcons())
            {
                if (itemIcon.GetComponent <DropItemHandler>() == null)
                {
                    DropItemHandler dropItemHandler = itemIcon.transform.gameObject.AddComponent <DropItemHandler>();
                    dropItemHandler.ItemIndex = itemIcon.ItemIndex;
                    dropItemHandler.Inventory = itemIcon.rectTransform.parent.GetComponent <ItemInventoryDisplay>().Inventory;
                }
            }

            foreach (EquipmentIcon equipmentIcon in Api.GetEquipmentIcons())
            {
                if (equipmentIcon.GetComponent <DropItemHandler>() == null)
                {
                    if (equipmentIcon.targetEquipmentSlot == null || equipmentIcon.targetEquipmentSlot.equipmentIndex == EquipmentIndex.None)
                    {
                        return;
                    }
                    DropItemHandler dropItemHandler = equipmentIcon.transform.gameObject.AddComponent <DropItemHandler>();
                    dropItemHandler.EquipmentIndex = equipmentIcon.targetEquipmentSlot.equipmentIndex;
                    dropItemHandler.Inventory      = equipmentIcon.targetInventory;
                }
            }
        }
예제 #2
0
 public void OnStart()
 {
     RootObject = new GameObject("DropItemsMod");
     Object.DontDestroyOnLoad(RootObject);
     DropItemHandler          = RootObject.AddComponent <DropItemHandler>();
     DropItemHandler.IsMaster = true;
     Debug.Log("Loaded DropItemsMod");
 }