Example #1
0
        public static LogicCommand DecodeCommand(ByteStream stream)
        {
            LogicCommand command = LogicCommandManager.CreateCommand((LogicCommandType)stream.ReadInt());

            if (command == null)
            {
                Debugger.Warning("LogicCommandManager::decodeCommand() - command is null");
            }
            else
            {
                command.Decode(stream);
            }

            return(command);
        }
Example #2
0
        public void Decode(ByteStream stream)
        {
            for (int i = this.m_commandList.Size() - 1; i >= 0; i--)
            {
                this.m_commandList[i].Destruct();
                this.m_commandList.Remove(i);
            }

            stream.EnableCheckSum(false);

            for (int i = 0, commandCount = stream.ReadInt(); i < commandCount; i++)
            {
                this.m_commandList.Add(LogicCommandManager.DecodeCommand(stream));
            }

            stream.EnableCheckSum(true);
        }
Example #3
0
        public static LogicCommand LoadCommandFromJSON(LogicJSONObject jsonObject)
        {
            LogicJSONNumber jsonNumber = jsonObject.GetJSONNumber("ct");

            if (jsonNumber == null)
            {
                Debugger.Error("loadCommandFromJSON - Unknown command type");
            }
            else
            {
                LogicCommand command = LogicCommandManager.CreateCommand((LogicCommandType)jsonNumber.GetIntValue());

                if (command != null)
                {
                    command.LoadFromJSON(jsonObject.GetJSONObject("c"));
                }

                return(command);
            }

            return(null);
        }