private static void DropItemCommand(ConCommandArgs args)
        {
            var itemName  = args.GetArgString(0);
            var itemIndex = ItemNameToIndex(itemName);

            if (itemIndex == ItemIndex.None)
            {
                Console.print("Can't find item specified");
                return;
            }

            var count = args.TryGetArgInt(1) ?? 1;

            KookehsDropItemMod.Logger.LogDebug("Item index: " + itemIndex);

            var master = args.GetSenderMaster();

            var inventory     = master.inventory;
            var charTransform = master.GetBody().GetFieldValue <Transform>("transform");

            for (int i = 0; i < count; i++)
            {
                DropItemHandler.DropItem(charTransform, inventory, PickupCatalog.FindPickupIndex(itemIndex));
            }
        }
        private static void DropEquipCommand(ConCommandArgs args)
        {
            //Actual code here
            var master = args.GetSenderMaster();

            var inventory     = master.inventory;
            var charTransform = master.GetBody().GetFieldValue <Transform>("transform");

            DropItemHandler.DropItem(charTransform, inventory, PickupCatalog.FindPickupIndex(inventory.GetEquipmentIndex()));
        }
        public KookehsDropItemMod()
        {
            var miniRpc = MiniRpc.CreateInstance(ModGuid);

            DropItemCommand = miniRpc.RegisterAction(Target.Server, (NetworkUser user, DropItemMessage dropItemMessage) => {
                var master = user.master;
                if (master == null)
                {
                    return;
                }

                var body          = master.GetBody();
                var inventory     = master.inventory;
                var charTransform = body.GetFieldValue <Transform>("transform");

                var pickupIndex = dropItemMessage.IsItem
                                        ? new PickupIndex(dropItemMessage.ItemIndex)
                                        : new PickupIndex(dropItemMessage.EquipmentIndex);

                DropItemHandler.DropItem(charTransform, inventory, pickupIndex);
                DropItemHandler.CreateNotification(body, charTransform, pickupIndex);
            });
        }
Esempio n. 4
0
        public void OnReceived()
        {
            if (!NetworkServer.active)
            {
                return;
            }

            Log("Received kookeh drop message");
            Log("NetworkID" + netId.ToString());
            Log("PickupIndex" + this.pickupIndex.ToString());

            var bodyObject = Util.FindNetworkObject(netId);

            var body = bodyObject.GetComponent <CharacterBody>();

            Log("Body is null: " + (body == null).ToString());

            var inventory     = body.master.inventory;
            var charTransform = body.GetFieldValue <Transform>("transform");

            DropItemHandler.DropItem(charTransform, inventory, pickupIndex);
            DropItemHandler.CreateNotification(body, charTransform, pickupIndex);
        }