Add dotnet format as pre-commit hook

This commit is contained in:
Liza 2023-02-07 21:49:53 +01:00
parent 8911ef5227
commit e13cf9409c
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 12 additions and 5 deletions

7
.githooks/pre-commit Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
#
# Use with:
#
# $> git config core.hooksPath .githooks
#
dotnet format SliceIsRight.sln

View File

@ -69,7 +69,7 @@ namespace SliceIsRight
if (!ClientState.IsLoggedIn || !IsInGoldSaucer || ObjectTable == null) if (!ClientState.IsLoggedIn || !IsInGoldSaucer || ObjectTable == null)
return; return;
for (int index = 0; index < ObjectTable.Length; ++ index) for (int index = 0; index < ObjectTable.Length; ++index)
{ {
GameObject? obj = ObjectTable[index]; GameObject? obj = ObjectTable[index];
if (obj == null || DistanceToPlayer(obj.Position) > MaxDistance) if (obj == null || DistanceToPlayer(obj.Position) > MaxDistance)
@ -187,7 +187,7 @@ namespace SliceIsRight
Vector3 farCenter = new Vector3(nearCenter.X + lengthSlice * (float)Math.Sin(rotation), nearCenter.Y, nearCenter.Z + lengthSlice * (float)Math.Cos(rotation)); Vector3 farCenter = new Vector3(nearCenter.X + lengthSlice * (float)Math.Sin(rotation), nearCenter.Y, nearCenter.Z + lengthSlice * (float)Math.Cos(rotation));
bool onScreen = false; bool onScreen = false;
foreach (Vector3 v in new[]{ far2, farCenter, far1, near1, nearCenter, near2}) foreach (Vector3 v in new[] { far2, farCenter, far1, near1, nearCenter, near2 })
{ {
onScreen |= GameGui.WorldToScreen(v, out Vector2 nextVertex); onScreen |= GameGui.WorldToScreen(v, out Vector2 nextVertex);
if ((nextVertex.X > 0 & nextVertex.X < displaySize.X) || (nextVertex.Y > 0 & nextVertex.Y < displaySize.Y)) if ((nextVertex.X > 0 & nextVertex.X < displaySize.X) || (nextVertex.Y > 0 & nextVertex.Y < displaySize.Y))