public void Clone(ScriptCommand cmd) { id = cmd.id; values = new Object[cmd.values.Length]; for (int i = 0; i < cmd.values.Length; i++) { values[i] = cmd.values[i]; } }
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); }
public void computeExValue(EexBinaryWriter writer) { int writerIndex = writer.getIndex(); for (int i = 0; i < commandList.Count; i++) { if (!commandList[i].isExtValueAvailable()) { continue; } int level = 1; writer.setIndex(writerIndex); for (int j = i + 1; j < commandList.Count; j++) { ScriptCommand cmd = commandList[j]; if (cmd.isExtValueAvailable()) { level++; } writer.writeUShort((ushort)cmd.Id); cmd.saveWriter(writer); if (cmd.isExtValueAvailable()) { writer.writeUShort((ushort)cmd.getExtValue()); } if (cmd.Id == (int)CommandId.CMD_ACTION_END) { level--; if (level == 0) { break; } } } commandList[i].setExtValue(writer.getIndex() - writerIndex); } writer.setIndex(writerIndex); }
public void saveNewWriter(EexBinaryWriter writer) { int sectionStart = writer.getIndex(); writer.writeUShort(0); for (int i = 0; i < commandList.Count; i++) { ScriptCommand cmd = commandList[i]; writer.writeUShort((ushort)cmd.Id); cmd.saveWriter(writer); if (cmd.isExtValueAvailable()) { writer.writeUShort((ushort)cmd.getExtValue()); } } int sectionEnd = writer.getIndex(); writer.setIndex(sectionStart).writeUShort((ushort)commandList.Count); writer.setIndex(sectionEnd); }
public void removeCode(ScriptCommand cmd) { removeCode(commandList.IndexOf(cmd)); }
public void CobyCode(int id, ScriptCommand cmd) { commandList.Insert(commandList.IndexOf(cmd) + 1, cmd); }
public int FindCommand(ScriptCommand cmd) { return(commandList.IndexOf(cmd)); }
public int addCode(int id, ScriptCommand cmd, bool ext = false) { return(addCode(id, FindCommand(cmd) + 1, ext)); }
public void addCmd(int index, ScriptCommand cmd) { commandList.Insert(index, cmd); }
public static String getNodeText(ScriptCommand cmd) { CommandConfig cfg = ScriptConfig.Instance.getCommandConfig(cmd.id); String ret = String.Format("{0:x}:{1}", cmd.id, cfg.Name); switch (cmd.id) { case 0x5: { ushort[] true_list = (ushort[])cmd.values[0]; ushort[] false_list = (ushort[])cmd.values[1]; int n = true_list.Length; ret += " "; for (int i = 0; i < n; i++) { ret += "Var" + true_list[i]; ret += " "; } ret += "; "; n = false_list.Length; for (int i = 0; i < n; i++) { ret += "Var" + false_list[i]; ret += " "; } } break; case 0x46: case 0x47: break; default: { for (int i = 0; i < cmd.keys.Length; i++) { int key = cmd.keys[i]; ret += (" "); //EexType etype = ScriptConfig.Instance.getEexType(key); switch (key) { case 4: //TempStr += ReadLong_Str(); ret += cmd.values[i].ToString(); break; case 0x102: ret += "Var" + cmd.values[i].ToString(); //tt.Format(("Var{0}"), ReadLong()); //TempStr += tt; break; case 5: ret += cmd.values[i].ToString(); //tt = ReadStr(true); //tt.Replace(("\r\n"), ("\\n")); //TempStr += tt; break; case 0x100: ret += cmd.values[i].ToString(); //TempStr += ReadPos(true); break; case 0x101: ret += cmd.values[i].ToString(); //TempStr += ReadArea(true); break; case 0x103: ret += cmd.values[i].ToString(); //TempStr += GetParameterName_Int(ParameterInfo[i], ReadInt(3), Code, i - CodeInfo[Code].ParameterIndex); break; default: string aaa = cmd.values[i].ToString(); ret += GetParameterName_Int(key, Convert.ToInt32(cmd.values[i]), cmd.id, 0 /*i - CodeInfo[Code].ParameterIndex*/); break; } } } break; } return(ret); }