Example #1
0
    public void ExecuteSystem(int entityId, ECSDefine.SystemType systemType, BaseSystem.SystemExpandData expandData)
    {
        BaseEntity entity = ECSUnit.GetEntity(entityId);

        if (entity == null)
        {
            Debug.LogError($"[ECSModule] ExecuteSystem Fail. Entity Is nil. entityId:{entityId}");
            return;
        }

        int        systemId = systemIdDistributionChunk.Pop();
        BaseSystem system   = CreateImmediatelyExecuteSystem(systemType, systemId);

        if (system == null)
        {
            return;
        }

        do
        {
            if (system.GetSystemFunctionType() != ECSDefine.SystemFunctionType.Logic)
            {
                Debug.LogError($"[ECSModule] ExecuteSystem Fail. Only Can ImmediatelyExecute Logic Type. entityId:{entityId} systemType:{Enum.GetName(typeof(ECSDefine.SystemType), systemType)}");
                break;
            }

            system.SetGlobalUnionId(GlobalUnionId);
            system.Execute(entityId, expandData);
        }while (false);

        DeleteImmediatelyExecuteSystem(system);//执行完毕回收
    }