Beispiel #1
0
        public void BeginCrafting(GameObject constructor, TechType techType, float duration)
        {
            NitroxId constructorId = NitroxEntity.GetId(constructor);

            Log.Debug("Building item from constructor with id: " + constructorId);

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

            if (opConstructedObject.HasValue)
            {
                GameObject constructedObject = (GameObject)opConstructedObject.Value;
                List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractInteractiveChildren(constructedObject);

                VehicleModel vehicleModel = vehicles.BuildVehicleModelFrom(constructedObject, techType);
                vehicles.AddVehicle(vehicleModel);

                packetSender.Send(new ConstructorBeginCrafting(vehicleModel, constructorId, duration));

                vehicles.SpawnDefaultBatteries(constructedObject, childIdentifiers);

                MonoBehaviour monoBehaviour = constructor.GetComponent <MonoBehaviour>();
                //We want to store the fallen position of the object to avoid flying object on reload
                if (monoBehaviour)
                {
                    monoBehaviour.StartCoroutine(vehicles.UpdateVehiclePositionAfterSpawn(vehicleModel, constructedObject, duration + 10.0f));
                }
            }
            else
            {
                Log.Error("Could not send packet because there wasn't a corresponding constructed object!");
            }
        }
Beispiel #2
0
        public void BeginCrafting(GameObject constructor, TechType techType, float duration)
        {
            NitroxId constructorId = NitroxEntity.GetId(constructor);

            Log.Debug("Building item from constructor with id: " + constructorId);

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

            if (opConstructedObject.HasValue)
            {
                GameObject constructedObject = (GameObject)opConstructedObject.Value;
                List <InteractiveChildObjectIdentifier> childIdentifiers = VehicleChildObjectIdentifierHelper.ExtractInteractiveChildren(constructedObject);

                VehicleModel vehicleModel = vehicles.BuildVehicleModelFrom(constructedObject, techType);
                vehicles.AddVehicle(vehicleModel);

                ConstructorBeginCrafting beginCrafting = VehicleConstructionFactory.BuildFrom(vehicleModel, constructorId, duration);
                packetSender.Send(beginCrafting);

                vehicles.SpawnDefaultBatteries(constructedObject, childIdentifiers);
            }
            else
            {
                Log.Error("Could not send packet because there wasn't a corresponding constructed object!");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Spawns a Seamoth or an Exosuit
        /// </summary>
        private void SpawnVehicle(GameObject gameObject)
        {
            TechType     techType     = CraftData.GetTechType(gameObject);
            VehicleModel vehicleModel = vehicles.BuildVehicleModelFrom(gameObject, techType);

            Validate.NotNull(vehicleModel, $"Unable to sync spawned vehicle ({vehicleModel.TechType} - {vehicleModel.Id}) from devconsole");

            VehicleSpawned vehicleSpawned = new VehicleSpawned(SerializationHelper.GetBytes(gameObject), vehicleModel);

            vehicles.AddVehicle(vehicleModel);

            Log.Debug($"Spawning vehicle {vehicleModel.TechType} with id {vehicleModel.Id} at {vehicleModel.Position}");
            packetSender.Send(vehicleSpawned);

            vehicles.SpawnDefaultBatteries(vehicleModel);
        }