Fixed warnings given by RiderIDE.

修复RiderIDE给出的警告。
This commit is contained in:
Cold-Mint 2024-07-25 20:32:59 +08:00
parent f0f954f10c
commit 6c1b7b2e84
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
17 changed files with 84 additions and 40 deletions

View File

@ -47,7 +47,9 @@ public class AppConfigData
/// <para>OpenObserve configuration information</para>
/// <para>OpenObserve的配置信息</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public OpenObserve? OpenObserve { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}
/// <summary>
@ -60,23 +62,31 @@ public class OpenObserve
/// <para>server address</para>
/// <para>服务器地址</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? Address { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Access Token</para>
/// <para>访问密匙</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? AccessToken { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Organization ID</para>
/// <para>组织ID</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? OrgId { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Stream Name</para>
/// <para>流名称</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? StreamName { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -20,7 +20,6 @@ public sealed partial class AiCharacter : CharacterTemplate
//用于检测墙壁的射线
private RayCast2D? _wallDetection;
public RayCast2D? WallDetection => _wallDetection;
private Vector2 _wallDetectionOrigin;
private Area2D? _attackArea;
@ -70,13 +69,21 @@ public sealed partial class AiCharacter : CharacterTemplate
/// <para>Navigation agent</para>
/// <para>导航代理</para>
/// </summary>
public NavigationAgent2D? NavigationAgent2D { get; set; }
private NavigationAgent2D? NavigationAgent2D { get; set; }
public IStateMachine? StateMachine { get; set; }
/// <summary>
/// <para>State machine</para>
/// <para>状态机</para>
/// </summary>
private IStateMachine? StateMachine { get; set; }
public RayCast2D? AttackObstacleDetection => _attackObstacleDetection;
/// <summary>
/// <para>Attack obstacle detection</para>
/// <para>攻击障碍物检测</para>
/// </summary>
private RayCast2D? AttackObstacleDetection => _attackObstacleDetection;
/// <summary>

View File

@ -244,7 +244,9 @@ public static class LogCat
Level = level,
Message = concreteLog
};
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
LogCollector.Push(logData);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
switch (level)

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ColdMint.scripts.debug;
using ColdMint.scripts.serialization;
using ColdMint.scripts.utils;
@ -53,16 +52,24 @@ public static class ItemTypeRegister
LogCat.LogWithFormat("found_files", LogCat.LogLabel.Default, LogCat.UploadFormat, files.Length);
//将文件解析为项目类型信息
//parse files to item type infos
IEnumerable<ItemTypeInfo> typeInfos =
files.SelectMany(file => ParseFile($"{itemRegsDirPath}/{file}")).ToList();
LogCat.LogWithFormat("found_item_types", LogCat.LogLabel.Default, LogCat.UploadFormat, typeInfos.Count());
//遍历类型信息并注册它们。
//traverse type infos and register them.
foreach (var typeInfo in typeInfos)
var count = 0;
foreach (var file in files)
{
RegisterTypeInfo(typeInfo);
var list = ParseFile($"{itemRegsDirPath}/{file}");
if (list == null)
{
continue;
}
foreach (var itemTypeInfo in list)
{
RegisterTypeInfo(itemTypeInfo);
}
count++;
}
LogCat.LogWithFormat("found_item_types", LogCat.LogLabel.Default, LogCat.UploadFormat, count);
}
/// <summary>
@ -74,7 +81,6 @@ public static class ItemTypeRegister
private static IList<ItemTypeInfo>? ParseFile(string filePath)
{
var yamlFile = FileAccess.Open(filePath, FileAccess.ModeFlags.Read);
//Read & deserialize
//阅读和反序列化
var yamlString = yamlFile.GetAsText();
@ -83,6 +89,14 @@ public static class ItemTypeRegister
return typeInfos;
}
/// <summary>
/// <para>Registration type info</para>
/// <para>注册类型信息</para>
/// </summary>
/// <param name="typeInfo">
///<para>typeInfo</para>
///<para>类型信息</para>
/// </param>
private static void RegisterTypeInfo(ItemTypeInfo typeInfo)
{
//Load scene and icon

View File

@ -10,11 +10,15 @@ public class RoomInjectionProcessorData
/// <para>Room injection processor ID</para>
/// <para>房间注入处理器ID</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? Id { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Room injection processor configuration information</para>
/// <para>房间注入处理器的配置信息</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? Config { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -18,9 +18,13 @@ public class RoomNodeData
/// </summary>
public string? RoomInjectionProcessorData { get; set; }
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? EnterRoomEventHandlerId { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? ExitRoomEventHandlerId { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Whether a tag is held</para>

View File

@ -223,7 +223,7 @@ public static class MapGenerator
{
var roomInjectionProcessorDataArray =
YamlSerialization.Deserialize<RoomInjectionProcessorData[]>(roomInjectionProcessorData);
if (roomInjectionProcessorDataArray.Length > 0)
if (roomInjectionProcessorDataArray is { Length: > 0 })
{
foreach (var injectionProcessorData in roomInjectionProcessorDataArray)
{

View File

@ -17,5 +17,7 @@ public class AiCharacterGenerateEvent
/// <para>The Tag used to generate the role</para>
/// <para>生成角色时使用的Tag</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? Tag { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -13,5 +13,7 @@ public class MapGenerationCompleteEvent
/// <para>Random number generator generated from seed</para>
/// <para>根据种子生成的随机数生成器</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public RandomNumberGenerator? RandomNumberGenerator { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -8,5 +8,11 @@ namespace ColdMint.scripts.map.events;
/// </summary>
public class PlayerInstanceChangeEvent
{
/// <summary>
/// <para>New player instance</para>
/// <para>新的玩家实例</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public Player? PlayerInstance { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -18,5 +18,7 @@ public class SelectedItemSlotChangeEvent
/// <para>Lost the selected item slot</para>
/// <para>失去选中的物品槽</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public ItemSlotNode? OldItemSlotNode { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -48,6 +48,8 @@ public class ChanceRoomInjectionProcessor : RoomInjectionProcessorTemplate<Chanc
///<para>The value ranges from 1 to 100. For example, if it is set to 1.5, it means that there is a 1.5% probability of generating this room.</para>
///<para>支持小数范围为1-100。例如如果设置为1.5则表示1.5%的概率生成此房间。</para>
/// </para>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public float? Chance { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Data;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
using ColdMint.scripts.debug;
using ColdMint.scripts.utils;

View File

@ -29,7 +29,9 @@ public class ModManifest
///<para>Allow relative paths, such as:... / Points to the parent directory.</para>
///<para>允许使用相对路径,例如: ../指向上级目录。</para>
/// </remarks>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string[]? DllList { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Pck path list of mod</para>
@ -39,7 +41,9 @@ public class ModManifest
///<para>Allow relative paths, such as:... / Points to the parent directory.</para>
///<para>允许使用相对路径,例如: ../指向上级目录。</para>
/// </remarks>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string[]? PckList { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>Creates module list information from a path</para>

View File

@ -141,11 +141,15 @@ public class LogData
/// <para>message</para>
/// <para>消息</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string? Message { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary>
/// <para>level</para>
/// <para>错误等级</para>
/// </summary>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public int Level { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
}

View File

@ -11,7 +11,7 @@ namespace ColdMint.scripts.stateMachine.StateProcessor;
/// </summary>
public class PatrolStateProcessor : StateProcessorTemplate
{
public Vector2[]? Points { get; set; }
public Vector2[]? Points { get; init; }
/// <summary>
/// <para>Whether to guard the origin</para>
@ -21,7 +21,9 @@ public class PatrolStateProcessor : StateProcessorTemplate
///<para>When empty by default, PatrolStateProcessor will take the first point where the character touches the ground as the origin. This property handles whether or not the origin is "guarded" when the character is attracted to another character, such as chasing an enemy, and switches back to patrol mode. If set to true, the role tries to return to the origin, otherwise, a new origin is assigned.</para>
///<para>默认清空下PatrolStateProcessor会将角色与地面接触的第一个位置当作原点。这个属性用来处理当角色被其他角色所吸引例如追击敌人转换回巡逻模式是否“守护”原点。如果设置为true则角色会尝试返回原点否则将分配新的原点。</para>
/// </remarks>
// ReSharper disable UnusedAutoPropertyAccessor.Global
public bool Guard { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
private int _index;
private Vector2? _originPosition;
@ -47,15 +49,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)
{
context.CurrentState = State.Chase;
}
else
{
context.CurrentState = State.LookForWeapon;
}
context.CurrentState = aiCharacter.CurrentItem is WeaponTemplate ? State.Chase : State.LookForWeapon;
LogCat.Log("patrol_enemy_detected", label: LogCat.LogLabel.PatrolStateProcessor);
return;
}

View File

@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using ColdMint.scripts.debug;
using ColdMint.scripts.projectile;
using Godot;
@ -46,7 +45,7 @@ public static class NodeUtils
/// <param name="childNode"></param>
public static void CallDeferredReparent(Node parentNode, Node childNode)
{
childNode.CallDeferred("reparent", parentNode);
childNode.CallDeferred(Node.MethodName.Reparent, parentNode);
}
@ -152,17 +151,6 @@ public static class NodeUtils
}
}
/// <summary>
/// <para>All child nodes are removed asynchronously</para>
/// <para>异步删除所有子节点</para>
/// </summary>
/// <param name="parent"></param>
/// <returns></returns>
public static async Task<int> DeleteAllChildAsync(Node parent)
{
return await Task.Run(() => DeleteAllChild(parent));
}
/// <summary>
/// <para>Gets the node closest to the origin</para>
/// <para>获取距离原点最近的节点</para>
@ -284,7 +272,7 @@ public static class NodeUtils
if (node is T result) return result;
// If the transformation fails, release the created node
//如果转型失败,释放所创建的节点
LogCat.LogWarningWithFormat("warning_node_cannot_cast_to", LogCat.LogLabel.Default,LogCat.UploadFormat, node,
LogCat.LogWarningWithFormat("warning_node_cannot_cast_to", LogCat.LogLabel.Default, LogCat.UploadFormat, node,
nameof(T));
node.QueueFree();
return null;