Beispiel #1
0
 public static void Command_SetVehicleColor([ConsoleCommandParameter(AutoCompleterType = typeof(ConsoleCommandAutoCompleterVehicleAliveOnly))] Vehicle vehicle,
                                            [ConsoleCommandParameter(AutoCompleterType = typeof(ConsoleCommandParameterAutoCompleterEnum))] VehiclePaint primary,
                                            [ConsoleCommandParameter(AutoCompleterType = typeof(ConsoleCommandParameterAutoCompleterEnum))] VehiclePaint secondary)
 {
     if (vehicle)
     {
         VehicleColor vehicleColor = new VehicleColor(primary, secondary);
         vehicle.SetColor(vehicleColor);
         List <string> log = new List <string>()
         {
             $"Vehicle: {vehicle.GetDisplayName()}",
             $"Manufacturer: {vehicle.GetMakeName()}",
             $"Primary Color:",
             $"     Name: {vehicleColor.PrimaryColorName}",
             $"     RGBA: {vehicleColor.PrimaryColorRGBA}",
             $"Secondary Color:",
             $"     Name: {vehicleColor.SecondaryColorName}",
             $"     RGBA: {vehicleColor.SecondaryColorRGBA}",
         };
         log.ForEach(Game.LogTrivial);
     }
     else
     {
         Game.LogTrivial("Vehicle doesn't exist");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Gets the <see cref="VehicleColor"/> of this <see cref="Vehicle"/>
        /// </summary>
        public static VehicleColor GetColor(this Vehicle vehicle)
        {
            NativeWrappers.GetVehicleColours(vehicle, out int primary, out int secondary);
            VehiclePaint primaryColor   = primary >= 0 && primary <= 160 ? (VehiclePaint)primary : VehiclePaint.Unknown;
            VehiclePaint secondaryColor = secondary >= 0 && secondary <= 160 ? (VehiclePaint)secondary : VehiclePaint.Unknown;

            return(new VehicleColor(primaryColor, secondaryColor));
        }
 public VehicleColor(VehiclePaint primary, VehiclePaint secondary)
 {
     PrimaryColor       = primary;
     SecondaryColor     = secondary;
     PrimaryColorRGBA   = GetColor(primary);
     SecondaryColorRGBA = GetColor(secondary);
     PrimaryColorName   = primary.ToString().Replace('_', ' ');
     SecondaryColorName = secondary.ToString().Replace('_', ' ');
 }
Beispiel #4
0
 /// <summary>
 /// Sets this <see cref="Vehicle"/> primary color only
 /// </summary>
 /// <param name="primaryColor">The primary color to be sets</param>
 public static void SetColor(this Vehicle vehicle, VehiclePaint primaryColor) => vehicle.SetColor(new VehicleColor(primaryColor, vehicle.GetColor().SecondaryColor));
 /// <summary>
 /// Gets the RGBA <see cref="Color"/> value of the specified <see cref="VehiclePaint"/>
 /// </summary>
 /// <returns>The <see cref="Color"/> representation of the given <paramref name="vehiclePaint"/>,
 /// if the given <paramref name="vehiclePaint"/> is <c><see cref="VehiclePaint.Unknown"/></c> returns <c><see cref="Color.Empty"/></c></returns>
 /// <remarks>Data is taken from: <a href="https://github.com/DurtyFree/gta-v-data-dumps/blob/master/vehicleColors.json">DurtyFree</a></remarks>
 public static Color GetColor(VehiclePaint vehiclePaint) => vehiclePaint switch
 {