/// <summary> /// Decodes a command. /// </summary> public static LogicCommand DecodeCommand(ByteStream stream) { LogicCommand command = LogicCommandManager.CreateCommand(stream.ReadInt()); if (command == null) { Debugger.Error("LogicCommandManager::decodeCommand() - command is null"); } else { command.Decode(stream); } return(command); }
/// <summary> /// Decodes this instance. /// </summary> public void Decode(ByteStream stream) { if (this._commandList.Count != 0) { do { this._commandList[0].Destruct(); this._commandList.Remove(0); } while (this._commandList.Count != 0); } stream.EnableCheckSum(false); for (int i = 0, commandCount = stream.ReadInt(); i < commandCount; i++) { this._commandList.Add(LogicCommandManager.DecodeCommand(stream)); } stream.EnableCheckSum(true); }
/// <summary> /// Loads command from json. /// </summary> 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(jsonNumber.GetJSONNodeType()); if (command != null) { command.LoadFromJSON(jsonObject.GetJSONObject("c")); } return(command); } return(null); }