refactor(ecs): 将EcsSystemBase中的EcsWorld类型改为接口

- 将EcsWorld属性的类型从具体类EcsWorld改为接口IEcsWorld
- 修改OnInit方法中的服务获取逻辑以使用接口类型
- 提高代码的抽象性和可扩展性
This commit is contained in:
GeWuYou 2026-02-23 11:40:43 +08:00 committed by gewuyou
parent 808d3beecf
commit 07e2a80de5

View File

@ -13,7 +13,7 @@ public abstract class EcsSystemBase : AbstractSystem, IEcsSystem
/// <summary> /// <summary>
/// ECS世界实例 /// ECS世界实例
/// </summary> /// </summary>
protected EcsWorld EcsWorld { get; private set; } = null!; protected IEcsWorld EcsWorld { get; private set; } = null!;
/// <summary> /// <summary>
/// 快捷访问内部World /// 快捷访问内部World
@ -35,7 +35,7 @@ public abstract class EcsSystemBase : AbstractSystem, IEcsSystem
/// </summary> /// </summary>
protected override void OnInit() protected override void OnInit()
{ {
EcsWorld = this.GetService<EcsWorld>() ?? throw new InvalidOperationException( EcsWorld = this.GetService<IEcsWorld>() ?? throw new InvalidOperationException(
"EcsWorld not found in context. Make sure ECS is properly initialized."); "EcsWorld not found in context. Make sure ECS is properly initialized.");
OnEcsInit(); OnEcsInit();