Exemple #1
0
    public void ExecuteRpc(int type, DataStreamReader reader, ref DataStreamReader.Context ctx, Entity connection, EntityCommandBuffer.Concurrent commandBuffer, int jobIndex)
    {
        switch (type)
        {
        case 0:
        {
            var tmp = new RpcLoadLevel();
            tmp.Deserialize(reader, ref ctx);
            tmp.Execute(connection, commandBuffer, jobIndex);
            break;
        }

        case 1:
        {
            var tmp = new RpcLevelLoaded();
            tmp.Deserialize(reader, ref ctx);
            tmp.Execute(connection, commandBuffer, jobIndex);
            break;
        }

        case 2:
        {
            var tmp = new RpcSpawn();
            tmp.Deserialize(reader, ref ctx);
            tmp.Execute(connection, commandBuffer, jobIndex);
            break;
        }
        }
    }
        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);
                    switch (type)
                    {
                    case 0:
                    {
                        var tmp = new RpcSetNetworkId();
                        tmp.Deserialize(reader, ref ctx);
                        tmp.Execute(entities[i], commandBuffer, chunkIndex);
                        break;
                    }

                    case 1:
                    {
                        var tmp = new RpcLoadLevel();
                        tmp.Deserialize(reader, ref ctx);
                        tmp.Execute(entities[i], commandBuffer, chunkIndex);
                        break;
                    }

                    case 2:
                    {
                        var tmp = new RpcLevelLoaded();
                        tmp.Deserialize(reader, ref ctx);
                        tmp.Execute(entities[i], commandBuffer, chunkIndex);
                        break;
                    }

                    case 3:
                    {
                        var tmp = new RpcSpawn();
                        tmp.Deserialize(reader, ref ctx);
                        tmp.Execute(entities[i], commandBuffer, chunkIndex);
                        break;
                    }
                    }
                }

                dynArray.Clear();
            }
        }