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 14:04:37 +00:00
|
|
|
|
[Export] private string[]? _itemIdList;
|
2024-06-22 15:29:24 +00:00
|
|
|
|
|
2024-10-08 14:04:37 +00:00
|
|
|
|
public Node2D? Spawn(int waveNumber)
|
2024-06-22 15:29:24 +00:00
|
|
|
|
{
|
2024-10-08 14:04:37 +00:00
|
|
|
|
if (_itemIdList == null)
|
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 14:04:37 +00:00
|
|
|
|
if (waveNumber < 0 || waveNumber >= _itemIdList.Length)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
var itemId = _itemIdList[waveNumber];
|
|
|
|
|
if (string.IsNullOrEmpty(itemId))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
var item = ItemTypeManager.CreateItem(itemId, this);
|
2024-10-11 09:59:47 +00:00
|
|
|
|
LogCat.LogWithFormat("generated_item_is_empty", LogCat.LogLabel.ItemSpawn, itemId, item == null);
|
2024-10-08 08:11:51 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 14:04:37 +00:00
|
|
|
|
public int GetMaxWaveNumber()
|
|
|
|
|
{
|
|
|
|
|
return _itemIdList?.Length ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 08:11:51 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|