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 lootData = LootListManager.GenerateLootData(LootListId);
|
||||||
var finalGlobalPosition = GlobalPosition;
|
var finalGlobalPosition = GlobalPosition;
|
||||||
//Todo : change name str to nameof(), like this
|
|
||||||
// CallDeferred(nameof(GenerateLootObjects), this, lootData, finalGlobalPosition);
|
|
||||||
GenerateLootObjects(GetParent(), lootData, finalGlobalPosition);
|
GenerateLootObjects(GetParent(), lootData, finalGlobalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +649,7 @@ public partial class CharacterTemplate : CharacterBody2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallDeferred("NodeReparent", node2D);
|
CallDeferred(nameof(NodeReparent), node2D);
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case WeaponTemplate weaponTemplate:
|
case WeaponTemplate weaponTemplate:
|
||||||
|
|
|
@ -106,7 +106,7 @@ public partial class DamageNumberNodeSpawn : Marker2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallDeferred("AddDamageNumberNode", damageNumber);
|
CallDeferred(nameof(AddDamageNumberNode), damageNumber);
|
||||||
damageNumber.Position = GlobalPosition;
|
damageNumber.Position = GlobalPosition;
|
||||||
if (damageTemplate.MoveLeft)
|
if (damageTemplate.MoveLeft)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ public static class ItemTypeManager
|
||||||
public static IItem? CreateItem(string id, Node? parent = null, Vector2? position = null)
|
public static IItem? CreateItem(string id, Node? parent = null, Vector2? position = null)
|
||||||
{
|
{
|
||||||
var item = NewItem(id);
|
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 (item is not Node2D node) return item;
|
||||||
if (position is { } pos) node.GlobalPosition = pos;
|
if (position is { } pos) node.GlobalPosition = pos;
|
||||||
return item;
|
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