コード例 #1
0
    public BaseComponent CopyComponent(BaseComponent resComponent)
    {
        if (resComponent == null)
        {
            return(null);
        }

        int entityId    = resComponent.GetEntityId();
        int componentId = resComponent.GetComponentId();

        ECSDefine.ComponentType           componentType       = resComponent.GetComponentType();
        BaseComponent.ComponentExpandData componentExpandData = resComponent.GetComponentExpandData();

        int newComponentId = copyComponentIdDistributionChunk.Pop();

        OperationObject operationObject = componentOperation.CreateOperationObject((int)componentType, newComponentId);

        if (operationObject == null)
        {
            Debug.LogError($"[ECSModule] CopyComponent Fail. componentType:{Enum.GetName(typeof(ECSDefine.ComponentType), componentType)}");
            return(null);
        }

        BaseComponent newComponent = operationObject as BaseComponent;

        newComponent.SetGlobalUnionId(GlobalUnionId);

        newComponent.SetEntityId(entityId);
        newComponent.SetComponentId(componentId);
        newComponent.SetComponentType(componentType);
        newComponent.SetComponentExpandData(componentExpandData.Copy());

        return(newComponent);
    }
コード例 #2
0
    public void AddUnit <T>(int unitTypeId) where T : BaseUnit
    {
        Type unitType = typeof(T);

        if (unitDict.ContainsKey(unitType))
        {
            Debug.LogError($"[GlobalUnion] AddUnit [{unitType.Name}] Fail. Has Record");
            return;
        }

        int             unitId          = idDistributionChunk.Pop();
        OperationObject operationObject = globalUnionPollingOperation.AddOperationObject(unitId, unitTypeId);

        if (operationObject != null)
        {
            BaseUnit unit = operationObject as BaseUnit;
            unitDict.Add(unitType, unit);

            InitUnit(unit);
        }
        if (!unitTypeDict.ContainsKey(unitType))
        {
            unitTypeDict.Add(unitType, unitTypeId);
        }
    }
コード例 #3
0
    public void RegSystem(int entityId, ECSDefine.SystemType systemType)
    {
        BaseEntity entity = ECSUnit.GetEntity(entityId);

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

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

        if (system == null)
        {
            return;
        }

        system.FillInExecute(entityId);
    }
コード例 #4
0
    public BaseSystem.ComponentInfo PopSystemComponentInfo()
    {
        int             systemComponentInfoId = systemComponentInfoIdDistributionChunk.Pop();
        OperationObject operationObject       = systemComponentInfoOperation.CreateOperationObject((int)ECSDefine.SystemType.ComponentInfo, systemComponentInfoId);

        if (operationObject != null)
        {
            BaseSystem.ComponentInfo componentInfo = (BaseSystem.ComponentInfo)operationObject;
            return(componentInfo);
        }
        return(null);
    }
コード例 #5
0
    public GlobalUnion CreateGlobalUnion()
    {
        int             globalId        = idDistributionChunk.Pop();
        OperationObject operationObject = globalUnionPollingOperation.AddOperationObject(globalId, (int)GlobalDefine.GlobalUnionType.Global);

        if (operationObject != null)
        {
            GlobalUnion globalUnion = operationObject as GlobalUnion;
            InitGlobalUnion(globalUnion, globalId);

            globalUnionDict.Add(globalId, globalUnion);
            return(globalUnion);
        }
        return(null);
    }
コード例 #6
0
    private BaseCommand PopCommand(ECSDefine.SystemType systemType)
    {
        int             commandId       = idDistributionChunk.Pop();
        OperationObject operationObject = commandOperation.CreateOperationObject((int)systemType, commandId);

        if (operationObject != null)
        {
            BaseCommand command = operationObject as BaseCommand;

            command.SetGlobalUnionId(GlobalUnionId);

            return(command);
        }

        return(null);
    }
コード例 #7
0
    public void ExecuteSynchroValueRspSystem(ECSDefine.SynchroValueRspSystemType systemType, SynchroValueRsp.SynchroValueRspStructure synchroValueRspStructure)
    {
        int             synchroValueRspSystemId = synchroValueRspSystemIdDistributionChunk.Pop();
        OperationObject operationObject         = synchroValueRspSystemOperation.CreateOperationObject((int)systemType, synchroValueRspSystemId);

        if (operationObject == null)
        {
            Debug.LogError($"[ECSModule] ExecuteSynchroValueRspSystem Fail. systemType:{Enum.GetName(typeof(ECSDefine.SynchroValueRspSystemType), systemType)}");
            return;
        }

        BaseSynchroValueRspSystem synchroValueRspSystem = operationObject as BaseSynchroValueRspSystem;

        synchroValueRspSystem.SetGlobalUnionId(GlobalUnionId);
        synchroValueRspSystem.Execute(synchroValueRspStructure);

        synchroValueRspSystemOperation.DeleteOperationObject((int)systemType, operationObject);//执行完毕回收
    }
コード例 #8
0
    public void RequireSynchroValueRep(int entityId, int componentId, ECSDefine.ComponentType componentType)
    {
        int reqId = synchroValueIdDistributionChunk.Pop();

        ECSDefine.SynchronizationValueType synchronizationValueType = ECSDefine.SynchronizationValueType.Require;
        OperationObject operationObject = SynchroValueRepOperation.CreateOperationObject((int)synchronizationValueType, reqId);

        if (operationObject == null)
        {
            Debug.LogError($"[SynchronizationUnit] RequireComponent Fail. SynchroValueRep is nil. synchronizationValueType:{Enum.GetName(typeof(ECSDefine.SynchronizationValueType), synchronizationValueType)}");
            return;
        }

        SynchroValueRep synchroValueRep = operationObject as SynchroValueRep;

        synchroValueRep.SetSynchroValueRepId(reqId);
        synchroValueRep.SetEntityId(entityId);
        synchroValueRep.SetComponentId(componentId);
        synchroValueRep.SetComponentType(componentType);

        synchroValueRepList.Add(synchroValueRep);
    }