Replaced all hardcoded stringName call.

移除了所有硬编码的StringName调用。
This commit is contained in:
霧雨烨 2024-06-16 17:09:40 +08:00
parent 40b52abb48
commit 2d3fa08d0d
4 changed files with 11 additions and 5 deletions

View File

@ -454,8 +454,6 @@ public partial class CharacterTemplate : CharacterBody2D
{
var lootData = LootListManager.GenerateLootData(LootListId);
var finalGlobalPosition = GlobalPosition;
//Todo : change name str to nameof(), like this
// CallDeferred(nameof(GenerateLootObjects), this, lootData, finalGlobalPosition);
GenerateLootObjects(GetParent(), lootData, finalGlobalPosition);
}
@ -651,7 +649,7 @@ public partial class CharacterTemplate : CharacterBody2D
return;
}
CallDeferred("NodeReparent", node2D);
CallDeferred(nameof(NodeReparent), node2D);
switch (item)
{
case WeaponTemplate weaponTemplate:

View File

@ -106,7 +106,7 @@ public partial class DamageNumberNodeSpawn : Marker2D
return;
}
CallDeferred("AddDamageNumberNode", damageNumber);
CallDeferred(nameof(AddDamageNumberNode), damageNumber);
damageNumber.Position = GlobalPosition;
if (damageTemplate.MoveLeft)
{

View File

@ -70,7 +70,7 @@ public static class ItemTypeManager
public static IItem? CreateItem(string id, Node? parent = null, Vector2? position = null)
{
var item = NewItem(id);
parent?.CallDeferred("add_child", (item as Node)!);
parent?.CallDeferred(GodotStringNameUtils.AddChild, (item as Node)!);
if (item is not Node2D node) return item;
if (position is { } pos) node.GlobalPosition = pos;
return item;

View File

@ -0,0 +1,8 @@
using Godot;
namespace ColdMint.scripts.utils;
public static class GodotStringNameUtils
{
public static StringName AddChild { get; } = new("add_chile");
}