Handle warnings in the Ide and optimize the code.

处理Ide内的警告,优化代码。
This commit is contained in:
Cold-Mint 2024-07-19 23:18:53 +08:00
parent 36e656cf46
commit db1a771fa7
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
8 changed files with 39 additions and 30 deletions

View File

@ -16,6 +16,16 @@ public class Camp
_friendlyCampIdList = new List<string>(); _friendlyCampIdList = new List<string>();
} }
/// <summary>
/// <para>Add friendly camp ID</para>
/// <para>添加友善的阵营ID</para>
/// </summary>
/// <param name="friendlyCampId"></param>
public void AddFriendlyCampId(string friendlyCampId)
{
_friendlyCampIdList.Add(friendlyCampId);
}
/// <summary> /// <summary>
/// <para>Get camp ID</para> /// <para>Get camp ID</para>
/// <para>获取阵营ID</para> /// <para>获取阵营ID</para>

View File

@ -80,16 +80,16 @@ public sealed partial class AiCharacter : CharacterTemplate
/// <summary> /// <summary>
/// <para>Exclamation bubble Id</para> /// <para>Exclamation bubble id</para>
/// <para>感叹气泡Id</para> /// <para>感叹气泡Id</para>
/// </summary> /// </summary>
private const int plaintBubbleId = 0; private const int PlaintBubbleId = 0;
/// <summary> /// <summary>
/// <para>Query bubble Id</para> /// <para>Query bubble id</para>
/// <para>疑问气泡Id</para> /// <para>疑问气泡Id</para>
/// </summary> /// </summary>
private const int queryBubbleId = 1; private const int QueryBubbleId = 1;
/// <summary> /// <summary>
/// <para>BubbleMarker</para> /// <para>BubbleMarker</para>
@ -134,14 +134,14 @@ public sealed partial class AiCharacter : CharacterTemplate
var plaint = NodeUtils.InstantiatePackedScene<Control>(plaintScene); var plaint = NodeUtils.InstantiatePackedScene<Control>(plaintScene);
if (plaint != null) if (plaint != null)
{ {
_bubbleMarker.AddBubble(plaintBubbleId, plaint); _bubbleMarker.AddBubble(PlaintBubbleId, plaint);
} }
using var queryScene = GD.Load<PackedScene>("res://prefab/ui/query.tscn"); using var queryScene = GD.Load<PackedScene>("res://prefab/ui/query.tscn");
var query = NodeUtils.InstantiatePackedScene<Control>(queryScene); var query = NodeUtils.InstantiatePackedScene<Control>(queryScene);
if (query != null) if (query != null)
{ {
_bubbleMarker.AddBubble(queryBubbleId, query); _bubbleMarker.AddBubble(QueryBubbleId, query);
} }
} }
@ -228,12 +228,12 @@ public sealed partial class AiCharacter : CharacterTemplate
/// </summary> /// </summary>
public void DispladyPlaint() public void DispladyPlaint()
{ {
_bubbleMarker?.ShowBubble(plaintBubbleId); _bubbleMarker?.ShowBubble(PlaintBubbleId);
} }
public void HidePlaint() public void HidePlaint()
{ {
_bubbleMarker?.HideBubble(plaintBubbleId); _bubbleMarker?.HideBubble(PlaintBubbleId);
} }
/// <summary> /// <summary>
@ -242,12 +242,12 @@ public sealed partial class AiCharacter : CharacterTemplate
/// </summary> /// </summary>
public void DispladyQuery() public void DispladyQuery()
{ {
_bubbleMarker?.ShowBubble(queryBubbleId); _bubbleMarker?.ShowBubble(QueryBubbleId);
} }
public void HideQuery() public void HideQuery()
{ {
_bubbleMarker?.HideBubble(queryBubbleId); _bubbleMarker?.HideBubble(QueryBubbleId);
} }
/// <summary> /// <summary>

View File

@ -237,8 +237,7 @@ public static class LogCat
var logData = new LogData var logData = new LogData
{ {
Level = level, Level = level,
Message = concreteLog, Message = concreteLog
AppId = "none"
}; };
LogCollector.Push(logData); LogCollector.Push(logData);
} }

View File

@ -26,15 +26,6 @@ public class RoomSlot
/// </remarks> /// </remarks>
public Vector2I StartPosition { get; set; } public Vector2I StartPosition { get; set; }
/// <summary>
/// <para>The midpoint of the slot</para>
/// <para>插槽的中点位置</para>
/// </summary>
///<remarks>
///<para>As opposed to a tile map. Convert to local location please call <see cref="TileMap.MapToLocal"/></para>
///<para>相对于瓦片地图而言的。转换为本地位置请调用<see cref="TileMap.MapToLocal"/></para>
/// </remarks>
public Vector2I MidpointPosition { get; set; }
/// <summary> /// <summary>
/// <para>The end position of the room slot</para> /// <para>The end position of the room slot</para>

View File

@ -194,12 +194,10 @@ public class Room
//转为瓦片地图的坐标(中点) //转为瓦片地图的坐标(中点)
var tileMapStartPosition = tileMap.LocalToMap(startPosition); var tileMapStartPosition = tileMap.LocalToMap(startPosition);
var tileMapEndPosition = tileMap.LocalToMap(endPosition); var tileMapEndPosition = tileMap.LocalToMap(endPosition);
var midpointPosition = tileMap.LocalToMap(midpointOfRoomSlots);
var roomSlot = new RoomSlot var roomSlot = new RoomSlot
{ {
EndPosition = tileMapEndPosition, EndPosition = tileMapEndPosition,
StartPosition = tileMapStartPosition, 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) //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) DistanceToMidpointOfRoom = CoordinateUtils.VectorToOrientationArray(midpoint, midpointOfRoomSlots)

View File

@ -26,7 +26,7 @@ public static class LogCollector
/// </remarks> /// </remarks>
public static int UploadThreshold { get; set; } = 300; public static int UploadThreshold { get; set; } = 300;
private static bool _lockList = false; private static bool _lockList;
/// <summary> /// <summary>
/// <para>httpClient</para> /// <para>httpClient</para>
@ -36,7 +36,7 @@ public static class LogCollector
private static string? _orgId; private static string? _orgId;
private static string? _streamName; private static string? _streamName;
/// <summary> /// <summary>
/// <para>CanUploadLog</para> /// <para>CanUploadLog</para>
/// <para>是否能上传日志</para> /// <para>是否能上传日志</para>
@ -95,7 +95,7 @@ public static class LogCollector
{ {
//After the upload succeeds, if the threshold is still met, continue uploading. //After the upload succeeds, if the threshold is still met, continue uploading.
//上传成功后,如果依然满足阈值,那么继续上传。 //上传成功后,如果依然满足阈值,那么继续上传。
PostLog(LogDataList.GetRange(0, UploadThreshold)); await PostLog(LogDataList.GetRange(0, UploadThreshold));
} }
} }
else else
@ -105,14 +105,26 @@ public static class LogCollector
} }
} }
public static void Push(LogData logData) /// <summary>
/// <para>Push log information to the cache</para>
/// <para>推送日志信息到缓存</para>
/// </summary>
/// <param name="logData">
///<para>Log data</para>
///<para>日志信息</para>
/// </param>
/// <remarks>
///<para>When logs reach the upload threshold, logs are automatically uploaded.</para>
///<para>当日志信息到达上传阈值后会自动上传。</para>
/// </remarks>
public static async Task Push(LogData logData)
{ {
LogDataList.Add(logData); LogDataList.Add(logData);
LogCat.LogWithFormat("upload_status", LogCat.LogLabel.LogCollector, false, LogDataList.Count, UploadThreshold); LogCat.LogWithFormat("upload_status", LogCat.LogLabel.LogCollector, false, LogDataList.Count, UploadThreshold);
if (!_lockList && LogDataList.Count > UploadThreshold) if (!_lockList && LogDataList.Count > UploadThreshold)
{ {
//执行上传 //执行上传
PostLog(LogDataList.GetRange(0, UploadThreshold)); await PostLog(LogDataList.GetRange(0, UploadThreshold));
} }
} }
} }

View File

@ -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. //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; context.CurrentState = State.Chase;
} }

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using ColdMint.scripts.debug; using ColdMint.scripts.debug;
using Godot; using Godot;