private void Process(Client client, ClientEquipmentAddItem msg) { var equipment = state.history.equipment.GetOrAddNew(msg.ownerGuid); equipment.slots[msg.slot] = msg; SendToAll(client.peer, msg); }
public static void Equip(Pickupable pickupable, GameObject owner, string slot) { if (Multiplayer.main.blocked) { return; } var res = new ClientEquipmentAddItem(); res.ownerGuid = GuidHelper.Get(owner); res.itemGuid = GuidHelper.Get(pickupable.gameObject); res.slot = slot; res.position = owner.transform.position; res.data = ObjectSerializer.GetBytes(pickupable.gameObject, true); if (res.data == null) { return; } Multiplayer.main.Send(res); }
private void Process(ClientEquipmentAddItem msg) { var owner = GuidHelper.Find(msg.ownerGuid); if (owner == null) { FindRemoteInventory(msg.ownerGuid)?.Add(msg.itemGuid, msg.data); return; } var gameObject = ObjectSerializer.GetGameObject(msg.data); var pickupable = gameObject.GetComponent <Pickupable>(); GuidHelper.Set(gameObject, msg.itemGuid); var equipment = Helpers.GetEquipment(owner); if (equipment == null) { Log.Info("Couldn't find equipment: " + msg.ownerGuid); return; } using (new MessageBlocker()) { var inventoryItem = new InventoryItem(pickupable); inventoryItem.container = equipment; inventoryItem.item.Reparent(equipment.tr); var itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment"); itemsBySlot[msg.slot] = inventoryItem; equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true }); Equipment.SendEquipmentEvent(pickupable, 0, owner, msg.slot); // equip event is = 0 equipment.ReflectionCall("NotifyEquip", false, false, new object[] { msg.slot, inventoryItem }); } }