2024-05-30 14:49:54 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using ColdMint.scripts.map.interfaces;
|
|
|
|
|
using ColdMint.scripts.serialization;
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.map.roomInjectionProcessor;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Room injection processor template</para>
|
|
|
|
|
/// <para>房间注入处理器模板</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="TConfig"></typeparam>
|
|
|
|
|
public abstract class RoomInjectionProcessorTemplate<TConfig> : IRoomInjectionProcessor
|
|
|
|
|
{
|
|
|
|
|
public abstract string GetId();
|
|
|
|
|
|
2024-06-16 14:44:50 +00:00
|
|
|
|
public Task<bool> CanBePlaced(RandomNumberGenerator randomNumberGenerator, string? yamlConfigData)
|
2024-05-30 14:49:54 +00:00
|
|
|
|
{
|
2024-06-16 14:44:50 +00:00
|
|
|
|
if (yamlConfigData == null)
|
2024-05-30 14:49:54 +00:00
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(false);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-16 14:44:50 +00:00
|
|
|
|
var configData = YamlSerialization.Deserialize<TConfig>(yamlConfigData);
|
|
|
|
|
return configData == null ? Task.FromResult(false) : OnCreateConfigData(randomNumberGenerator, configData);
|
2024-05-30 14:49:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>When creating a configuration class</para>
|
|
|
|
|
/// <para>当创建配置类时</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="randomNumberGenerator"></param>
|
|
|
|
|
/// <param name="configData"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected abstract Task<bool> OnCreateConfigData(RandomNumberGenerator randomNumberGenerator, TConfig configData);
|
|
|
|
|
}
|