Replaced all hardcoded stringName call.
移除了所有硬编码的StringName调用。
This commit is contained in:
parent
40b52abb48
commit
2d3fa08d0d
|
@ -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:
|
||||
|
|
|
@ -106,7 +106,7 @@ public partial class DamageNumberNodeSpawn : Marker2D
|
|||
return;
|
||||
}
|
||||
|
||||
CallDeferred("AddDamageNumberNode", damageNumber);
|
||||
CallDeferred(nameof(AddDamageNumberNode), damageNumber);
|
||||
damageNumber.Position = GlobalPosition;
|
||||
if (damageTemplate.MoveLeft)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
8
scripts/utils/GodotStringNameUtils.cs
Normal file
8
scripts/utils/GodotStringNameUtils.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.utils;
|
||||
|
||||
public static class GodotStringNameUtils
|
||||
{
|
||||
public static StringName AddChild { get; } = new("add_chile");
|
||||
}
|
Loading…
Reference in New Issue
Block a user