Skip to content

Commit

Permalink
Fix some formatting inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStolk committed Sep 9, 2024
1 parent bf2d263 commit 7a9c6a9
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ internal sealed record TextureBinary(ushort Width, ushort Height, byte[] ColorDa
public ContentType ContentType => ContentType.Texture;

private static bool IsOpaqueWhite(byte r, byte g, byte b, byte a)
=> r == byte.MaxValue && g == byte.MaxValue && b == byte.MaxValue && a == byte.MaxValue;
{
return r == byte.MaxValue && g == byte.MaxValue && b == byte.MaxValue && a == byte.MaxValue;
}

private static TextureContentType DetermineTextureContentType(IReadOnlyList<byte> colorData)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public TocEntry(ContentType contentType, string name, uint length)
public uint Length { get; }

public override string ToString()
=> $"{ContentType}: \"{Name}\" ({Length} bytes)";
{
return $"{ContentType}: \"{Name}\" ({Length} bytes)";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ namespace DevilDaggersInfo.Tools.Engine.Content.Extensions;
internal static class BinaryReaderExtensions
{
public static Vector2 ReadVector2AsHalfPrecision(this BinaryReader br)
=> new((float)br.ReadHalf(), (float)br.ReadHalf());
{
return new Vector2((float)br.ReadHalf(), (float)br.ReadHalf());
}

public static Vector3 ReadVector3AsHalfPrecision(this BinaryReader br)
=> new((float)br.ReadHalf(), (float)br.ReadHalf(), (float)br.ReadHalf());
{
return new Vector3((float)br.ReadHalf(), (float)br.ReadHalf(), (float)br.ReadHalf());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ namespace DevilDaggersInfo.Tools.Engine.Content.Parsers.Model;
public readonly record struct Face(ushort Position, ushort Texture, ushort Normal)
{
public override string ToString()
=> $"{Position}/{Texture}/{Normal}";
{
return $"{Position}/{Texture}/{Normal}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ public static ModelData Parse(byte[] fileContents)
return new ModelData(positions, textures, normals, meshes.Select(kvp => new MeshData(kvp.Key, kvp.Value)).ToList());
}

private static float ParseVertexFloat(string value) => (float)double.Parse(value, NumberStyles.Float);
private static float ParseVertexFloat(string value)
{
return (float)double.Parse(value, NumberStyles.Float);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,63 @@ public static class SpawnsetEditTypeExtensions
private static readonly Color _colorPractice = new(0, _colorValue, _colorValue, 255);
private static readonly Color _colorSpawn = new(_colorValue, 0, _colorValue, 255);

public static ReadOnlySpan<char> GetChange(this SpawnsetEditType spawnsetEditType) => spawnsetEditType switch
public static ReadOnlySpan<char> GetChange(this SpawnsetEditType spawnsetEditType)
{
SpawnsetEditType.Reset => "Spawnset reset",
SpawnsetEditType.ArenaTileHeight => "Arena tile height edit",
SpawnsetEditType.ArenaPencil => "Arena pencil edit",
SpawnsetEditType.ArenaLine => "Arena line edit",
SpawnsetEditType.ArenaRectangle => "Arena rectangle edit",
SpawnsetEditType.ArenaEllipse => "Arena ellipse edit",
SpawnsetEditType.ArenaBucket => "Arena bucket edit",
SpawnsetEditType.RaceDagger => "Race dagger position change",
SpawnsetEditType.ShrinkStart => "Shrink start change",
SpawnsetEditType.ShrinkEnd => "Shrink end change",
SpawnsetEditType.ShrinkRate => "Shrink rate change",
SpawnsetEditType.Brightness => "Brightness change",
SpawnsetEditType.Format => "Format change",
SpawnsetEditType.GameMode =>"Game mode change",
SpawnsetEditType.HandLevel => "Hand level change",
SpawnsetEditType.AdditionalGems => "Additional gems change",
SpawnsetEditType.TimerStart => "Timer start change",
SpawnsetEditType.SpawnDelete => "Spawn deletion",
SpawnsetEditType.SpawnAdd => "Spawn addition",
SpawnsetEditType.SpawnEdit => "Spawn edit",
SpawnsetEditType.SpawnInsert => "Spawn insertion",
SpawnsetEditType.SpawnsTransformation => "Spawns transformation",
_ => throw new UnreachableException(),
};
return spawnsetEditType switch
{
SpawnsetEditType.Reset => "Spawnset reset",
SpawnsetEditType.ArenaTileHeight => "Arena tile height edit",
SpawnsetEditType.ArenaPencil => "Arena pencil edit",
SpawnsetEditType.ArenaLine => "Arena line edit",
SpawnsetEditType.ArenaRectangle => "Arena rectangle edit",
SpawnsetEditType.ArenaEllipse => "Arena ellipse edit",
SpawnsetEditType.ArenaBucket => "Arena bucket edit",
SpawnsetEditType.RaceDagger => "Race dagger position change",
SpawnsetEditType.ShrinkStart => "Shrink start change",
SpawnsetEditType.ShrinkEnd => "Shrink end change",
SpawnsetEditType.ShrinkRate => "Shrink rate change",
SpawnsetEditType.Brightness => "Brightness change",
SpawnsetEditType.Format => "Format change",
SpawnsetEditType.GameMode => "Game mode change",
SpawnsetEditType.HandLevel => "Hand level change",
SpawnsetEditType.AdditionalGems => "Additional gems change",
SpawnsetEditType.TimerStart => "Timer start change",
SpawnsetEditType.SpawnDelete => "Spawn deletion",
SpawnsetEditType.SpawnAdd => "Spawn addition",
SpawnsetEditType.SpawnEdit => "Spawn edit",
SpawnsetEditType.SpawnInsert => "Spawn insertion",
SpawnsetEditType.SpawnsTransformation => "Spawns transformation",
_ => throw new UnreachableException(),
};
}

public static Color GetColor(this SpawnsetEditType spawnsetEditType) => spawnsetEditType switch
public static Color GetColor(this SpawnsetEditType spawnsetEditType)
{
SpawnsetEditType.Reset => _colorMisc,
SpawnsetEditType.ArenaTileHeight => _colorArena,
SpawnsetEditType.ArenaPencil => _colorArena,
SpawnsetEditType.ArenaLine => _colorArena,
SpawnsetEditType.ArenaRectangle => _colorArena,
SpawnsetEditType.ArenaEllipse => _colorArena,
SpawnsetEditType.ArenaBucket => _colorArena,
SpawnsetEditType.RaceDagger => _colorRaceDagger,
SpawnsetEditType.ShrinkStart => _colorShrink,
SpawnsetEditType.ShrinkEnd => _colorShrink,
SpawnsetEditType.ShrinkRate => _colorShrink,
SpawnsetEditType.Brightness => _colorBrightness,
SpawnsetEditType.Format => _colorMisc,
SpawnsetEditType.GameMode => _colorMisc,
SpawnsetEditType.HandLevel => _colorPractice,
SpawnsetEditType.AdditionalGems => _colorPractice,
SpawnsetEditType.TimerStart => _colorPractice,
SpawnsetEditType.SpawnDelete => _colorSpawn,
SpawnsetEditType.SpawnAdd => _colorSpawn,
SpawnsetEditType.SpawnEdit => _colorSpawn,
SpawnsetEditType.SpawnInsert => _colorSpawn,
SpawnsetEditType.SpawnsTransformation => _colorSpawn,
_ => throw new UnreachableException(),
};
return spawnsetEditType switch
{
SpawnsetEditType.Reset => _colorMisc,
SpawnsetEditType.ArenaTileHeight => _colorArena,
SpawnsetEditType.ArenaPencil => _colorArena,
SpawnsetEditType.ArenaLine => _colorArena,
SpawnsetEditType.ArenaRectangle => _colorArena,
SpawnsetEditType.ArenaEllipse => _colorArena,
SpawnsetEditType.ArenaBucket => _colorArena,
SpawnsetEditType.RaceDagger => _colorRaceDagger,
SpawnsetEditType.ShrinkStart => _colorShrink,
SpawnsetEditType.ShrinkEnd => _colorShrink,
SpawnsetEditType.ShrinkRate => _colorShrink,
SpawnsetEditType.Brightness => _colorBrightness,
SpawnsetEditType.Format => _colorMisc,
SpawnsetEditType.GameMode => _colorMisc,
SpawnsetEditType.HandLevel => _colorPractice,
SpawnsetEditType.AdditionalGems => _colorPractice,
SpawnsetEditType.TimerStart => _colorPractice,
SpawnsetEditType.SpawnDelete => _colorSpawn,
SpawnsetEditType.SpawnAdd => _colorSpawn,
SpawnsetEditType.SpawnEdit => _colorSpawn,
SpawnsetEditType.SpawnInsert => _colorSpawn,
SpawnsetEditType.SpawnsTransformation => _colorSpawn,
_ => throw new UnreachableException(),
};
}
}
19 changes: 11 additions & 8 deletions src/DevilDaggersInfo.Tools/Extensions/AssetTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ namespace DevilDaggersInfo.Tools.Extensions;

public static class AssetTypeExtensions
{
public static Vector4 GetColor(this AssetType assetType) => assetType switch
public static Vector4 GetColor(this AssetType assetType)
{
AssetType.Audio => new Vector4(1, 0.25f, 1, 1),
AssetType.ObjectBinding => new Vector4(0.25f, 1, 1, 1),
AssetType.Mesh => new Vector4(1, 0.25f, 0.25f, 1),
AssetType.Shader => new Vector4(0.25f, 1, 0.25f, 1),
AssetType.Texture => new Vector4(1, 0.66f, 0.25f, 1),
_ => Vector4.One,
};
return assetType switch
{
AssetType.Audio => new Vector4(1, 0.25f, 1, 1),
AssetType.ObjectBinding => new Vector4(0.25f, 1, 1, 1),
AssetType.Mesh => new Vector4(1, 0.25f, 0.25f, 1),
AssetType.Shader => new Vector4(0.25f, 1, 0.25f, 1),
AssetType.Texture => new Vector4(1, 0.66f, 0.25f, 1),
_ => Vector4.One,
};
}
}
27 changes: 15 additions & 12 deletions src/DevilDaggersInfo.Tools/Extensions/GameStatusExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ namespace DevilDaggersInfo.Tools.Extensions;

public static class GameStatusExtensions
{
public static string ToDisplayString(this GameStatus gameStatus) => gameStatus switch
public static string ToDisplayString(this GameStatus gameStatus)
{
GameStatus.Title => "Title",
GameStatus.Menu => "Menu",
GameStatus.Lobby => "Lobby",
GameStatus.Playing => "Playing",
GameStatus.Dead => "Dead",
GameStatus.OwnReplayFromLastRun => "Own replay from last run",
GameStatus.OwnReplayFromLeaderboard => "Own replay from leaderboard",
GameStatus.OtherPlayersReplayFromLeaderboard => "Other player's replay from leaderboard",
GameStatus.LocalReplay => "Local replay",
_ => throw new UnreachableException(),
};
return gameStatus switch
{
GameStatus.Title => "Title",
GameStatus.Menu => "Menu",
GameStatus.Lobby => "Lobby",
GameStatus.Playing => "Playing",
GameStatus.Dead => "Dead",
GameStatus.OwnReplayFromLastRun => "Own replay from last run",
GameStatus.OwnReplayFromLeaderboard => "Own replay from leaderboard",
GameStatus.OtherPlayersReplayFromLeaderboard => "Other player's replay from leaderboard",
GameStatus.LocalReplay => "Local replay",
_ => throw new UnreachableException(),
};
}
}
17 changes: 10 additions & 7 deletions src/DevilDaggersInfo.Tools/Extensions/HandLevelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ namespace DevilDaggersInfo.Tools.Extensions;

public static class HandLevelExtensions
{
public static Color GetColor(this HandLevel handLevel) => handLevel switch
public static Color GetColor(this HandLevel handLevel)
{
HandLevel.Level1 => UpgradeColors.Level1.ToEngineColor(),
HandLevel.Level2 => UpgradeColors.Level2.ToEngineColor(),
HandLevel.Level3 => UpgradeColors.Level3.ToEngineColor(),
HandLevel.Level4 => UpgradeColors.Level4.ToEngineColor(),
_ => throw new UnreachableException(),
};
return handLevel switch
{
HandLevel.Level1 => UpgradeColors.Level1.ToEngineColor(),
HandLevel.Level2 => UpgradeColors.Level2.ToEngineColor(),
HandLevel.Level3 => UpgradeColors.Level3.ToEngineColor(),
HandLevel.Level4 => UpgradeColors.Level4.ToEngineColor(),
_ => throw new UnreachableException(),
};
}
}
5 changes: 4 additions & 1 deletion src/DevilDaggersInfo.Tools/Extensions/WikiColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ namespace DevilDaggersInfo.Tools.Extensions;

public static class WikiColorExtensions
{
public static Color ToEngineColor(this DevilDaggersInfo.Core.Wiki.Structs.Color c) => new(c.R, c.G, c.B, 255);
public static Color ToEngineColor(this DevilDaggersInfo.Core.Wiki.Structs.Color c)
{
return new Color(c.R, c.G, c.B, 255);
}
}
5 changes: 4 additions & 1 deletion src/DevilDaggersInfo.Tools/Scenes/GameObjects/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public static void InitializeRendering()
_vaoHitbox = MeshShaderUtils.CreateVao(Root.InternalResources.TileHitboxModel.MainMesh);
}

public float SquaredDistanceToCamera() => Vector2.DistanceSquared(new Vector2(PositionX, PositionZ), new Vector2(_camera.Position.X, _camera.Position.Z));
public float SquaredDistanceToCamera()
{
return Vector2.DistanceSquared(new Vector2(PositionX, PositionZ), new Vector2(_camera.Position.X, _camera.Position.Z));
}

public void SetDisplayHeight(float height)
{
Expand Down
Loading

0 comments on commit 7a9c6a9

Please sign in to comment.