Пример #1
0
            public unsafe void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                var entities     = chunk.GetNativeArray(entityType);
                var bufferAccess = chunk.GetBufferAccessor(bufferType);

                for (int i = 0; i < bufferAccess.Length; ++i)
                {
                    var dynArray            = bufferAccess[i];
                    DataStreamReader reader = DataStreamUnsafeUtility.CreateReaderFromExistingData((byte *)dynArray.GetUnsafePtr(), dynArray.Length);
                    var ctx = default(DataStreamReader.Context);
                    while (reader.GetBytesRead(ref ctx) < reader.Length)
                    {
                        int type = reader.ReadInt(ref ctx);
                        if (type < internalRpcCollectionLength)
                        {
                            internalRpcCollection.ExecuteRpc(type, reader, ref ctx, entities[i], commandBuffer, chunkIndex);
                        }
                        else
                        {
                            rpcCollection.ExecuteRpc(type - internalRpcCollectionLength, reader, ref ctx, entities[i], commandBuffer, chunkIndex);
                        }
                    }

                    dynArray.Clear();
                }
            }
Пример #2
0
        protected unsafe override void OnUpdate()
        {
            // TODO: LZ:
            //      not use Allocator.Persistent
            var ents = m_RpcBufferQuery.ToEntityArray(Allocator.TempJob);

            for (var i = 0; i < ents.Length; ++i)
            {
                var ent    = ents[i];
                var rpcBuf = EntityManager.GetBuffer <IncomingRpcDataStreamBufferComponent>(ent);

                DataStreamReader reader = DataStreamUnsafeUtility.CreateReaderFromExistingData((byte *)rpcBuf.GetUnsafePtr(), rpcBuf.Length);

                var ctx = default(DataStreamReader.Context);
                while (reader.GetBytesRead(ref ctx) < reader.Length)
                {
                    int type = reader.ReadInt(ref ctx);
                    if (type < m_InternalRpcCollectionLength)
                    {
                        m_InternalRpcCollection.ExecuteRpc(type, reader, ref ctx, ent, PostUpdateCommands);
                    }
                    else
                    {
                        m_RpcCollection.ExecuteRpc(type - m_InternalRpcCollectionLength, reader, ref ctx, ent, PostUpdateCommands);
                    }
                }

                rpcBuf.Clear();
            }
            ents.Dispose();
        }