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>();
}
/// <summary>
/// <para>Add friendly camp ID</para>
/// <para>添加友善的阵营ID</para>
/// </summary>
/// <param name="friendlyCampId"></param>
public void AddFriendlyCampId(string friendlyCampId)
{
_friendlyCampIdList.Add(friendlyCampId);
}
/// <summary>
/// <para>Get camp ID</para>
/// <para>获取阵营ID</para>

View File

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

View File

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

View File

@ -26,15 +26,6 @@ public class RoomSlot
/// </remarks>
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>
/// <para>The end position of the room slot</para>

View File

@ -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)

View File

@ -26,7 +26,7 @@ public static class LogCollector
/// </remarks>
public static int UploadThreshold { get; set; } = 300;
private static bool _lockList = false;
private static bool _lockList;
/// <summary>
/// <para>httpClient</para>
@ -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)
/// <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);
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));
}
}
}

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.
//发现敌人进入侦察范围后,我们先看角色是否持有武器,如果有,那么追击敌人,否则,巡逻状态转换为寻找武器。
if (aiCharacter.CurrentItem is WeaponTemplate weaponTemplate)
if (aiCharacter.CurrentItem is WeaponTemplate)
{
context.CurrentState = State.Chase;
}

View File

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