public void BroadcastUnequip(Pickupable pickupable, GameObject owner, string slot) { NitroxId itemId = NitroxEntity.GetId(pickupable.gameObject); Player player = owner.GetComponent <Player>(); if (player != null) { TechType techType = pickupable.GetTechType(); PlayerEquipmentRemoved equipmentAdded = new PlayerEquipmentRemoved(techType.ToDto(), itemId); packetSender.Send(equipmentAdded); return; } NitroxId ownerId = NitroxEntity.GetId(owner); if (pickupable.GetTechType() == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerId, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } ModuleRemoved moduleRemoved = new ModuleRemoved(ownerId, slot, itemId); packetSender.Send(moduleRemoved); }
public void BroadcastEquip(Pickupable pickupable, GameObject owner, string slot) { NitroxId ownerId = NitroxEntity.GetId(owner); NitroxId itemId = NitroxEntity.GetId(pickupable.gameObject); TechType techType = pickupable.GetTechType(); if (techType == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerId, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } Transform parent = pickupable.gameObject.transform.parent; pickupable.gameObject.transform.SetParent(null); byte[] bytes = SerializationHelper.GetBytes(pickupable.gameObject); EquippedItemData equippedItem = new EquippedItemData(ownerId, itemId, bytes, slot, techType.ToDto()); Player player = owner.GetComponent <Player>(); if (player != null) { PlayerEquipmentAdded equipmentAdded = new PlayerEquipmentAdded(techType.ToDto(), equippedItem); packetSender.Send(equipmentAdded); pickupable.gameObject.transform.SetParent(parent); return; } ModuleAdded moduleAdded = new ModuleAdded(equippedItem); packetSender.Send(moduleAdded); pickupable.gameObject.transform.SetParent(parent); }
public void BroadcastEquip(Pickupable pickupable, GameObject owner, string slot) { string ownerGuid = GuidHelper.GetGuid(owner); string itemGuid = GuidHelper.GetGuid(pickupable.gameObject); // save current parent to prevent infinite oxygen when tank equipped above water #290 Transform parent = pickupable.gameObject.transform.parent; // set pickupable parent to null to prevent deserialized function throwing errors when packet get to other players pickupable.gameObject.transform.SetParent(null); byte[] bytes = SerializationHelper.GetBytes(pickupable.gameObject); if (pickupable.GetTechType() == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerGuid, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } EquippedItemData equippedItem = new EquippedItemData(ownerGuid, itemGuid, bytes, slot); Player player = owner.GetComponent <Player>(); bool isPlayerEquipment = (player != null); EquipmentAddItem equipPacket = new EquipmentAddItem(equippedItem, isPlayerEquipment); packetSender.Send(equipPacket); // re-assign parent to prevent infinite oxygen #290 pickupable.gameObject.transform.SetParent(parent); }
public void BroadcastEquip(Pickupable pickupable, GameObject owner, string slot) { string ownerGuid = GuidHelper.GetGuid(owner); string itemGuid = GuidHelper.GetGuid(pickupable.gameObject); pickupable.gameObject.transform.SetParent(null); // On Deserialized Function Try to find non-existent Parent set null to prevent that bug byte[] bytes = SerializationHelper.GetBytes(pickupable.gameObject); if (pickupable.GetTechType() == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerGuid, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } EquippedItemData equippedItem = new EquippedItemData(ownerGuid, itemGuid, bytes, slot); Player player = owner.GetComponent <Player>(); bool isPlayerEquipment = (player != null); EquipmentAddItem equipPacket = new EquipmentAddItem(equippedItem, isPlayerEquipment); packetSender.Send(equipPacket); }
public void BroadcastUnequip(Pickupable pickupable, GameObject owner, string slot) { string itemGuid = GuidHelper.GetGuid(pickupable.gameObject); string ownerGuid = GuidHelper.GetGuid(owner); if (pickupable.GetTechType() == TechType.VehicleStorageModule) { List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(owner); VehicleChildUpdate vehicleChildInteractiveData = new VehicleChildUpdate(ownerGuid, childIdentifiers); packetSender.Send(vehicleChildInteractiveData); } Player player = owner.GetComponent <Player>(); bool isPlayerEquipment = (player != null); EquipmentRemoveItem equipPacket = new EquipmentRemoveItem(ownerGuid, slot, itemGuid, isPlayerEquipment); packetSender.Send(equipPacket); }