From 4ded5e05291968fbb2d1044bb886b67b8e009aaf Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 9 May 2023 22:57:42 +0900 Subject: [PATCH] C# style --- .../Io/Compress/FastLz.cs | 24 +++++++-------- .../TileCacheBuilder.cs | 7 +---- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 26 ----------------- .../Tools/CrowdToolMode.cs | 29 +++++++++++++++++++ src/DotRecast.Recast/Geom/BoundsItem.cs | 11 +++++++ src/DotRecast.Recast/Geom/ChunkyTriMesh.cs | 25 +--------------- src/DotRecast.Recast/Geom/CompareItemX.cs | 12 ++++++++ src/DotRecast.Recast/Geom/CompareItemY.cs | 12 ++++++++ .../IRecastBuilderProgressListener.cs | 7 +++++ src/DotRecast.Recast/InputGeomReader.cs | 6 ---- src/DotRecast.Recast/RecastBuilder.cs | 7 +---- 11 files changed, 86 insertions(+), 80 deletions(-) create mode 100644 src/DotRecast.Recast.Demo/Tools/CrowdToolMode.cs create mode 100644 src/DotRecast.Recast/Geom/BoundsItem.cs create mode 100644 src/DotRecast.Recast/Geom/CompareItemX.cs create mode 100644 src/DotRecast.Recast/Geom/CompareItemY.cs create mode 100644 src/DotRecast.Recast/IRecastBuilderProgressListener.cs delete mode 100644 src/DotRecast.Recast/InputGeomReader.cs diff --git a/src/DotRecast.Detour.TileCache/Io/Compress/FastLz.cs b/src/DotRecast.Detour.TileCache/Io/Compress/FastLz.cs index 7cccd8b..6079c75 100644 --- a/src/DotRecast.Detour.TileCache/Io/Compress/FastLz.cs +++ b/src/DotRecast.Detour.TileCache/Io/Compress/FastLz.cs @@ -41,23 +41,23 @@ namespace DotRecast.Detour.TileCache.Io.Compress private static readonly int MIN_RECOMENDED_LENGTH_FOR_LEVEL_2 = 1024 * 64; - static readonly int MAGIC_NUMBER = 'F' << 16 | 'L' << 8 | 'Z'; + private static readonly int MAGIC_NUMBER = 'F' << 16 | 'L' << 8 | 'Z'; - static readonly byte BLOCK_TYPE_NON_COMPRESSED = 0x00; - static readonly byte BLOCK_TYPE_COMPRESSED = 0x01; - static readonly byte BLOCK_WITHOUT_CHECKSUM = 0x00; - static readonly byte BLOCK_WITH_CHECKSUM = 0x10; + private static readonly byte BLOCK_TYPE_NON_COMPRESSED = 0x00; + private static readonly byte BLOCK_TYPE_COMPRESSED = 0x01; + private static readonly byte BLOCK_WITHOUT_CHECKSUM = 0x00; + private static readonly byte BLOCK_WITH_CHECKSUM = 0x10; - static readonly int OPTIONS_OFFSET = 3; - static readonly int CHECKSUM_OFFSET = 4; + private static readonly int OPTIONS_OFFSET = 3; + private static readonly int CHECKSUM_OFFSET = 4; - static readonly int MAX_CHUNK_LENGTH = 0xFFFF; + private static readonly int MAX_CHUNK_LENGTH = 0xFFFF; /** * Do not call {@link #Compress(byte[], int, int, byte[], int, int)} for input buffers * which length less than this value. */ - static readonly int MIN_LENGTH_TO_COMPRESSION = 32; + private static readonly int MIN_LENGTH_TO_COMPRESSION = 32; /** * In this case {@link #Compress(byte[], int, int, byte[], int, int)} will choose level @@ -65,17 +65,17 @@ namespace DotRecast.Detour.TileCache.Io.Compress * {@link #MIN_RECOMENDED_LENGTH_FOR_LEVEL_2} {@link #LEVEL_1} will be choosen, * otherwise {@link #LEVEL_2}. */ - static readonly int LEVEL_AUTO = 0; + private static readonly int LEVEL_AUTO = 0; /** * Level 1 is the fastest compression and generally useful for short data. */ - static readonly int LEVEL_1 = 1; + private static readonly int LEVEL_1 = 1; /** * Level 2 is slightly slower but it gives better compression ratio. */ - static readonly int LEVEL_2 = 2; + private static readonly int LEVEL_2 = 2; /** * The output buffer must be at least 6% larger than the input buffer and can not be smaller than 66 bytes. diff --git a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs index 68219cd..688ed48 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs +++ b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs @@ -35,11 +35,6 @@ namespace DotRecast.Detour.TileCache const int DT_TILECACHE_NULL_IDX = 0xffff; - - - - - private readonly TileCacheLayerHeaderReader reader = new TileCacheLayerHeaderReader(); public void BuildTileCacheRegions(TileCacheLayer layer, int walkableClimb) @@ -2063,4 +2058,4 @@ namespace DotRecast.Detour.TileCache } } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index 0ff80be..decac0c 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -36,32 +36,6 @@ using static DotRecast.Core.RecastMath; namespace DotRecast.Recast.Demo.Tools; -public class CrowdToolMode -{ - public static readonly CrowdToolMode CREATE = new(0, "Create Agents"); - public static readonly CrowdToolMode MOVE_TARGET = new(1, "Move Target"); - public static readonly CrowdToolMode SELECT = new(2, "Select Agent"); - public static readonly CrowdToolMode TOGGLE_POLYS = new(3, "Toggle Polys"); - public static readonly CrowdToolMode PROFILING = new(4, "Profiling"); - - public static readonly ImmutableArray Values = ImmutableArray.Create( - CREATE, - MOVE_TARGET, - SELECT, - TOGGLE_POLYS, - PROFILING - ); - - public int Idx { get; } - public string Label { get; } - - private CrowdToolMode(int idx, string label) - { - Idx = idx; - Label = label; - } -} - public class CrowdTool : Tool { private readonly CrowdToolParams toolParams = new CrowdToolParams(); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdToolMode.cs b/src/DotRecast.Recast.Demo/Tools/CrowdToolMode.cs new file mode 100644 index 0000000..38ac056 --- /dev/null +++ b/src/DotRecast.Recast.Demo/Tools/CrowdToolMode.cs @@ -0,0 +1,29 @@ +using System.Collections.Immutable; + +namespace DotRecast.Recast.Demo.Tools; + +public class CrowdToolMode +{ + public static readonly CrowdToolMode CREATE = new(0, "Create Agents"); + public static readonly CrowdToolMode MOVE_TARGET = new(1, "Move Target"); + public static readonly CrowdToolMode SELECT = new(2, "Select Agent"); + public static readonly CrowdToolMode TOGGLE_POLYS = new(3, "Toggle Polys"); + public static readonly CrowdToolMode PROFILING = new(4, "Profiling"); + + public static readonly ImmutableArray Values = ImmutableArray.Create( + CREATE, + MOVE_TARGET, + SELECT, + TOGGLE_POLYS, + PROFILING + ); + + public int Idx { get; } + public string Label { get; } + + private CrowdToolMode(int idx, string label) + { + Idx = idx; + Label = label; + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/Geom/BoundsItem.cs b/src/DotRecast.Recast/Geom/BoundsItem.cs new file mode 100644 index 0000000..93a6c57 --- /dev/null +++ b/src/DotRecast.Recast/Geom/BoundsItem.cs @@ -0,0 +1,11 @@ +using DotRecast.Core; + +namespace DotRecast.Recast.Geom +{ + public class BoundsItem + { + public Vector2f bmin; + public Vector2f bmax; + public int i; + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs b/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs index 3807088..d9e99b5 100644 --- a/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs +++ b/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs @@ -24,29 +24,6 @@ using DotRecast.Core; namespace DotRecast.Recast.Geom { - public class BoundsItem - { - public Vector2f bmin; - public Vector2f bmax; - public int i; - } - - public class CompareItemX : IComparer - { - public int Compare(BoundsItem a, BoundsItem b) - { - return a.bmin.x.CompareTo(b.bmin.x); - } - } - - public class CompareItemY : IComparer - { - public int Compare(BoundsItem a, BoundsItem b) - { - return a.bmin.y.CompareTo(b.bmin.y); - } - } - public class ChunkyTriMesh { List nodes; @@ -315,4 +292,4 @@ namespace DotRecast.Recast.Geom return true; } } -} +} \ No newline at end of file diff --git a/src/DotRecast.Recast/Geom/CompareItemX.cs b/src/DotRecast.Recast/Geom/CompareItemX.cs new file mode 100644 index 0000000..4364bbf --- /dev/null +++ b/src/DotRecast.Recast/Geom/CompareItemX.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace DotRecast.Recast.Geom +{ + public class CompareItemX : IComparer + { + public int Compare(BoundsItem a, BoundsItem b) + { + return a.bmin.x.CompareTo(b.bmin.x); + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/Geom/CompareItemY.cs b/src/DotRecast.Recast/Geom/CompareItemY.cs new file mode 100644 index 0000000..a00c31b --- /dev/null +++ b/src/DotRecast.Recast/Geom/CompareItemY.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace DotRecast.Recast.Geom +{ + public class CompareItemY : IComparer + { + public int Compare(BoundsItem a, BoundsItem b) + { + return a.bmin.y.CompareTo(b.bmin.y); + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/IRecastBuilderProgressListener.cs b/src/DotRecast.Recast/IRecastBuilderProgressListener.cs new file mode 100644 index 0000000..eecc49e --- /dev/null +++ b/src/DotRecast.Recast/IRecastBuilderProgressListener.cs @@ -0,0 +1,7 @@ +namespace DotRecast.Recast +{ + public interface IRecastBuilderProgressListener + { + void OnProgress(int completed, int total); + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast/InputGeomReader.cs b/src/DotRecast.Recast/InputGeomReader.cs deleted file mode 100644 index 90030a4..0000000 --- a/src/DotRecast.Recast/InputGeomReader.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotRecast.Recast -{ - public class InputGeomReader - { - } -} \ No newline at end of file diff --git a/src/DotRecast.Recast/RecastBuilder.cs b/src/DotRecast.Recast/RecastBuilder.cs index 79c451f..a278541 100644 --- a/src/DotRecast.Recast/RecastBuilder.cs +++ b/src/DotRecast.Recast/RecastBuilder.cs @@ -29,11 +29,6 @@ namespace DotRecast.Recast { public class RecastBuilder { - public interface IRecastBuilderProgressListener - { - void OnProgress(int completed, int total); - } - private readonly IRecastBuilderProgressListener progressListener; public RecastBuilder() @@ -321,4 +316,4 @@ namespace DotRecast.Recast return RecastLayers.BuildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight); } } -} +} \ No newline at end of file