diff --git a/scripts/AppConfig.cs b/scripts/AppConfig.cs index 9b19987..b40863f 100644 --- a/scripts/AppConfig.cs +++ b/scripts/AppConfig.cs @@ -47,7 +47,9 @@ public class AppConfigData /// OpenObserve configuration information /// OpenObserve的配置信息 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public OpenObserve? OpenObserve { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } /// @@ -60,23 +62,31 @@ public class OpenObserve /// server address /// 服务器地址 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? Address { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Access Token /// 访问密匙 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? AccessToken { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Organization ID /// 组织ID /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? OrgId { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Stream Name /// 流名称 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? StreamName { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/character/AiCharacter.cs b/scripts/character/AiCharacter.cs index ca32716..e0c92ac 100644 --- a/scripts/character/AiCharacter.cs +++ b/scripts/character/AiCharacter.cs @@ -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 /// Navigation agent /// 导航代理 /// - public NavigationAgent2D? NavigationAgent2D { get; set; } + private NavigationAgent2D? NavigationAgent2D { get; set; } - public IStateMachine? StateMachine { get; set; } + /// + /// State machine + /// 状态机 + /// + private IStateMachine? StateMachine { get; set; } - public RayCast2D? AttackObstacleDetection => _attackObstacleDetection; + /// + /// Attack obstacle detection + /// 攻击障碍物检测 + /// + private RayCast2D? AttackObstacleDetection => _attackObstacleDetection; /// diff --git a/scripts/debug/LogCat.cs b/scripts/debug/LogCat.cs index 3506362..599822a 100644 --- a/scripts/debug/LogCat.cs +++ b/scripts/debug/LogCat.cs @@ -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) diff --git a/scripts/inventory/ItemTypeRegister.cs b/scripts/inventory/ItemTypeRegister.cs index 200c893..54cb3b3 100644 --- a/scripts/inventory/ItemTypeRegister.cs +++ b/scripts/inventory/ItemTypeRegister.cs @@ -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 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); } /// @@ -74,7 +81,6 @@ public static class ItemTypeRegister private static IList? 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; } + /// + /// Registration type info + /// 注册类型信息 + /// + /// + ///typeInfo + ///类型信息 + /// private static void RegisterTypeInfo(ItemTypeInfo typeInfo) { //Load scene and icon diff --git a/scripts/levelGraphEditor/RoomInjectionProcessorData.cs b/scripts/levelGraphEditor/RoomInjectionProcessorData.cs index b82c9cb..ccf53e7 100644 --- a/scripts/levelGraphEditor/RoomInjectionProcessorData.cs +++ b/scripts/levelGraphEditor/RoomInjectionProcessorData.cs @@ -10,11 +10,15 @@ public class RoomInjectionProcessorData /// Room injection processor ID /// 房间注入处理器ID /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? Id { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Room injection processor configuration information /// 房间注入处理器的配置信息 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? Config { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/levelGraphEditor/RoomNodeData.cs b/scripts/levelGraphEditor/RoomNodeData.cs index fc178a0..99b818a 100644 --- a/scripts/levelGraphEditor/RoomNodeData.cs +++ b/scripts/levelGraphEditor/RoomNodeData.cs @@ -18,9 +18,13 @@ public class RoomNodeData /// 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 /// /// Whether a tag is held diff --git a/scripts/map/MapGenerator.cs b/scripts/map/MapGenerator.cs index 623012c..de246b0 100644 --- a/scripts/map/MapGenerator.cs +++ b/scripts/map/MapGenerator.cs @@ -223,7 +223,7 @@ public static class MapGenerator { var roomInjectionProcessorDataArray = YamlSerialization.Deserialize(roomInjectionProcessorData); - if (roomInjectionProcessorDataArray.Length > 0) + if (roomInjectionProcessorDataArray is { Length: > 0 }) { foreach (var injectionProcessorData in roomInjectionProcessorDataArray) { diff --git a/scripts/map/events/AiCharacterGenerateEvent.cs b/scripts/map/events/AiCharacterGenerateEvent.cs index 5bc42c2..37ad9bd 100644 --- a/scripts/map/events/AiCharacterGenerateEvent.cs +++ b/scripts/map/events/AiCharacterGenerateEvent.cs @@ -17,5 +17,7 @@ public class AiCharacterGenerateEvent /// The Tag used to generate the role /// 生成角色时使用的Tag /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? Tag { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/map/events/MapGenerationCompleteEvent.cs b/scripts/map/events/MapGenerationCompleteEvent.cs index b39a1e9..74cb90a 100644 --- a/scripts/map/events/MapGenerationCompleteEvent.cs +++ b/scripts/map/events/MapGenerationCompleteEvent.cs @@ -13,5 +13,7 @@ public class MapGenerationCompleteEvent /// Random number generator generated from seed /// 根据种子生成的随机数生成器 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public RandomNumberGenerator? RandomNumberGenerator { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/map/events/PlayerInstanceChangeEvent.cs b/scripts/map/events/PlayerInstanceChangeEvent.cs index 63a77b8..f08abfb 100644 --- a/scripts/map/events/PlayerInstanceChangeEvent.cs +++ b/scripts/map/events/PlayerInstanceChangeEvent.cs @@ -8,5 +8,11 @@ namespace ColdMint.scripts.map.events; /// public class PlayerInstanceChangeEvent { + /// + /// New player instance + /// 新的玩家实例 + /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public Player? PlayerInstance { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/map/events/SelectedItemSlotChangeEvent.cs b/scripts/map/events/SelectedItemSlotChangeEvent.cs index 00514e9..77d8886 100644 --- a/scripts/map/events/SelectedItemSlotChangeEvent.cs +++ b/scripts/map/events/SelectedItemSlotChangeEvent.cs @@ -18,5 +18,7 @@ public class SelectedItemSlotChangeEvent /// Lost the selected item slot /// 失去选中的物品槽 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public ItemSlotNode? OldItemSlotNode { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/map/roomInjectionProcessor/ChanceRoomInjectionProcessor.cs b/scripts/map/roomInjectionProcessor/ChanceRoomInjectionProcessor.cs index 2474bbe..1962ea5 100644 --- a/scripts/map/roomInjectionProcessor/ChanceRoomInjectionProcessor.cs +++ b/scripts/map/roomInjectionProcessor/ChanceRoomInjectionProcessor.cs @@ -48,6 +48,8 @@ public class ChanceRoomInjectionProcessor : RoomInjectionProcessorTemplateThe 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. ///支持小数,范围为1-100。例如,如果设置为1.5,则表示1.5%的概率生成此房间。 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public float? Chance { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } } \ No newline at end of file diff --git a/scripts/mod/ModLoader.cs b/scripts/mod/ModLoader.cs index 8f65d16..eb7a1dc 100644 --- a/scripts/mod/ModLoader.cs +++ b/scripts/mod/ModLoader.cs @@ -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; diff --git a/scripts/mod/ModManifest.cs b/scripts/mod/ModManifest.cs index 2b26c2c..ae1ef3c 100644 --- a/scripts/mod/ModManifest.cs +++ b/scripts/mod/ModManifest.cs @@ -29,7 +29,9 @@ public class ModManifest ///Allow relative paths, such as:... / Points to the parent directory. ///允许使用相对路径,例如: ../指向上级目录。 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string[]? DllList { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Pck path list of mod @@ -39,7 +41,9 @@ public class ModManifest ///Allow relative paths, such as:... / Points to the parent directory. ///允许使用相对路径,例如: ../指向上级目录。 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string[]? PckList { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Creates module list information from a path diff --git a/scripts/openObserve/LogCollector.cs b/scripts/openObserve/LogCollector.cs index 13bf2e2..400a278 100644 --- a/scripts/openObserve/LogCollector.cs +++ b/scripts/openObserve/LogCollector.cs @@ -141,11 +141,15 @@ public class LogData /// message /// 消息 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public string? Message { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// level /// 错误等级 /// + // ReSharper disable UnusedAutoPropertyAccessor.Global public int Level { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global } \ No newline at end of file diff --git a/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs b/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs index 6aa41e7..c96167a 100644 --- a/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs +++ b/scripts/stateMachine/StateProcessor/PatrolStateProcessor.cs @@ -11,7 +11,7 @@ namespace ColdMint.scripts.stateMachine.StateProcessor; /// public class PatrolStateProcessor : StateProcessorTemplate { - public Vector2[]? Points { get; set; } + public Vector2[]? Points { get; init; } /// /// Whether to guard the origin @@ -21,7 +21,9 @@ public class PatrolStateProcessor : StateProcessorTemplate ///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. ///默认清空下,PatrolStateProcessor会将角色与地面接触的第一个位置当作原点。这个属性用来处理当角色被其他角色所吸引,(例如追击敌人)转换回巡逻模式,是否“守护”原点。如果设置为true,则角色会尝试返回原点,否则,将分配新的原点。 /// + // 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; } diff --git a/scripts/utils/NodeUtils.cs b/scripts/utils/NodeUtils.cs index c0514f8..039f265 100644 --- a/scripts/utils/NodeUtils.cs +++ b/scripts/utils/NodeUtils.cs @@ -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 /// 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 } } - /// - /// All child nodes are removed asynchronously - /// 异步删除所有子节点 - /// - /// - /// - public static async Task DeleteAllChildAsync(Node parent) - { - return await Task.Run(() => DeleteAllChild(parent)); - } - /// /// Gets the node closest to the origin /// 获取距离原点最近的节点 @@ -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;