2024-10-04 12:53:34 +00:00
|
|
|
|
using ColdMint.scripts.debug;
|
|
|
|
|
using ColdMint.scripts.inventory;
|
2024-10-08 08:11:51 +00:00
|
|
|
|
using ColdMint.scripts.map.room;
|
2024-06-22 15:29:24 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.map;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>ItemSpawn</para>
|
|
|
|
|
/// <para>物品出生点</para>
|
|
|
|
|
/// </summary>
|
2024-10-08 08:11:51 +00:00
|
|
|
|
public partial class ItemSpawn : Marker2D, ISpawnMarker
|
2024-06-22 15:29:24 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
[Export] private string? ItemId { get; set; }
|
2024-06-22 15:29:24 +00:00
|
|
|
|
|
2024-10-08 08:11:51 +00:00
|
|
|
|
public Node2D? Spawn()
|
2024-06-22 15:29:24 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
if (string.IsNullOrEmpty(ItemId))
|
2024-06-22 15:29:24 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
return null;
|
2024-06-22 15:29:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-24 14:19:12 +00:00
|
|
|
|
var item = ItemTypeManager.CreateItem(ItemId, this);
|
2024-10-08 08:11:51 +00:00
|
|
|
|
LogCat.LogWithFormat("generated_item_is_empty", LogCat.LogLabel.ItemSpawn, true, ItemId, item == null);
|
|
|
|
|
if (item is not Node2D node2D)
|
2024-06-22 15:29:24 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
return null;
|
2024-06-22 15:29:24 +00:00
|
|
|
|
}
|
2024-10-08 08:11:51 +00:00
|
|
|
|
node2D.GlobalPosition = GlobalPosition;
|
|
|
|
|
return node2D;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanQueueFree()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
2024-06-22 15:29:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 08:11:51 +00:00
|
|
|
|
public void DoQueueFree()
|
2024-06-22 15:29:24 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
QueueFree();
|
2024-06-22 15:29:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|