Skip to content

Commit

Permalink
Update csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed Dec 18, 2024
1 parent afd9042 commit 7bcc8ed
Show file tree
Hide file tree
Showing 26 changed files with 367 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.26.7",
"version": "0.30.3",
"commands": [
"dotnet-csharpier"
]
Expand Down
6 changes: 3 additions & 3 deletions RLBotCS/Conversion/ColorSwatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal static Color GetSecondary(uint colorId) =>
{ 6, 44, 127 },
{ 6, 22, 127 },
{ 38, 6, 127 },
{ 48, 6, 127 }
{ 48, 6, 127 },
};

private static readonly int[,] OrangeSwatches =
Expand Down Expand Up @@ -170,7 +170,7 @@ internal static Color GetSecondary(uint colorId) =>
{ 127, 30, 6 },
{ 127, 6, 6 },
{ 127, 6, 48 },
{ 127, 6, 66 }
{ 127, 6, 66 },
};

private static readonly int[,] SecondarySwatches =
Expand Down Expand Up @@ -279,6 +279,6 @@ internal static Color GetSecondary(uint colorId) =>
{ 18, 0, 51 },
{ 40, 0, 51 },
{ 51, 0, 32 },
{ 51, 0, 8 }
{ 51, 0, 8 },
};
}
42 changes: 21 additions & 21 deletions RLBotCS/Conversion/FlatToCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private static string MapGameMode(GameMode gameMode) =>
GameMode.Heatseeker => "?game=TAGame.GameInfo_GodBall_TA",
GameMode.Gridiron => "?game=TAGame.GameInfo_Football_TA",
GameMode.Knockout => "?game=TAGame.GameInfo_KnockOut_TA",
_ => throw new ArgumentOutOfRangeException(nameof(gameMode), gameMode, null)
_ => throw new ArgumentOutOfRangeException(nameof(gameMode), gameMode, null),
};

private static string MapMatchLength(MatchLength matchLength) =>
Expand All @@ -29,7 +29,7 @@ private static string MapMatchLength(MatchLength matchLength) =>
MatchLength.Ten_Minutes => "10Minutes",
MatchLength.Twenty_Minutes => "20Minutes",
MatchLength.Unlimited => "UnlimitedTime",
_ => throw new ArgumentOutOfRangeException(nameof(matchLength), matchLength, null)
_ => throw new ArgumentOutOfRangeException(nameof(matchLength), matchLength, null),
};

private static string MapMaxScore(MaxScore maxScore) =>
Expand All @@ -41,7 +41,7 @@ private static string MapMaxScore(MaxScore maxScore) =>
MaxScore.Five_Goals => "Max5",
MaxScore.Seven_Goals => "Max7",
MaxScore.Unlimited => "UnlimitedScore",
_ => throw new ArgumentOutOfRangeException(nameof(maxScore), maxScore, null)
_ => throw new ArgumentOutOfRangeException(nameof(maxScore), maxScore, null),
};

private static string MapMultiBall(MultiBall multiBall) =>
Expand All @@ -51,7 +51,7 @@ private static string MapMultiBall(MultiBall multiBall) =>
MultiBall.Two => "TwoBalls",
MultiBall.Four => "FourBalls",
MultiBall.Six => "SixBalls",
_ => throw new ArgumentOutOfRangeException(nameof(multiBall), multiBall, null)
_ => throw new ArgumentOutOfRangeException(nameof(multiBall), multiBall, null),
};

private static string MapOvertime(OvertimeOption option) =>
Expand All @@ -60,7 +60,7 @@ private static string MapOvertime(OvertimeOption option) =>
OvertimeOption.Unlimited => "",
OvertimeOption.Five_Max_First_Score => "Overtime5MinutesFirstScore",
OvertimeOption.Five_Max_Random_Team => "Overtime5MinutesRandom",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapSeriesLength(SeriesLengthOption option) =>
Expand All @@ -70,7 +70,7 @@ private static string MapSeriesLength(SeriesLengthOption option) =>
SeriesLengthOption.Three_Games => "3Games",
SeriesLengthOption.Five_Games => "5Games",
SeriesLengthOption.Seven_Games => "7Games",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapGameSpeed(GameSpeedOption option) =>
Expand All @@ -79,7 +79,7 @@ private static string MapGameSpeed(GameSpeedOption option) =>
GameSpeedOption.Default => "",
GameSpeedOption.Slo_Mo => "SloMoGameSpeed",
GameSpeedOption.Time_Warp => "SloMoDistanceBall",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBallMaxSpeed(BallMaxSpeedOption option) =>
Expand All @@ -89,7 +89,7 @@ private static string MapBallMaxSpeed(BallMaxSpeedOption option) =>
BallMaxSpeedOption.Slow => "SlowBall",
BallMaxSpeedOption.Fast => "FastBall",
BallMaxSpeedOption.Super_Fast => "SuperFastBall",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBallType(BallTypeOption option) =>
Expand All @@ -104,7 +104,7 @@ private static string MapBallType(BallTypeOption option) =>
BallTypeOption.Haunted => "Ball_Haunted",
BallTypeOption.Ekin => "Ball_Ekin",
BallTypeOption.SpookyCube => "Ball_SpookyCube",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBallWeight(BallWeightOption option) =>
Expand All @@ -117,7 +117,7 @@ private static string MapBallWeight(BallWeightOption option) =>
BallWeightOption.Curve_Ball => "MagnusBall",
BallWeightOption.Beach_Ball_Curve => "MagnusBeachBall",
BallWeightOption.Magnus_FutBall => "MagnusFutBallTest",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBallSize(BallSizeOption option) =>
Expand All @@ -128,7 +128,7 @@ private static string MapBallSize(BallSizeOption option) =>
BallSizeOption.Medium => "MediumBall",
BallSizeOption.Large => "BigBall",
BallSizeOption.Gigantic => "GiantBall",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBallBounciness(BallBouncinessOption option) =>
Expand All @@ -139,7 +139,7 @@ private static string MapBallBounciness(BallBouncinessOption option) =>
BallBouncinessOption.High => "HighBounciness",
BallBouncinessOption.Super_High => "SuperBounciness",
BallBouncinessOption.LowishBounciness => "LowishBounciness",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBoost(BoostOption option) =>
Expand All @@ -150,7 +150,7 @@ private static string MapBoost(BoostOption option) =>
BoostOption.Slow_Recharge => "SlowRecharge",
BoostOption.Rapid_Recharge => "RapidRecharge",
BoostOption.No_Boost => "NoBooster",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapRumble(RumbleOption option) =>
Expand All @@ -167,7 +167,7 @@ private static string MapRumble(RumbleOption option) =>
RumbleOption.Haunted_Ball_Beam => "ItemsModeHauntedBallBeam",
RumbleOption.Tactical => "ItemsModeSelection",
RumbleOption.BatmanRumble => "ItemsMode_BM",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapBoostStrength(BoostStrengthOption option) =>
Expand All @@ -178,7 +178,7 @@ private static string MapBoostStrength(BoostStrengthOption option) =>
BoostStrengthOption.Two => "BoostMultiplier2x",
BoostStrengthOption.Five => "BoostMultiplier5x",
BoostStrengthOption.Ten => "BoostMultiplier10x",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapGravity(GravityOption option) =>
Expand All @@ -189,7 +189,7 @@ private static string MapGravity(GravityOption option) =>
GravityOption.High => "HighGravity",
GravityOption.Super_High => "SuperGravity",
GravityOption.Reverse => "ReverseGravity",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapDemolish(DemolishOption option) =>
Expand All @@ -200,7 +200,7 @@ private static string MapDemolish(DemolishOption option) =>
DemolishOption.Friendly_Fire => "DemolishAll",
DemolishOption.On_Contact => "AlwaysDemolishOpposing",
DemolishOption.On_Contact_FF => "AlwaysDemolish",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapRespawnTime(RespawnTimeOption option) =>
Expand All @@ -210,15 +210,15 @@ private static string MapRespawnTime(RespawnTimeOption option) =>
RespawnTimeOption.Two_Seconds => "TwoSecondsRespawn",
RespawnTimeOption.One_Second => "OneSecondsRespawn",
RespawnTimeOption.Disable_Goal_Reset => "DisableGoalDelay",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapMaxTime(MaxTimeOption option) =>
option switch
{
MaxTimeOption.Default => "",
MaxTimeOption.Eleven_Minutes => "MaxTime11Minutes",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapGameEvent(GameEventOption option) =>
Expand All @@ -227,15 +227,15 @@ private static string MapGameEvent(GameEventOption option) =>
GameEventOption.Default => "",
GameEventOption.Rugby => "RugbyGameEventRules",
GameEventOption.Haunted => "HauntedGameEventRules",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string MapAudio(AudioOption option) =>
option switch
{
AudioOption.Default => "",
AudioOption.Haunted => "HauntedAudio",
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null),
};

private static string GetOption(string option)
Expand Down
64 changes: 30 additions & 34 deletions RLBotCS/Conversion/FlatToModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ GameState gameState
) =>
relative?.Value switch
{
rlbot.flat.CarAnchorT { Index: var index, Local: var local }
=> new RelativeAnchor(
ToVectorFromT(local),
gameState.PlayerMapping.ActorIdFromPlayerIndex(index) ?? 0
),
rlbot.flat.BallAnchorT { Index: var index, Local: var local }
=> new RelativeAnchor(
rlbot.flat.CarAnchorT { Index: var index, Local: var local } => new RelativeAnchor(
ToVectorFromT(local),
gameState.PlayerMapping.ActorIdFromPlayerIndex(index) ?? 0
),
rlbot.flat.BallAnchorT { Index: var index, Local: var local } =>
new RelativeAnchor(
ToVectorFromT(local),
gameState.GetBallActorIdFromIndex(index) ?? 0
),
Expand Down Expand Up @@ -76,18 +75,17 @@ internal static Loadout ToLoadout(rlbot.flat.PlayerLoadoutT l, uint team)

var lp = l.LoadoutPaint;

LoadoutPaint loadoutPaint =
new()
{
CarPaintId = (byte)lp.CarPaintId,
DecalPaintId = (byte)lp.DecalPaintId,
WheelsPaintId = (byte)lp.WheelsPaintId,
BoostPaintId = (byte)lp.BoostPaintId,
AntennaPaintId = (byte)lp.AntennaPaintId,
HatPaintId = (byte)lp.HatPaintId,
TrailsPaintId = (byte)lp.TrailsPaintId,
GoalExplosionPaintId = (byte)lp.GoalExplosionPaintId
};
LoadoutPaint loadoutPaint = new()
{
CarPaintId = (byte)lp.CarPaintId,
DecalPaintId = (byte)lp.DecalPaintId,
WheelsPaintId = (byte)lp.WheelsPaintId,
BoostPaintId = (byte)lp.BoostPaintId,
AntennaPaintId = (byte)lp.AntennaPaintId,
HatPaintId = (byte)lp.HatPaintId,
TrailsPaintId = (byte)lp.TrailsPaintId,
GoalExplosionPaintId = (byte)lp.GoalExplosionPaintId,
};

return new Loadout
{
Expand All @@ -104,7 +102,7 @@ internal static Loadout ToLoadout(rlbot.flat.PlayerLoadoutT l, uint team)
WheelsId = (ushort)l.WheelsId,
LoadoutPaint = loadoutPaint,
PrimaryColorLookup = primaryColor,
SecondaryColorLookup = secondaryColor
SecondaryColorLookup = secondaryColor,
};
}

Expand All @@ -114,13 +112,12 @@ Vector3 defaultVec
) =>
partVec switch
{
not null
=> new Vector3(
partVec.X?.Val ?? defaultVec.X,
partVec.Y?.Val ?? defaultVec.Y,
partVec.Z?.Val ?? defaultVec.Z
),
_ => defaultVec
not null => new Vector3(
partVec.X?.Val ?? defaultVec.X,
partVec.Y?.Val ?? defaultVec.Y,
partVec.Z?.Val ?? defaultVec.Z
),
_ => defaultVec,
};

internal static Rotator DesiredToRotator(
Expand All @@ -129,13 +126,12 @@ Rotator defaultRot
) =>
partRot switch
{
not null
=> new Rotator(
partRot.Pitch?.Val ?? defaultRot.Pitch,
partRot.Yaw?.Val ?? defaultRot.Yaw,
partRot.Roll?.Val ?? defaultRot.Roll
),
_ => defaultRot
not null => new Rotator(
partRot.Pitch?.Val ?? defaultRot.Pitch,
partRot.Yaw?.Val ?? defaultRot.Yaw,
partRot.Roll?.Val ?? defaultRot.Roll
),
_ => defaultRot,
};

internal static Physics DesiredToPhysics(rlbot.flat.DesiredPhysicsT p, Physics defaultP) =>
Expand Down
Loading

0 comments on commit 7bcc8ed

Please sign in to comment.