示例#1
0
        public object Decode(ProtocolBuffer protocolBuffer)
        {
            Type        type;
            CommandCode key = (CommandCode)this.commandCodeCodec.Decode(protocolBuffer);

            if (!this.typeByCode.TryGetValue(key, out type))
            {
                throw new UnknownCommandException(key);
            }
            object instance = ProtocolFlowInstances.GetInstance(type);

            this.protocol.GetCodec(type).DecodeToInstance(protocolBuffer, instance);
            return(instance);
        }
        private bool TrySplitCommands(Command command, List <Command> commands)
        {
            if (!this.SplitShareCommand)
            {
                return(false);
            }
            EntityShareCommand item = command as EntityShareCommand;

            if (item == null)
            {
                return(false);
            }
            Component[] components = item.Components;
            item.Components = EmptyComponents;
            commands.Add(item);
            foreach (Component component in components)
            {
                ComponentAddCommand instance = ProtocolFlowInstances.GetInstance <ComponentAddCommand>();
                instance.Entity    = item.GetOrCreateEntity();
                instance.Component = component;
                commands.Add(instance);
            }
            return(true);
        }