예제 #1
0
 public void ExecuteCacheSynchroValueRep()
 {
     for (int index = 0; index < synchroValueRepList.Count; index++)
     {
         SynchroValueRep synchroValueRep = synchroValueRepList[index];
         SynchroValueRsp synchroValueRsp = SynchroValueRepToSynchroValueRsp(synchroValueRep);
         if (synchroValueRsp == null)
         {
             continue;
         }
         sendSynchroValueRspList.Add(synchroValueRsp);
     }
     synchroValueRepList.Clear();
 }
예제 #2
0
    private SynchroValueRsp SynchroValueRepToSynchroValueRsp(SynchroValueRep synchroValueRep)
    {
        int             synchroValueRepId = synchroValueRep.GetSynchroValueRepId();
        int             synchroValueRspId = synchroValueRepId + 1;
        OperationObject operationObject   = SynchroValueRspOperation.CreateOperationObject((int)ECSDefine.SynchronizationValueType.Response, synchroValueRspId);

        if (operationObject == null)
        {
            Debug.LogError("[SynchronizationUnit] SynchroValueRepToSynchroValueRsp Fail. Create SynchroValueRsp Fail");
            return(null);
        }

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

        ECSDefine.ComponentType componentType = synchroValueRep.GetComponentType();

        SynchroValueRsp synchroValueRsp = operationObject as SynchroValueRsp;

        synchroValueRsp.SetSynchroValueRspId(synchroValueRspId);
        synchroValueRsp.SetComponentId(componentId);
        synchroValueRsp.SetComponentType(componentType);
        synchroValueRep.SetEntityId(entityId);

        BaseEntity entity = ecsUnit.GetEntity(entityId);

        if (entity == null)
        {
            synchroValueRsp.SetIsEntityAlive(true);
            BaseComponent component = entity.GetComponentByComponentId(componentId);
            synchroValueRsp.SetIsComponentAlive(component != null);
        }
        else
        {
            synchroValueRsp.SetIsEntityAlive(false);
            synchroValueRsp.SetIsComponentAlive(false);
        }

        return(synchroValueRsp);
    }
예제 #3
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);
    }
예제 #4
0
 public void ReceiveSynchroValueRep(SynchroValueRep synchroValueRep)
 {
     synchroValueRepList.Add(synchroValueRep);
 }