public int addCode(int id, int index, bool ext = false) { ScriptCommand cmd = ScriptCommand.createCommand(id); if (ext) { cmd.setExtValue(2); } commandList.Insert(index, cmd); return(index); }
public bool loadReader(EexBinaryReader reader) { commandList.Clear(); int sectionLen = reader.readUShort(); int endIndex = reader.getIndex() + sectionLen; int buildTreeCmd = -1; while (reader.getIndex() < endIndex) { int cmdId = reader.readUShort(); ScriptCommand cmd = ScriptCommand.createCommand(cmdId); try { cmd.loadReader(reader); } catch (EexReaderException exception) { exception.CommandId = cmdId; throw; } commandList.Add(cmd); if (buildTreeCmd != -1) { if ((buildTreeCmd == (int)CommandId.CMD_CHILD_INFO_ACTION && cmdId == (int)CommandId.CMD_ACTION_END) || (buildTreeCmd == (int)CommandId.CMD_CHILD_ACTION)) { buildTreeCmd = -1; cmd.setExtValue(reader.readUShort()); continue; } } switch ((CommandId)cmdId) { case CommandId.CMD_CHILD_ACTION: // = 0x1;//子事件设定 case CommandId.CMD_CHILD_INFO_ACTION: // = 0x2;//子事件设定带信息 buildTreeCmd = cmdId; break; } } return(true); }
public bool loadJson(JObject jobj) { commandList.Clear(); JArray jar = (JArray)jobj["commands"]; int buildTreeCmd = -1; foreach (JObject item in jar) { int cmdId = ScriptCommand.parseCommandId(item); ScriptCommand cmd = ScriptCommand.createCommand(cmdId); try { cmd.loadJson(item); } catch (EexReaderException exception) { exception.CommandId = cmdId; throw; } commandList.Add(cmd); if (buildTreeCmd != -1) { if ((buildTreeCmd == (int)CommandId.CMD_CHILD_INFO_ACTION && cmdId == (int)CommandId.CMD_ACTION_END) || (buildTreeCmd == (int)CommandId.CMD_CHILD_ACTION)) { buildTreeCmd = -1; cmd.setExtValue(ScriptCommand.parseExtValue(item)); continue; } } switch ((CommandId)cmdId) { case CommandId.CMD_CHILD_ACTION: // = 0x1;//子事件设定 case CommandId.CMD_CHILD_INFO_ACTION: // = 0x2;//子事件设定带信息 buildTreeCmd = cmdId; break; } } return(true); }