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);
            });
        }
Example #2
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);
        }