コード例 #1
0
        internal unsafe void AddEntityCommand(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e)
        {
            int num1;

            if ((chain.m_PrevEntityCommand == null) || !(chain.m_PrevEntityCommand.Entity == e))
            {
                num1 = 0;
            }
            else
            {
                num1 = (int)(chain.m_PrevEntityCommand.BatchCount < 0x200);
            }
            if (num1 == 0)
            {
                EntityCommand *commandPtr2 = (EntityCommand *)ref this.Reserve(chain, jobIndex, sizeof(EntityCommand));
                commandPtr2->Header.CommandType = (int)op;
                commandPtr2->Header.TotalSize   = sizeof(EntityCommand);
                commandPtr2->Header.SortIndex   = chain.m_LastSortIndex;
                commandPtr2->Entity             = e;
                commandPtr2->BatchCount         = 1;
                chain.m_PrevEntityCommand       = commandPtr2;
            }
            else
            {
                int *numPtr1 = (int *)ref chain.m_PrevEntityCommand.BatchCount;
                numPtr1[0]++;
                EntityCommand *commandPtr = (EntityCommand *)ref this.Reserve(chain, jobIndex, sizeof(EntityCommand));
                commandPtr->Header.CommandType = (int)op;
                commandPtr->Header.TotalSize   = sizeof(EntityCommand);
                commandPtr->Header.SortIndex   = chain.m_LastSortIndex;
                commandPtr->Entity             = e;
                commandPtr->BatchCount         = 0;
            }
        }
コード例 #2
0
 public unsafe void TemporaryForceDisableBatching()
 {
     this.m_PrevCreateCommand = null;
     this.m_PrevEntityCommand = null;
 }
コード例 #3
0
        public static unsafe void Execute(byte[] memory, int commandLength, List <object> objects)
        {
            fixed(byte *memoryP = memory)
            {
                byte *commands = memoryP;

                while (commandLength > 0)
                {
                    int commandSize = 0;

                    switch (*(CommandType *)commands)
                    {
                    case CommandType.Entity:
                        commandSize = sizeof(EntityCommand);
                        break;

                    case CommandType.CreateEntity:
                        EntityCommand *command = (EntityCommand *)commands;
                        command->Entity = command->Entity.World.CreateEntity();
                        commandSize     = sizeof(EntityCommand);
                        break;

                    case CommandType.WorldSet:
                        WorldCommand *worldCommand = (WorldCommand *)commands;
                        commandSize  = sizeof(WorldCommand);
                        commandSize += ComponentCommands.GetCommand(worldCommand->ComponentIndex).Set(World.Worlds[worldCommand->WorldId], objects, commands + sizeof(WorldCommand));
                        break;

                    case CommandType.WorldRemove:
                        worldCommand = (WorldCommand *)commands;
                        ComponentCommands.GetCommand(worldCommand->ComponentIndex).Remove(World.Worlds[worldCommand->WorldId]);
                        commandSize = sizeof(WorldCommand);
                        break;

                    case CommandType.Enable:
                        ((Entity *)(memoryP + ((EntityOffsetCommand *)commands)->EntityOffset))->Enable();
                        commandSize = sizeof(EntityOffsetCommand);
                        break;

                    case CommandType.Disable:
                        ((Entity *)(memoryP + ((EntityOffsetCommand *)commands)->EntityOffset))->Disable();
                        commandSize = sizeof(EntityOffsetCommand);
                        break;

                    case CommandType.EnableT:
                        EntityOffsetComponentCommand *componentCommand = (EntityOffsetComponentCommand *)commands;
                        ComponentCommands.GetCommand(componentCommand->ComponentIndex).Enable(*(Entity *)(memoryP + componentCommand->EntityOffset));
                        commandSize = sizeof(EntityOffsetComponentCommand);
                        break;

                    case CommandType.DisableT:
                        componentCommand = (EntityOffsetComponentCommand *)commands;
                        ComponentCommands.GetCommand(componentCommand->ComponentIndex).Disable(*(Entity *)(memoryP + componentCommand->EntityOffset));
                        commandSize = sizeof(EntityOffsetComponentCommand);
                        break;

                    case CommandType.Set:
                        componentCommand = (EntityOffsetComponentCommand *)commands;
                        commandSize      = sizeof(EntityOffsetComponentCommand);
                        commandSize     += ComponentCommands.GetCommand(componentCommand->ComponentIndex).Set(*(Entity *)(memoryP + componentCommand->EntityOffset), objects, commands + sizeof(EntityOffsetComponentCommand));
                        break;

                    case CommandType.SetSameAs:
                        EntityReferenceOffsetComponentCommand *entityReferenceComponentCommand = (EntityReferenceOffsetComponentCommand *)commands;
                        ComponentCommands.GetCommand(entityReferenceComponentCommand->ComponentIndex).SetSameAs(
                            *(Entity *)(memoryP + entityReferenceComponentCommand->EntityOffset),
                            *(Entity *)(memoryP + entityReferenceComponentCommand->ReferenceOffset));
                        commandSize = sizeof(EntityReferenceOffsetComponentCommand);
                        break;

                    case CommandType.SetSameAsWorld:
                        componentCommand = (EntityOffsetComponentCommand *)commands;
                        ComponentCommands.GetCommand(componentCommand->ComponentIndex).SetSameAsWorld(*(Entity *)(memoryP + componentCommand->EntityOffset));
                        commandSize = sizeof(EntityOffsetComponentCommand);
                        break;

                    case CommandType.Remove:
                        componentCommand = (EntityOffsetComponentCommand *)commands;
                        ComponentCommands.GetCommand(componentCommand->ComponentIndex).Remove(*(Entity *)(memoryP + componentCommand->EntityOffset));
                        commandSize = sizeof(EntityOffsetComponentCommand);
                        break;

                    case CommandType.NotifyChanged:
                        componentCommand = (EntityOffsetComponentCommand *)commands;
                        ComponentCommands.GetCommand(componentCommand->ComponentIndex).NotifyChanged(*(Entity *)(memoryP + componentCommand->EntityOffset));
                        commandSize = sizeof(EntityOffsetComponentCommand);
                        break;

                    case CommandType.Clone:
                        CloneCommand *cloneCommand = (CloneCommand *)commands;
                        ((ComponentCloner)objects[cloneCommand->ClonerIndex]).Clone(*(Entity *)(memoryP + cloneCommand->SourceOffset), *(Entity *)(memoryP + cloneCommand->TargetOffset));
                        commandSize = sizeof(CloneCommand);
                        break;

                    case CommandType.Dispose:
                        ((Entity *)(memoryP + ((EntityOffsetCommand *)commands)->EntityOffset))->Dispose();
                        commandSize = sizeof(EntityOffsetCommand);
                        break;
                    }

                    commands      += commandSize;
                    commandLength -= commandSize;
                }
            }
        }