-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03ec4dc
commit 9abc0cd
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using InSimDotNet.Packets; | ||
using System.Collections.Generic; | ||
|
||
namespace InSimDotNet.Helpers { | ||
/// <summary> | ||
/// Helper class for setting car handicaps. | ||
/// </summary> | ||
public static class HandicapHelper { | ||
private static Dictionary<CarFlags, byte> CarMap = new Dictionary<CarFlags, byte>() { | ||
{ CarFlags.XFG, 0 }, | ||
{ CarFlags.XRG, 1 }, | ||
{ CarFlags.XRT, 2 }, | ||
{ CarFlags.RB4, 3 }, | ||
{ CarFlags.FXO, 4 }, | ||
{ CarFlags.LX4, 5 }, | ||
{ CarFlags.LX6, 6 }, | ||
{ CarFlags.MRT, 7 }, | ||
{ CarFlags.UF1, 8 }, | ||
{ CarFlags.RAC, 9 }, | ||
{ CarFlags.FZ5, 10 }, | ||
{ CarFlags.FOX, 11 }, | ||
{ CarFlags.XFR, 12 }, | ||
{ CarFlags.UFR, 13 }, | ||
{ CarFlags.FO8, 14 }, | ||
{ CarFlags.FXR, 15 }, | ||
{ CarFlags.XRR, 16 }, | ||
{ CarFlags.FZR, 17 }, | ||
{ CarFlags.BF1, 18 }, | ||
{ CarFlags.FBM, 19 }, | ||
}; | ||
|
||
/// <summary> | ||
/// Sets the handicap for the specified cars. | ||
/// </summary> | ||
/// <param name="packet">The <see cref="IS_HCP"/> packet containing the handicaps. | ||
/// <param name="T_Mass">The added mass to set in kilograms (0 - 200).</param> | ||
/// <param name="H_TRes">The intake restriction to set (0 - 50).</param> | ||
public static void SetHandicap(IS_HCP packet, CarFlags cars, byte H_Mass = 0, byte H_TRes = 0) { | ||
foreach (var car in CarMap) { | ||
if (cars.HasFlag(car.Key) || cars.HasFlag(CarFlags.All)) { | ||
packet.Info[car.Value].H_Mass = H_Mass; | ||
packet.Info[car.Value].H_TRes = H_TRes; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters