Example #1
0
        private void Process(ClientEquipmentRemoveItem msg)
        {
            var owner = GuidHelper.Find(msg.ownerGuid);

            if (owner == null)
            {
                FindRemoteInventory(msg.ownerGuid)?.Remove(msg.itemGuid);
                return;
            }

            var pickupable = GuidHelper.FindComponent <Pickupable>(msg.itemGuid);

            if (pickupable != null)
            {
                var equipment = Helpers.GetEquipment(owner);
                if (equipment != null)
                {
                    var itemsBySlot   = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                    var inventoryItem = itemsBySlot[msg.slot];
                    itemsBySlot[msg.slot] = null;

                    equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), false });
                    Equipment.SendEquipmentEvent(pickupable, 1, owner, msg.slot);                     // unequip event is = 1
                    equipment.ReflectionCall("NotifyUnequip", false, false, new object[] { msg.slot, inventoryItem });
                }
            }

            UnityEngine.Object.Destroy(pickupable.gameObject);
        }
Example #2
0
        private void Process(Client client, ClientEquipmentRemoveItem msg)
        {
            var equipment = state.history.equipment.GetOrAddNew(msg.ownerGuid);

            equipment.slots.Remove(msg.slot);

            SendToAll(client.peer, msg);
        }
Example #3
0
        public static void Unequip(Pickupable pickupable, GameObject owner, string slot)
        {
            if (Multiplayer.main.blocked)
            {
                return;
            }

            var res = new ClientEquipmentRemoveItem();

            res.ownerGuid = GuidHelper.Get(owner);
            res.itemGuid  = GuidHelper.Get(pickupable.gameObject);
            res.slot      = slot;
            res.position  = owner.transform.position;

            Multiplayer.main.Send(res);
        }