コード例 #1
0
        public void Spawn()
        {
            GameVehicle                     = Alt.CreateVehicle(DbModel.Model.ToString(), new Position(DbModel.PosX, DbModel.PosY, DbModel.PosZ), new Rotation(DbModel.RotPitch, DbModel.RotPitch, DbModel.RotYaw));
            GameVehicle.EngineOn            = false;
            GameVehicle.ManualEngineControl = true;
            GameVehicle.ModKit              = 1;



            GameVehicle.PrimaryColorRgb = new Rgba((byte)DbModel.R, (byte)DbModel.G, (byte)DbModel.B, 1);
            GameVehicle.NumberplateText = $"LS {DbModel.Id}";

            GameVehicle.SetData("vehicle:data", this);
            GameVehicle.SetData("vehicle:id", DbModel.Id);
            GameVehicle.SetSyncedMetaData("vehicle:syncedData", DbModel);

            if (_nonDbVehicle)
            {
                return;
            }

            foreach (ItemModel upgrade in DbModel.VehicleUpgrades)
            {
                if ((TuningType)upgrade.FirstParameter == TuningType.Wheels)
                {
                    GameVehicle.SetWheels((byte)upgrade.SecondParameter, (byte)upgrade.ThirdParameter);
                }
                else
                {
                    GameVehicle.SetMod((VehicleModType)upgrade.SecondParameter, (byte)upgrade.ThirdParameter);
                }
            }


            //Save();
        }
コード例 #2
0
        public override void Spawn()
        {
            GameVehicle = NAPI.Vehicle.CreateVehicle(NAPI.Util.VehicleNameToModel(DbModel.VehicleHash),
                                                     new Vector3(DbModel.SpawnPositionX, DbModel.SpawnPositionY, DbModel.SpawnPositionZ),
                                                     DbModel.SpawnPositionX, DbModel.PrimaryColor.ToColor(),
                                                     DbModel.SecondaryColor.ToColor(),
                                                     DbModel.NumberPlate, 255, true);
            GameVehicle.Rotation = new Vector3(DbModel.SpawnRotationX,
                                               DbModel.SpawnRotationY,
                                               DbModel.SpawnRotationZ);
            GameVehicle.NumberPlateStyle       = DbModel.NumberPlateStyle;
            GameVehicle.EnginePowerMultiplier  = DbModel.EnginePowerMultiplier;
            GameVehicle.EngineTorqueMultiplier = DbModel.EngineTorqueMultiplier;
            GameVehicle.WheelType    = DbModel.WheelType;
            GameVehicle.WheelColor   = DbModel.WheelColor;
            GameVehicle.EngineStatus = false;
            DbModel.IsSpawned        = true;
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 1, DbModel.Door1Damage);
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 2, DbModel.Door2Damage);
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 3, DbModel.Door3Damage);
            NAPI.Vehicle.BreakVehicleDoor(GameVehicle, 4, DbModel.Door4Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 1, DbModel.Window1Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 2, DbModel.Window2Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 3, DbModel.Window3Damage);
            NAPI.Vehicle.BreakVehicleWindow(GameVehicle, 4, DbModel.Window4Damage);

            //Dodajemy tuning do pojazdu
            float engineMultipier = 0f;
            float torqueMultipier = 0f;

            foreach (ItemModel tuning in DbModel.ItemsInVehicle)
            {
                if (tuning.ItemEntityType == ItemEntityType.Tuning && tuning.FourthParameter.HasValue)
                {
                    if (tuning.FirstParameter != null && (TuningType)tuning.FirstParameter == TuningType.Speed)
                    {
                        if (tuning.SecondParameter != null)
                        {
                            engineMultipier += (float)tuning.SecondParameter;
                        }
                        if (tuning.ThirdParameter != null)
                        {
                            torqueMultipier += (float)tuning.ThirdParameter;
                        }
                    }
                }
            }

            //Te metody działają tak, że ujemny mnożnik zmniejsza | 0 to normalnie | a dodatni poprawia
            //Pola są potrzebne, ponieważ w salonie będą dostępne 3 wersje pojazdu
            //TODO: tańsza o 10% zmniejszone osiągi o -5f
            //TODO: normalna
            //TODO: droższa o 25% zwiększone osiągi o 5f
            NAPI.Vehicle.SetVehicleEnginePowerMultiplier(GameVehicle, engineMultipier);
            NAPI.Vehicle.SetVehicleEngineTorqueMultiplier(GameVehicle, torqueMultipier);

            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_maxfuel", DbModel.Fuel);
            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_fuel", DbModel.Fuel);
            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_fuelConsumption", DbModel.FuelConsumption);
            //NAPI.Data.SetEntitySharedData(GameVehicle.Handle, "_milage", DbModel.Milage);
            GameVehicle.SetData("VehicleEntity", this);
            GameVehicle.SetSharedData("Id", DbModel.Id);
            GameVehicle.SetSharedData("milage", DbModel.Milage);
            GameVehicle.SetSharedData("fuel", DbModel.Fuel);
            GameVehicle.SetSharedData("fuelConsumption", DbModel.FuelConsumption);
            GameVehicle.SetSharedData("maxFuel", DbModel.FuelTank);
            EntityHelper.Add(this);
            Save();
        }