System.Collections.Generic.Dictionary.ContainsKey(VehicleClass)

Here are the examples of the csharp api System.Collections.Generic.Dictionary.ContainsKey(VehicleClass) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 Source : FuelManager.cs
with MIT License
from GroovyGiantPanda

static async void PeriodicCheck()
        {
            while (true)
            {
                if (Game.PlayerPed.IsInVehicle())
                {
                    if (!Function.Call<bool>(Hash.DECOR_EXIST_ON, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel"))
                    {
                        // For very large random float numbers this method does not yield a uniform distribution
                        // But for this magnitude it is perfectly fine
                        float randomFuel = (float)(minRandomFuel + (maxRandomFuel - minRandomFuel) * (random.NextDouble()));
                        Function.Call(Hash._DECOR_SET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel", randomFuel);
                    }
                    vehicleFuel = Function.Call<float>(Hash._DECOR_GET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel");

                    if (!Function.Call<bool>(Hash.DECOR_EXIST_ON, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.FuelUsageMultiplier"))
                    {
                        fuelUsageMultiplier = startingMultiplier;
                        //Log.ToChat($"{fuelUsageMultiplier:0.00000}");
                        VehicleClreplaced VehicleClreplaced = (VehicleClreplaced)Function.Call<int>(Hash.GET_VEHICLE_CLreplaced, Game.PlayerPed.CurrentVehicle.Handle);
                        fuelUsageMultiplier *= (FuelConsumptionClreplacedMultiplier.ContainsKey(VehicleClreplaced) ? FuelConsumptionClreplacedMultiplier[VehicleClreplaced] : 1.0f);
                        fuelUsageMultiplier *= FuelConsumptionModelMultiplier.ContainsKey((VehicleHash)(uint)Game.PlayerPed.CurrentVehicle.Model.Hash) ? FuelConsumptionModelMultiplier[(VehicleHash)(uint)Game.PlayerPed.CurrentVehicle.Model.Hash] : 1f;
                        Function.Call(Hash._DECOR_SET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.FuelUsageMultiplier", fuelUsageMultiplier);
                    }
                    if (lastUpdate == -1)
                    {
                        lastUpdate = Function.Call<int>(Hash.GET_GAME_TIMER);
                    }
                    if (fuelUsageMultiplier < 0)
                    {
                        fuelUsageMultiplier = Function.Call<float>(Hash._DECOR_GET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.FuelUsageMultiplier");
                    }
                    currentUpdate = Function.Call<int>(Hash.GET_GAME_TIMER); 
                    double deltaTime = (currentUpdate - lastUpdate) / 1000f;
                    float vehicleSpeed = Math.Abs(Game.PlayerPed.CurrentVehicle.Speed);
                    vehicleFuel = Math.Max(0f, vehicleFuel - (float)(deltaTime * fuelUsageMultiplier * vehicleSpeed));
                    Function.Call(Hash._DECOR_SET_FLOAT, Game.PlayerPed.CurrentVehicle.Handle, "Vehicle.Fuel", vehicleFuel);
                    lastUpdate = currentUpdate;
                }
                else
                {
                    fuelUsageMultiplier = -1;
                    //vehicleFuel = -1;
                    lastUpdate = -1;
                }
                isNearFuelPump = ObjectList.Select(o => new Prop(o)).Where(o => FuelPumpModelHashes.Contains((ObjectHash)(uint)o.Model.Hash)).Any(o => o.Position.DistanceToSquared(Game.PlayerPed.Position) < Math.Pow(2*FuelPumpRange, 2));
                await BaseScript.Delay(500);
            }
        }