Ejemplo n.º 1
0
        public void BroadcastUnequip(Pickupable pickupable, GameObject owner, string slot)
        {
            string itemGuid = GuidHelper.GetGuid(pickupable.gameObject);
            Player player   = owner.GetComponent <Player>();

            if (player != null)
            {
                TechType techType = pickupable.GetTechType();
                PlayerEquipmentRemoved equipmentAdded = new PlayerEquipmentRemoved(techType, itemGuid);
                packetSender.Send(equipmentAdded);

                return;
            }

            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);
            }

            ModuleRemoved moduleRemoved = new ModuleRemoved(ownerGuid, slot, itemGuid);

            packetSender.Send(moduleRemoved);
        }
Ejemplo n.º 2
0
        public void BeginCrafting(GameObject constructor, TechType techType, float duration)
        {
            string constructorGuid = GuidHelper.GetGuid(constructor);

            Log.Debug("Building item from constructor with uuid: " + constructorGuid);

            Optional <object> opConstructedObject = TransientLocalObjectManager.Get(TransientObjectType.CONSTRUCTOR_INPUT_CRAFTED_GAMEOBJECT);

            if (opConstructedObject.IsPresent())
            {
                GameObject constructedObject = (GameObject)opConstructedObject.Get();

                List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(constructedObject);
                Vehicle vehicle = constructedObject.GetComponent <Vehicle>();
                string  constructedObjectGuid = GuidHelper.GetGuid(constructedObject);

                //Initialize some default values to serialize.
                Vector3[] HSB       = new Vector3[5];
                Vector3[] Colours   = new Vector3[5];
                Vector4   tmpColour = Color.white;
                string    name      = "Cyclops"; // Cant find a way to actually get the Cyclops name.

                getObjectAttributes(vehicle, name, HSB, Colours, tmpColour, constructedObjectGuid);
                ConstructorBeginCrafting beginCrafting = new ConstructorBeginCrafting(constructorGuid, constructedObjectGuid, techType, duration, childIdentifiers, constructedObject.transform.position, constructedObject.transform.rotation, name, HSB, Colours);
                packetSender.Send(beginCrafting);
            }
            else
            {
                Log.Error("Could not send packet because there wasn't a corresponding constructed object!");
            }
        }
Ejemplo n.º 3
0
        public void BroadcastEquip(Pickupable pickupable, GameObject owner, string slot)
        {
            string   ownerGuid = GuidHelper.GetGuid(owner);
            string   itemGuid  = GuidHelper.GetGuid(pickupable.gameObject);
            TechType techType  = pickupable.GetTechType();

            if (techType == TechType.VehicleStorageModule)
            {
                List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(owner);
                VehicleChildUpdate vehicleChildInteractiveData           = new VehicleChildUpdate(ownerGuid, 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(ownerGuid, itemGuid, bytes, slot, techType);
            Player           player       = owner.GetComponent <Player>();

            if (player != null)
            {
                PlayerEquipmentAdded equipmentAdded = new PlayerEquipmentAdded(techType, equippedItem);
                packetSender.Send(equipmentAdded);
                pickupable.gameObject.transform.SetParent(parent);

                return;
            }

            ModuleAdded moduleAdded = new ModuleAdded(equippedItem);

            packetSender.Send(moduleAdded);
            pickupable.gameObject.transform.SetParent(parent);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public void BeginCrafting(GameObject constructor, TechType techType, float duration)
        {
            string constructorGuid = GuidHelper.GetGuid(constructor);

            Log.Debug("Building item from constructor with uuid: " + constructorGuid);

            Optional <object> opConstructedObject = TransientLocalObjectManager.Get(TransientObjectType.CONSTRUCTOR_INPUT_CRAFTED_GAMEOBJECT);

            if (opConstructedObject.IsPresent())
            {
                GameObject constructedObject = (GameObject)opConstructedObject.Get();

                List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(constructedObject);
                Vehicle   vehicle = constructedObject.GetComponent <Vehicle>();
                string    constructedObjectGuid = GuidHelper.GetGuid(constructedObject);
                Vector3[] HSB       = new Vector3[5];
                Vector3[] Colours   = new Vector3[5];
                Vector4   tmpColour = Color.white;
                string    name      = "";

                if (!vehicle)
                { // Cylcops
                    GameObject   target        = GuidHelper.RequireObjectFrom(constructedObjectGuid);
                    SubNameInput subNameInput  = target.RequireComponentInChildren <SubNameInput>();
                    SubName      subNameTarget = (SubName)subNameInput.ReflectionGet("target");

                    Colours = subNameTarget.GetColors();
                    HSB     = subNameTarget.GetColors();
                    name    = subNameTarget.GetName();
                }
                else if (vehicle)
                { // Seamoth & Prawn Suit
                    name    = (string)vehicle.ReflectionCall("GetName", true);
                    HSB     = vehicle.subName.GetColors();
                    Colours = vehicle.subName.GetColors();
                }
                ConstructorBeginCrafting beginCrafting = new ConstructorBeginCrafting(constructorGuid, constructedObjectGuid, techType.Model(), duration, childIdentifiers, constructedObject.transform.position, constructedObject.transform.rotation,
                                                                                      name, HSB, Colours);
                vehicles.AddVehicle(VehicleModelFactory.BuildFrom(beginCrafting));
                packetSender.Send(beginCrafting);

                // Mark vehicle as controlled by nitrox (used for sending add/remove batteries aka storage slots)
                constructedObject.AddComponent <NitroxEntity>();
                SpawnDefaultBatteries(constructedObject, childIdentifiers);
            }
            else
            {
                Log.Error("Could not send packet because there wasn't a corresponding constructed object!");
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public void BeginCrafting(GameObject constructor, TechType techType, float duration)
        {
            string constructorGuid = GuidHelper.GetGuid(constructor);

            Log.Debug("Building item from constructor with uuid: " + constructorGuid);

            Optional <object> opConstructedObject = TransientLocalObjectManager.Get(TransientObjectType.CONSTRUCTOR_INPUT_CRAFTED_GAMEOBJECT);

            if (opConstructedObject.IsPresent())
            {
                GameObject constructedObject = (GameObject)opConstructedObject.Get();

                List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractGuidsOfInteractiveChildren(constructedObject);
                string constructedObjectGuid           = GuidHelper.GetGuid(constructedObject);
                ConstructorBeginCrafting beginCrafting = new ConstructorBeginCrafting(constructorGuid, constructedObjectGuid, techType, duration, childIdentifiers, constructedObject.transform.position, constructedObject.transform.rotation);
                packetSender.Send(beginCrafting);
            }
            else
            {
                Log.Error("Could not send packet because there wasn't a corresponding constructed object!");
            }
        }