From db1a771fa767bec02e1a1f7b54ddf04318c150c1 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Fri, 19 Jul 2024 23:18:53 +0800 Subject: [PATCH] =?UTF-8?q?Handle=20warnings=20in=20the=20Ide=20and=20opti?= =?UTF-8?q?mize=20the=20code.=20=E5=A4=84=E7=90=86Ide=E5=86=85=E7=9A=84?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/camp/Camp.cs | 10 +++++++++ scripts/character/AiCharacter.cs | 20 ++++++++--------- scripts/debug/LogCat.cs | 3 +-- scripts/map/dateBean/RoomSlot.cs | 9 -------- scripts/map/room/Room.cs | 2 -- scripts/openObserve/LogCollector.cs | 22 ++++++++++++++----- .../StateProcessor/PatrolStateProcessor.cs | 2 +- scripts/utils/NodeUtils.cs | 1 - 8 files changed, 39 insertions(+), 30 deletions(-) diff --git a/scripts/camp/Camp.cs b/scripts/camp/Camp.cs index 841e707..900bab2 100644 --- a/scripts/camp/Camp.cs +++ b/scripts/camp/Camp.cs @@ -16,6 +16,16 @@ public class Camp _friendlyCampIdList = new List(); } + /// + /// Add friendly camp ID + /// 添加友善的阵营ID + /// + /// + public void AddFriendlyCampId(string friendlyCampId) + { + _friendlyCampIdList.Add(friendlyCampId); + } + /// /// Get camp ID /// 获取阵营ID diff --git a/scripts/character/AiCharacter.cs b/scripts/character/AiCharacter.cs index 505e06b..ca32716 100644 --- a/scripts/character/AiCharacter.cs +++ b/scripts/character/AiCharacter.cs @@ -80,16 +80,16 @@ public sealed partial class AiCharacter : CharacterTemplate /// - /// Exclamation bubble Id + /// Exclamation bubble id /// 感叹气泡Id /// - private const int plaintBubbleId = 0; + private const int PlaintBubbleId = 0; /// - /// Query bubble Id + /// Query bubble id /// 疑问气泡Id /// - private const int queryBubbleId = 1; + private const int QueryBubbleId = 1; /// /// BubbleMarker @@ -134,14 +134,14 @@ public sealed partial class AiCharacter : CharacterTemplate var plaint = NodeUtils.InstantiatePackedScene(plaintScene); if (plaint != null) { - _bubbleMarker.AddBubble(plaintBubbleId, plaint); + _bubbleMarker.AddBubble(PlaintBubbleId, plaint); } using var queryScene = GD.Load("res://prefab/ui/query.tscn"); var query = NodeUtils.InstantiatePackedScene(queryScene); if (query != null) { - _bubbleMarker.AddBubble(queryBubbleId, query); + _bubbleMarker.AddBubble(QueryBubbleId, query); } } @@ -228,12 +228,12 @@ public sealed partial class AiCharacter : CharacterTemplate /// public void DispladyPlaint() { - _bubbleMarker?.ShowBubble(plaintBubbleId); + _bubbleMarker?.ShowBubble(PlaintBubbleId); } public void HidePlaint() { - _bubbleMarker?.HideBubble(plaintBubbleId); + _bubbleMarker?.HideBubble(PlaintBubbleId); } /// @@ -242,12 +242,12 @@ public sealed partial class AiCharacter : CharacterTemplate /// public void DispladyQuery() { - _bubbleMarker?.ShowBubble(queryBubbleId); + _bubbleMarker?.ShowBubble(QueryBubbleId); } public void HideQuery() { - _bubbleMarker?.HideBubble(queryBubbleId); + _bubbleMarker?.HideBubble(QueryBubbleId); } /// diff --git a/scripts/debug/LogCat.cs b/scripts/debug/LogCat.cs index aaab15b..9c0789c 100644 --- a/scripts/debug/LogCat.cs +++ b/scripts/debug/LogCat.cs @@ -237,8 +237,7 @@ public static class LogCat var logData = new LogData { Level = level, - Message = concreteLog, - AppId = "none" + Message = concreteLog }; LogCollector.Push(logData); } diff --git a/scripts/map/dateBean/RoomSlot.cs b/scripts/map/dateBean/RoomSlot.cs index a948b19..8124710 100644 --- a/scripts/map/dateBean/RoomSlot.cs +++ b/scripts/map/dateBean/RoomSlot.cs @@ -26,15 +26,6 @@ public class RoomSlot /// public Vector2I StartPosition { get; set; } - /// - /// The midpoint of the slot - /// 插槽的中点位置 - /// - /// - ///As opposed to a tile map. Convert to local location please call - ///相对于瓦片地图而言的。转换为本地位置请调用 - /// - public Vector2I MidpointPosition { get; set; } /// /// The end position of the room slot diff --git a/scripts/map/room/Room.cs b/scripts/map/room/Room.cs index 73b89db..8a497db 100644 --- a/scripts/map/room/Room.cs +++ b/scripts/map/room/Room.cs @@ -194,12 +194,10 @@ public class Room //转为瓦片地图的坐标(中点) var tileMapStartPosition = tileMap.LocalToMap(startPosition); var tileMapEndPosition = tileMap.LocalToMap(endPosition); - var midpointPosition = tileMap.LocalToMap(midpointOfRoomSlots); var roomSlot = new RoomSlot { EndPosition = tileMapEndPosition, StartPosition = tileMapStartPosition, - MidpointPosition = midpointPosition, //Calculate the orientation of the slot (the midpoint of the room is the origin, the vector pointing to the midpoint of the slot) //计算槽位的方向(房间中点为原点,指向槽位中点的向量) DistanceToMidpointOfRoom = CoordinateUtils.VectorToOrientationArray(midpoint, midpointOfRoomSlots) diff --git a/scripts/openObserve/LogCollector.cs b/scripts/openObserve/LogCollector.cs index 9e137c4..13bf2e2 100644 --- a/scripts/openObserve/LogCollector.cs +++ b/scripts/openObserve/LogCollector.cs @@ -26,7 +26,7 @@ public static class LogCollector /// public static int UploadThreshold { get; set; } = 300; - private static bool _lockList = false; + private static bool _lockList; /// /// httpClient @@ -36,7 +36,7 @@ public static class LogCollector private static string? _orgId; private static string? _streamName; - + /// /// CanUploadLog /// 是否能上传日志 @@ -95,7 +95,7 @@ public static class LogCollector { //After the upload succeeds, if the threshold is still met, continue uploading. //上传成功后,如果依然满足阈值,那么继续上传。 - PostLog(LogDataList.GetRange(0, UploadThreshold)); + await PostLog(LogDataList.GetRange(0, UploadThreshold)); } } else @@ -105,14 +105,26 @@ public static class LogCollector } } - public static void Push(LogData logData) + /// + /// Push log information to the cache + /// 推送日志信息到缓存 + /// + /// + ///Log data + ///日志信息 + /// + /// + ///When logs reach the upload threshold, logs are automatically uploaded. + ///当日志信息到达上传阈值后会自动上传。 + /// + public static async Task Push(LogData logData) { LogDataList.Add(logData); LogCat.LogWithFormat("upload_status", LogCat.LogLabel.LogCollector, false, LogDataList.Count, UploadThreshold); if (!_lockList && LogDataList.Count > UploadThreshold) { //执行上传 - PostLog(LogDataList.GetRange(0, UploadThreshold)); + await PostLog(LogDataList.GetRange(0, UploadThreshold)); } } } diff --git a/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs b/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs index b2f66ba..6aa41e7 100644 --- a/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs +++ b/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs @@ -47,7 +47,7 @@ public class PatrolStateProcessor : StateProcessorTemplate { //Once the enemy enters the reconnaissance range, we first see if the character has a weapon, if so, then pursue the enemy, otherwise, the patrol state changes to looking for weapons. //发现敌人进入侦察范围后,我们先看角色是否持有武器,如果有,那么追击敌人,否则,巡逻状态转换为寻找武器。 - if (aiCharacter.CurrentItem is WeaponTemplate weaponTemplate) + if (aiCharacter.CurrentItem is WeaponTemplate) { context.CurrentState = State.Chase; } diff --git a/scripts/utils/NodeUtils.cs b/scripts/utils/NodeUtils.cs index 2b5dcb4..7d7224e 100644 --- a/scripts/utils/NodeUtils.cs +++ b/scripts/utils/NodeUtils.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; using ColdMint.scripts.debug; using Godot;