Example #1
0
        public void OnDrop(Inventory inv, bool tss, int slot, int amount, bool dbui, Vector3?pos)
        {
            if ((inv.interactiable & InventoryController.DropInvFlags) != InventoryController.DropInvFlags)
            {
                return;
            }

            if (optionalOnDropBehaviour == null)
            {
                InventoryHandler.DropItemEventArgs dea = new InventoryHandler.DropItemEventArgs(inv, tss, slot, this, amount, dbui, pos.GetValueOrDefault(), true);

                InventoryHandler.current.Broadcast(BroadcastEventType.DropItem, dea: dea);
            }
            else
            {
                InventoryHandler.DropItemEventArgs dea = new InventoryHandler.DropItemEventArgs(inv, tss, slot, this, amount, dbui, pos.GetValueOrDefault(), false);
                object[] tmp = new object[2] {
                    this, dea
                };

                BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;

                MethodInfo monoMethod = optionalOnDropBehaviour.GetClass().GetMethod("OnDropItem", flags);

                if (monoMethod == null)
                {
                    Debug.LogError($"The script provided ({optionalOnDropBehaviour.name}) on item {itemName} does not contain, or its not accesible, the expected function OnDropItem.\n Check if this function exists and if the provided script derives from DropBehaviour");
                }
                else
                {
                    monoMethod.Invoke(Activator.CreateInstance(optionalOnDropBehaviour.GetClass()), tmp);
                }
            }
        }
 public abstract void OnDropItem(object sender, InventoryHandler.DropItemEventArgs e);