Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code analyzer fix #612

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BossMod/Modules/Global/DeepDungeon/FloorPathfind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum Direction
}

// neat feature of deep dungeons - there is only one path from any room to any other room (no loops) and the grid is so small that brute forcing is basically free!
internal class FloorPathfind(ReadOnlySpan<RoomFlags> Map)
internal sealed class FloorPathfind(ReadOnlySpan<RoomFlags> Map)
{
public readonly RoomFlags[] Map = Map.ToArray();

Expand Down
27 changes: 18 additions & 9 deletions BossMod/Modules/Global/DeepDungeon/LevelData.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
namespace BossMod.Global.DeepDungeon;

public record class Floor<T>(uint DungeonId, uint Floorset, Tileset<T> RoomsA, Tileset<T> RoomsB)
public sealed record class Floor<T>(uint DungeonId, uint Floorset, Tileset<T> RoomsA, Tileset<T> RoomsB)
{
public Floor<M> Map<M>(Func<T, M> Mapping) => new(DungeonId, Floorset, RoomsA.Map(Mapping), RoomsB.Map(Mapping));
}

public record class Tileset<T>(RoomData<T>[] Rooms)
public sealed record class Tileset<T>
{
private readonly RoomData<T>[] _rooms;

public Tileset(RoomData<T>[] rooms)
{
_rooms = rooms;
}

public IReadOnlyList<RoomData<T>> Rooms => _rooms;

public Tileset<M> Map<M>(Func<T, M> Mapping)
{
var len = Rooms.Length;
var len = _rooms.Length;
var mappedRooms = new RoomData<M>[len];
for (var i = 0; i < len; ++i)
{
mappedRooms[i] = Rooms[i].Map(Mapping);
mappedRooms[i] = _rooms[i].Map(Mapping);
}
return new Tileset<M>(mappedRooms);
}

public RoomData<T> this[int index] => Rooms[index];
public RoomData<T> this[int index] => _rooms[index];

public override string ToString()
{
var sb = new StringBuilder();
sb.Append("Tileset { Rooms = [");
var len = Rooms.Length;
var len = _rooms.Length;
for (var i = 0; i < len; ++i)
{
if (i > 0)
{
sb.Append(", ");
}
sb.Append(Rooms[i].ToString());
sb.Append(_rooms[i].ToString());
}
sb.Append("] }");
return sb.ToString();
}
}

public record class RoomData<T>(T Center, T North, T South, T West, T East)
public sealed record class RoomData<T>(T Center, T North, T South, T West, T East)
{
public RoomData<M> Map<M>(Func<T, M> F) => new(F(Center), F(North), F(South), F(West), F(East));
}

public record struct Wall(WPos Position, float Depth);
public readonly record struct Wall(WPos Position, float Depth);
2 changes: 1 addition & 1 deletion BossMod/Modules/Global/DeepDungeon/Minimap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace BossMod.Global.DeepDungeon;

public record class Minimap(DeepDungeonState State, Angle PlayerRotation, int CurrentDestination)
public sealed record class Minimap(DeepDungeonState State, Angle PlayerRotation, int CurrentDestination)
{
enum IconID : uint
{
Expand Down