TH1/Unity/Assets/Scripts/Core/Entity/IGetComponentSysSystem.cs
2025-07-17 18:26:28 +08:00

44 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
namespace ET
{
// GetComponentSystem有巨大作用比如每次保存Unit的数据不需要所有组件都保存只需要保存Unit变化过的组件
// 是否变化可以通过判断该组件是否GetComponentGet了就记录该组件
// 这样可以只保存Unit变化过的组件
// 再比如传送也可以做此类优化
public interface IGetComponentSys
{
}
public interface IGetComponentSysSystem: ISystemType
{
void Run(Entity o, Type type);
}
[EntitySystem]
public abstract class GetComponentSysSystem<T> : SystemObject, IGetComponentSysSystem where T: Entity, IGetComponentSys
{
void IGetComponentSysSystem.Run(Entity o, Type type)
{
this.GetComponentSys((T)o, type);
}
Type ISystemType.SystemType()
{
return typeof(IGetComponentSysSystem);
}
int ISystemType.GetInstanceQueueIndex()
{
return InstanceQueueIndex.None;
}
Type ISystemType.Type()
{
return typeof(T);
}
protected abstract void GetComponentSys(T self, Type type);
}
}