59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using Models;
|
|
|
|
namespace Core;
|
|
|
|
/// <summary>
|
|
/// 游戏会话(运行时入口)
|
|
/// 设计说明:
|
|
/// 1) 将 State + Content + Systems + Services 组织为一个整体。
|
|
/// 2) 便于在 Godot Node 中持有,避免散落的静态单例。
|
|
/// 注意事项:
|
|
/// - 真实项目中应通过工厂或依赖注入创建。
|
|
/// 未来扩展:
|
|
/// - 可加入“加载存档/保存存档/重置”接口。
|
|
/// </summary>
|
|
public sealed class GameSession
|
|
{
|
|
public GameState State { get; }
|
|
public GameContentDatabase Content { get; }
|
|
public DomainEventBus Events { get; }
|
|
public ILocalizationService Localization { get; }
|
|
public GameSystems Systems { get; }
|
|
|
|
public GameSession(GameState state, GameContentDatabase content, ILocalizationService localization, DomainEventBus events)
|
|
{
|
|
State = state;
|
|
Content = content;
|
|
Localization = localization;
|
|
Events = events;
|
|
Systems = new GameSystems();
|
|
Systems.Initialize(this);
|
|
}
|
|
|
|
public static GameSession CreateDefault()
|
|
{
|
|
var registry = new ContentRegistry();
|
|
var resourceSource = new ResourceContentSource(0);
|
|
resourceSource.ResourcePaths.Add("res://resources/definitions/discipline_biology.tres");
|
|
registry.RegisterSource(resourceSource);
|
|
|
|
var jsonSource = new JsonContentSource(10);
|
|
jsonSource.DataPaths.Add("res://resources/definitions/disciplines.json");
|
|
jsonSource.DataPaths.Add("res://resources/definitions/archetypes.json");
|
|
jsonSource.DataPaths.Add("res://resources/definitions/roles.json");
|
|
jsonSource.DataPaths.Add("res://resources/definitions/traits.json");
|
|
registry.RegisterSource(jsonSource);
|
|
|
|
var content = registry.BuildDatabase();
|
|
var localization = new GodotLocalizationService();
|
|
var events = new DomainEventBus();
|
|
return new GameSession(new GameState(), content, localization, events);
|
|
}
|
|
|
|
public void Tick(float delta)
|
|
{
|
|
Systems.Tick(delta);
|
|
}
|
|
}
|
|
|