Created
September 1, 2019 13:58
-
-
Save AinTunez/a9f3dafbbf249e8ba6aa7b580f6fab5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private string EventToString(EMEVD.Event evt) | |
| { | |
| var paramList = new Dictionary<long, List<EMEVD.Parameter>>(); | |
| for (int i = 0; i < evt.Instructions.Count; i++) | |
| paramList[i] = new List<EMEVD.Parameter>(); | |
| foreach (var p in evt.Parameters) | |
| paramList[p.InstructionIndex].Add(p); | |
| var headerParams = new List<string>(); | |
| var insOut = new StringBuilder(); | |
| for (int i = 0; i < evt.Instructions.Count; i++) | |
| { | |
| var ins = evt.Instructions[i]; | |
| var doc = EVD.DOC[(uint)ins.Bank][(uint)ins.ID]; | |
| var param = paramList[i]; | |
| var funcName = UTIL.TitleCaseName(doc.Name); | |
| var argList = new List<dynamic>(); | |
| var br = new BinaryReaderEx(false, ins.Args); | |
| foreach (var argDef in doc.Arguments) | |
| { | |
| var prm = param.FirstOrDefault(p => p.TargetStartByte == br.Position); | |
| if (prm != null) | |
| { | |
| string text = "ARGS_" + prm.TargetStartByte + "_" + (prm.TargetStartByte + prm.ByteCount - 1); | |
| argList.Add(text); | |
| if (argDef.Type == 0) text += ": byte"; | |
| else if (argDef.Type == 1) text += ": ushort"; | |
| else if (argDef.Type == 2) text += ": uint"; | |
| else if (argDef.Type == 3) text += ": sbyte"; | |
| else if (argDef.Type == 4) text += ": short"; | |
| else if (argDef.Type == 5) text += ": int"; | |
| else if (argDef.Type == 6) text += ": float"; | |
| else if (argDef.Type == 8) text += ": ulong"; | |
| else throw new Exception("Invalid type in argDef"); | |
| if (!headerParams.Contains(text)) headerParams.Add(text); | |
| br.Skip((int) prm.ByteCount); | |
| } else | |
| { | |
| dynamic arg = "?"; | |
| if (argDef.Type == 0) arg = br.ReadByte(); //u8 | |
| else if (argDef.Type == 1) arg = br.ReadUInt16(); //u16 | |
| else if (argDef.Type == 2) arg = br.ReadUInt32(); //u32 | |
| else if (argDef.Type == 3) arg = br.ReadSByte(); //s8 | |
| else if (argDef.Type == 4) arg = br.ReadInt16(); //s16 | |
| else if (argDef.Type == 5) arg = br.ReadInt32(); //s32 | |
| else if (argDef.Type == 6) arg = br.ReadSingle(); //f32 | |
| else if (argDef.Type == 8) arg = br.ReadUInt64(); //u64 | |
| else throw new Exception("Invalid type in argDef"); | |
| argList.Add(arg); | |
| } | |
| ; | |
| } | |
| insOut.AppendLine("\t" + funcName + "(" + string.Join(", ", argList) + ")"); | |
| } | |
| var header = new StringBuilder(); | |
| header.AppendLine("@" + evt.RestBehavior.ToString()); | |
| header.AppendLine("def Event" + evt.ID + "(" + string.Join(", ", headerParams) + "):"); | |
| return header.ToString() + insOut.ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment