public override void Process(InitialPlayerSync packet)
 {
     foreach (VehicleModel vehicle in packet.Vehicles)
     {
         // TODO: create an AsyncInitialSyncProcessor that creates cyclops before seamoth (as seamoth can be docked in cyclops)
         vehicles.CreateVehicle(vehicle);
     }
 }
Пример #2
0
 public override void Process(InitialPlayerSync packet)
 {
     foreach (VehicleModel vehicle in packet.Vehicles)
     {
         if (vehicle.TechType.Enum() != TechType.Cyclops)
         {
             vehicles.CreateVehicle(vehicle);
         }
     }
 }
            public void CreateVehicles(object sender, EventArgs eventArgs)
            {
                ThrottledBuilder.main.QueueDrained -= CreateVehicles;

                // TODO: Wait for Cyclops to spawn, as it is not instantaneous but rather async.
                foreach (VehicleModel vehicle in vehicleModels)
                {
                    vehicles.CreateVehicle(vehicle);
                }
            }
 public override void Process(InitialPlayerSync packet)
 {
     foreach (VehicleModel vehicle in packet.Vehicles)
     {
         // TODO: create an AsyncInitialSyncProcessor that creates cyclops before seamoth and exosuit (as seamoth can be docked in cyclops)
         if (vehicle.TechType.Enum() != TechType.Cyclops)
         {
             vehicles.CreateVehicle(vehicle);
         }
     }
 }
Пример #5
0
 public override void Process(InitialPlayerSync packet)
 {
     vehicles.VehicleCreated += OnVehicleCreated;
     foreach (VehicleModel vehicle in packet.Vehicles)
     {
         if (vehicle.TechType.Enum() == TechType.Cyclops)
         {
             cyclopsStillLoading++;
             vehicles.CreateVehicle(vehicle);
         }
     }
     // If no cyclops is created, just send the finish right away
     if (cyclopsStillLoading == 0)
     {
         FinishedCreating();
     }
 }
Пример #6
0
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            int totalSyncedVehicles    = 0;
            int nonCyclopsVehicleCount = packet.Vehicles.Where(v => v.TechType.ToUnity() != TechType.Cyclops).Count();

            foreach (VehicleModel vehicle in packet.Vehicles)
            {
                if (vehicle.TechType.ToUnity() != TechType.Cyclops)
                {
                    waitScreenItem.SetProgress(totalSyncedVehicles, nonCyclopsVehicleCount);
                    vehicles.CreateVehicle(vehicle);
                    totalSyncedVehicles++;
                    yield return(null);
                }
            }

            Log.Info("Recieved initial sync with " + totalSyncedVehicles + " non-cyclops vehicles");
        }
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            this.waitScreenItem      = waitScreenItem;
            vehicles.VehicleCreated += OnVehicleCreated;

            totalCyclopsToLoad = packet.Vehicles.Where(v => v.TechType.Enum() == TechType.Cyclops).Count();

            foreach (VehicleModel vehicle in packet.Vehicles)
            {
                if (vehicle.TechType.Enum() == TechType.Cyclops)
                {
                    Log.Debug($"Trying to spawn {vehicle}");
                    vehicles.CreateVehicle(vehicle);
                }
            }

            yield return(new WaitUntil(() => cyclopsLoaded == totalCyclopsToLoad));
        }
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            this.waitScreenItem = waitScreenItem;

            vehicles.VehicleCreated += OnVehicleCreated;

            foreach (VehicleModel vehicle in packet.Vehicles)
            {
                if (vehicle.TechType.Enum() == TechType.Cyclops)
                {
                    cyclopsStillLoading++;
                    vehicles.CreateVehicle(vehicle);
                }
            }

            totalCyclopsToLoad = cyclopsStillLoading;

            yield return(new WaitUntil(() => cyclopsStillLoading == 0));
        }
Пример #9
0
        private bool SpawnPurchasedVehicle(Client player, List <Vector3> spawns, VehicleHash vehicleHash,
                                           int vehiclePrice, string firstColor, string secondColor)
        {
            for (var i = 0; i < spawns.Count; i++)
            {
                // Check if the spawn point has a vehicle on it
                var spawnOccupied = NAPI.Pools.GetAllVehicles().Where(veh => spawns[i].DistanceTo(veh.Position) < 2.5f)
                                    .Any();

                if (!spawnOccupied)
                {
                    // Basic data for vehicle creation
                    var vehicleModel = new VehicleModel();
                    {
                        vehicleModel.model       = GetVehicleModel(vehicleHash);
                        vehicleModel.plate       = string.Empty;
                        vehicleModel.position    = spawns[i];
                        vehicleModel.rotation    = new Vector3(0.0f, 0.0f, 218.0f);
                        vehicleModel.owner       = player.GetData(EntityData.PLAYER_NAME);
                        vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                        vehicleModel.firstColor  = firstColor;
                        vehicleModel.secondColor = secondColor;
                        vehicleModel.pearlescent = 0;
                        vehicleModel.price       = vehiclePrice;
                        vehicleModel.parking     = 0;
                        vehicleModel.parked      = 0;
                        vehicleModel.engine      = 0;
                        vehicleModel.locked      = 0;
                        vehicleModel.gas         = 50.0f;
                        vehicleModel.kms         = 0.0f;
                    }

                    // Creating the purchased vehicle
                    Vehicles.CreateVehicle(player, vehicleModel, false);

                    return(true);
                }
            }

            return(false);
        }
Пример #10
0
 public override void Process(VehicleCreated packet)
 {
     vehicles.CreateVehicle(packet.CreatedVehicle);
 }
Пример #11
0
        public void PurchaseVehicleEvent(Client player, params object[] arguments)
        {
            int         carShop      = GetClosestCarShop(player);
            VehicleHash vehicleHash  = (VehicleHash)UInt32.Parse(arguments[0].ToString());
            int         vehiclePrice = GetVehiclePrice(vehicleHash);

            if (vehiclePrice > 0 && NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_BANK) >= vehiclePrice)
            {
                switch (carShop)
                {
                case 0:
                    for (int i = 0; i < Constants.CARSHOP_SPAWNS.Count; i++)
                    {
                        bool spawnOccupied = false;
                        foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
                        {
                            Vector3 vehPos = NAPI.Entity.GetEntityPosition(veh);
                            if (Constants.CARSHOP_SPAWNS[i].DistanceTo(vehPos) < 2.5f)
                            {
                                spawnOccupied = true;
                                break;
                            }
                        }
                        if (!spawnOccupied)
                        {
                            // Rellenamos los datos básicos del vehículo para su creación
                            VehicleModel vehicleModel = new VehicleModel();
                            vehicleModel.model       = GetVehicleModel(vehicleHash);
                            vehicleModel.plate       = String.Empty;
                            vehicleModel.position    = Constants.CARSHOP_SPAWNS[i];
                            vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                            vehicleModel.owner       = NAPI.Data.GetEntityData(player, EntityData.PLAYER_NAME);
                            vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                            vehicleModel.firstColor  = arguments[1].ToString();
                            vehicleModel.secondColor = arguments[2].ToString();
                            vehicleModel.pearlescent = 0;
                            vehicleModel.price       = vehiclePrice;
                            vehicleModel.parking     = 0;
                            vehicleModel.parked      = 0;
                            vehicleModel.engine      = 0;
                            vehicleModel.locked      = 0;
                            vehicleModel.gas         = 50.0f;
                            vehicleModel.kms         = 0.0f;

                            // Creamos el vehículo comprado
                            Vehicles.CreateVehicle(player, vehicleModel, false);
                            return;
                        }
                    }
                    break;

                case 1:
                    for (int i = 0; i < Constants.BIKESHOP_SPAWNS.Count; i++)
                    {
                        bool spawnOccupied = false;
                        foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
                        {
                            Vector3 vehPos = NAPI.Entity.GetEntityPosition(veh);
                            if (Constants.BIKESHOP_SPAWNS[i].DistanceTo(vehPos) < 2.5f)
                            {
                                spawnOccupied = true;
                                break;
                            }
                        }
                        if (!spawnOccupied)
                        {
                            // Rellenamos los datos básicos del vehículo para su creación
                            VehicleModel vehicleModel = new VehicleModel();
                            vehicleModel.model       = GetVehicleModel(vehicleHash);
                            vehicleModel.plate       = String.Empty;
                            vehicleModel.position    = Constants.BIKESHOP_SPAWNS[i];
                            vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                            vehicleModel.owner       = NAPI.Data.GetEntityData(player, EntityData.PLAYER_NAME);
                            vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                            vehicleModel.firstColor  = arguments[1].ToString();
                            vehicleModel.secondColor = arguments[2].ToString();
                            vehicleModel.pearlescent = 0;
                            vehicleModel.price       = vehiclePrice;
                            vehicleModel.parking     = 0;
                            vehicleModel.parked      = 0;
                            vehicleModel.engine      = 0;
                            vehicleModel.locked      = 0;
                            vehicleModel.gas         = 50.0f;
                            vehicleModel.kms         = 0.0f;

                            // Creamos el vehículo comprado
                            Vehicles.CreateVehicle(player, vehicleModel, false);
                            return;
                        }
                    }
                    break;

                case 2:
                    for (int i = 0; i < Constants.SHIP_SPAWNS.Count; i++)
                    {
                        bool spawnOccupied = false;
                        foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
                        {
                            Vector3 vehPos = NAPI.Entity.GetEntityPosition(veh);
                            if (Constants.SHIP_SPAWNS[i].DistanceTo(vehPos) < 2.5f)
                            {
                                spawnOccupied = true;
                                break;
                            }
                        }
                        if (!spawnOccupied)
                        {
                            // Rellenamos los datos básicos del vehículo para su creación
                            VehicleModel vehicleModel = new VehicleModel();
                            vehicleModel.model       = GetVehicleModel(vehicleHash);
                            vehicleModel.plate       = String.Empty;
                            vehicleModel.position    = Constants.SHIP_SPAWNS[i];
                            vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                            vehicleModel.owner       = NAPI.Data.GetEntityData(player, EntityData.PLAYER_NAME);
                            vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                            vehicleModel.firstColor  = arguments[1].ToString();
                            vehicleModel.secondColor = arguments[2].ToString();
                            vehicleModel.pearlescent = 0;
                            vehicleModel.price       = vehiclePrice;
                            vehicleModel.parking     = 0;
                            vehicleModel.parked      = 0;
                            vehicleModel.engine      = 0;
                            vehicleModel.locked      = 0;
                            vehicleModel.gas         = 50.0f;
                            vehicleModel.kms         = 0.0f;

                            // Creamos el vehículo comprado
                            Vehicles.CreateVehicle(player, vehicleModel, false);
                            return;
                        }
                    }
                    break;
                }

                // Los concesionarios están ocupados
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_CARSHOP_SPAWN_OCCUPIED);
            }
            else
            {
                String message = String.Format(Messages.ERR_CARSHOP_NO_MONEY, vehiclePrice);
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + message);
            }
        }
Пример #12
0
        public void PurchaseVehicleEvent(Client player, String hash, String firstColor, String secondColor)
        {
            int         carShop      = GetClosestCarShop(player);
            VehicleHash vehicleHash  = (VehicleHash)UInt32.Parse(hash);
            int         vehiclePrice = GetVehiclePrice(vehicleHash);

            if (vehiclePrice > 0 && NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_BANK) >= vehiclePrice)
            {
                switch (carShop)
                {
                case 0:
                    for (int i = 0; i < Constants.CARSHOP_SPAWNS.Count; i++)
                    {
                        bool spawnOccupied = false;
                        foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
                        {
                            Vector3 vehPos = NAPI.Entity.GetEntityPosition(veh);
                            if (Constants.CARSHOP_SPAWNS[i].DistanceTo(vehPos) < 2.5f)
                            {
                                spawnOccupied = true;
                                break;
                            }
                        }
                        if (!spawnOccupied)
                        {
                            // Basic data for vehicle creation
                            VehicleModel vehicleModel = new VehicleModel();
                            vehicleModel.model       = GetVehicleModel(vehicleHash);
                            vehicleModel.plate       = String.Empty;
                            vehicleModel.position    = Constants.CARSHOP_SPAWNS[i];
                            vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                            vehicleModel.owner       = NAPI.Data.GetEntityData(player, EntityData.PLAYER_NAME);
                            vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                            vehicleModel.firstColor  = firstColor;
                            vehicleModel.secondColor = secondColor;
                            vehicleModel.pearlescent = 0;
                            vehicleModel.price       = vehiclePrice;
                            vehicleModel.parking     = 0;
                            vehicleModel.parked      = 0;
                            vehicleModel.engine      = 0;
                            vehicleModel.locked      = 0;
                            vehicleModel.gas         = 50.0f;
                            vehicleModel.kms         = 0.0f;

                            // Creating the purchased vehicle
                            Vehicles.CreateVehicle(player, vehicleModel, false);
                            return;
                        }
                    }
                    break;

                case 1:
                    for (int i = 0; i < Constants.BIKESHOP_SPAWNS.Count; i++)
                    {
                        bool spawnOccupied = false;
                        foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
                        {
                            Vector3 vehPos = NAPI.Entity.GetEntityPosition(veh);
                            if (Constants.BIKESHOP_SPAWNS[i].DistanceTo(vehPos) < 2.5f)
                            {
                                spawnOccupied = true;
                                break;
                            }
                        }
                        if (!spawnOccupied)
                        {
                            // Basic data for vehicle creation
                            VehicleModel vehicleModel = new VehicleModel();
                            vehicleModel.model       = GetVehicleModel(vehicleHash);
                            vehicleModel.plate       = String.Empty;
                            vehicleModel.position    = Constants.BIKESHOP_SPAWNS[i];
                            vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                            vehicleModel.owner       = NAPI.Data.GetEntityData(player, EntityData.PLAYER_NAME);
                            vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                            vehicleModel.firstColor  = firstColor;
                            vehicleModel.secondColor = secondColor;
                            vehicleModel.pearlescent = 0;
                            vehicleModel.price       = vehiclePrice;
                            vehicleModel.parking     = 0;
                            vehicleModel.parked      = 0;
                            vehicleModel.engine      = 0;
                            vehicleModel.locked      = 0;
                            vehicleModel.gas         = 50.0f;
                            vehicleModel.kms         = 0.0f;

                            // Creating the purchased vehicle
                            Vehicles.CreateVehicle(player, vehicleModel, false);
                            return;
                        }
                    }
                    break;

                case 2:
                    for (int i = 0; i < Constants.SHIP_SPAWNS.Count; i++)
                    {
                        bool spawnOccupied = false;
                        foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
                        {
                            Vector3 vehPos = NAPI.Entity.GetEntityPosition(veh);
                            if (Constants.SHIP_SPAWNS[i].DistanceTo(vehPos) < 2.5f)
                            {
                                spawnOccupied = true;
                                break;
                            }
                        }
                        if (!spawnOccupied)
                        {
                            // Basic data for vehicle creation
                            VehicleModel vehicleModel = new VehicleModel();
                            vehicleModel.model       = GetVehicleModel(vehicleHash);
                            vehicleModel.plate       = String.Empty;
                            vehicleModel.position    = Constants.SHIP_SPAWNS[i];
                            vehicleModel.rotation    = new Vector3(0.0, 0.0, 0.0);
                            vehicleModel.owner       = NAPI.Data.GetEntityData(player, EntityData.PLAYER_NAME);
                            vehicleModel.colorType   = Constants.VEHICLE_COLOR_TYPE_CUSTOM;
                            vehicleModel.firstColor  = firstColor;
                            vehicleModel.secondColor = secondColor;
                            vehicleModel.pearlescent = 0;
                            vehicleModel.price       = vehiclePrice;
                            vehicleModel.parking     = 0;
                            vehicleModel.parked      = 0;
                            vehicleModel.engine      = 0;
                            vehicleModel.locked      = 0;
                            vehicleModel.gas         = 50.0f;
                            vehicleModel.kms         = 0.0f;

                            // Creating the purchased vehicle
                            Vehicles.CreateVehicle(player, vehicleModel, false);
                            return;
                        }
                    }
                    break;
                }

                // Parking places are occupied
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_CARSHOP_SPAWN_OCCUPIED);
            }
            else
            {
                String message = String.Format(Messages.ERR_CARSHOP_NO_MONEY, vehiclePrice);
                NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + message);
            }
        }