2024-06-03 14:58:59 +00:00
|
|
|
|
using ColdMint.scripts.character;
|
2024-10-08 08:11:51 +00:00
|
|
|
|
using ColdMint.scripts.map.room;
|
2024-06-10 13:05:18 +00:00
|
|
|
|
using ColdMint.scripts.utils;
|
2024-06-03 14:58:59 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.map;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Ai character generation point</para>
|
|
|
|
|
/// <para>Ai角色生成点</para>
|
|
|
|
|
/// </summary>
|
2024-10-08 08:11:51 +00:00
|
|
|
|
public partial class AiCharacterSpawn : Marker2D, ISpawnMarker
|
2024-06-03 14:58:59 +00:00
|
|
|
|
{
|
|
|
|
|
private PackedScene? _packedScene;
|
2024-10-08 08:11:51 +00:00
|
|
|
|
[Export] private string? _resPath;
|
2024-06-03 14:58:59 +00:00
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
|
|
|
|
base._Ready();
|
2024-10-08 08:11:51 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(_resPath))
|
2024-06-03 14:58:59 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
_packedScene = GD.Load<PackedScene>(_resPath);
|
2024-06-03 14:58:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 08:11:51 +00:00
|
|
|
|
public Node2D? Spawn()
|
2024-06-03 14:58:59 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
if (GameSceneDepend.AiCharacterContainer == null || _packedScene == null)
|
2024-06-03 14:58:59 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
return null;
|
2024-06-03 14:58:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-24 14:19:12 +00:00
|
|
|
|
var aiCharacter = NodeUtils.InstantiatePackedScene<AiCharacter>(_packedScene);
|
2024-06-10 13:05:18 +00:00
|
|
|
|
if (aiCharacter == null)
|
2024-06-03 14:58:59 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
return null;
|
2024-06-03 14:58:59 +00:00
|
|
|
|
}
|
2024-06-24 14:19:12 +00:00
|
|
|
|
|
2024-09-01 15:24:35 +00:00
|
|
|
|
NodeUtils.CallDeferredAddChild(GameSceneDepend.AiCharacterContainer, aiCharacter);
|
2024-06-25 14:11:19 +00:00
|
|
|
|
aiCharacter.GlobalPosition = GlobalPosition;
|
2024-10-08 08:11:51 +00:00
|
|
|
|
return aiCharacter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanQueueFree()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
2024-06-03 14:58:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-08 08:11:51 +00:00
|
|
|
|
public void DoQueueFree()
|
2024-06-03 14:58:59 +00:00
|
|
|
|
{
|
2024-10-08 08:11:51 +00:00
|
|
|
|
QueueFree();
|
2024-06-03 14:58:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|