From 729aee68c791229e5b4a0e4372600065b045a85e Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 29 Aug 2023 13:49:18 +0900 Subject: [PATCH] readonly struct ObstacleRequest --- src/DotRecast.Detour.TileCache/DtTileCache.cs | 8 ++------ src/DotRecast.Detour.TileCache/ObstacleRequest.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/DotRecast.Detour.TileCache/DtTileCache.cs b/src/DotRecast.Detour.TileCache/DtTileCache.cs index 26acff8..f5c4f15 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCache.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCache.cs @@ -385,9 +385,7 @@ namespace DotRecast.Detour.TileCache private ObstacleRequest AddObstacleRequest(DtTileCacheObstacle ob) { - ObstacleRequest req = new ObstacleRequest(); - req.action = ObstacleRequestAction.REQUEST_ADD; - req.refs = GetObstacleRef(ob); + ObstacleRequest req = new ObstacleRequest(ObstacleRequestAction.REQUEST_ADD, GetObstacleRef(ob)); m_reqs.Add(req); return req; } @@ -399,9 +397,7 @@ namespace DotRecast.Detour.TileCache return; } - ObstacleRequest req = new ObstacleRequest(); - req.action = ObstacleRequestAction.REQUEST_REMOVE; - req.refs = refs; + ObstacleRequest req = new ObstacleRequest(ObstacleRequestAction.REQUEST_REMOVE, refs); m_reqs.Add(req); } diff --git a/src/DotRecast.Detour.TileCache/ObstacleRequest.cs b/src/DotRecast.Detour.TileCache/ObstacleRequest.cs index 7fffca3..4051370 100644 --- a/src/DotRecast.Detour.TileCache/ObstacleRequest.cs +++ b/src/DotRecast.Detour.TileCache/ObstacleRequest.cs @@ -20,9 +20,15 @@ freely, subject to the following restrictions: namespace DotRecast.Detour.TileCache { - public class ObstacleRequest + public readonly struct ObstacleRequest { - public ObstacleRequestAction action; - public long refs; + public readonly ObstacleRequestAction action; + public readonly long refs; + + public ObstacleRequest(ObstacleRequestAction action, long refs) + { + this.action = action; + this.refs = refs; + } } } \ No newline at end of file