public static Event Deserialize(string s, MovesetNode node) { if (String.IsNullOrEmpty(s)) { return(null); } try { string[] lines = s.Split('|'); if (lines[0].Length != 8) { return(null); } Event newEv = new Event(); string id = lines[0]; uint idNumber = Convert.ToUInt32(id, 16); newEv.EventID = idNumber; uint _event = newEv.EventID; EventInformation info = newEv.Info; for (int i = 0; i < newEv._numArgs; i++) { string[] pLines = lines[i + 1].Split('\\'); int type = int.Parse(pLines[0]); if (type == 2) //Offset { string[] oLines = pLines[1].Split(','); int list = int.Parse(oLines[0]), type2 = int.Parse(oLines[1]), index = int.Parse(oLines[2]); ScriptOffsetInfo w = new ScriptOffsetInfo((ListValue)list, (TypeValue)type2, index); EventOffset o = (EventOffset)newEv.NewParam(i, 0, ParamType.Offset); o._script = node.GetScript(w); o._offsetInfo = w; } else { int value = int.Parse(pLines[1]); newEv.NewParam(i, value, type); } } return(newEv); } catch { return(null); } }
public override void PostParse() { //Get script node using raw offset //This happens in post parse so that all scripts have been parsed already MovesetNode node = (MovesetNode)_root; SakuraiEntryNode e = _root.GetEntry(RawOffset); bool exist = e != null && e is Event; _offsetInfo = node.GetScriptLocation(RawOffset); Script a; if (_offsetInfo._list == ListValue.Null && !exist) { node.SubRoutines.Add(a = Parse <Script>(RawOffset)); } else if (_offsetInfo._list != ListValue.References) { a = node.GetScript(_offsetInfo); } else { if (_externalEntry == null && _offsetInfo._index >= 0 && _offsetInfo._index < _root.ReferenceList.Count) { _externalEntry = _root.ReferenceList[_offsetInfo._index]; _externalEntry.References.Add(this); } return; } if (a == null) { a = GetScript(); } if (a != null) { a._actionRefs.Add(this); } else { throw new Exception("Script not found."); } _script = a; }
internal void LinkScript() { MovesetNode node = (MovesetNode)_root; SakuraiEntryNode e = _root.GetEntry(RawOffset); bool exist = e != null && e is Event; _offsetInfo = node.GetScriptLocation(RawOffset); Script a; if (_offsetInfo.list == ListValue.Null && !exist) { node.SubRoutines.Add(a = Parse <Script>(RawOffset)); } else if (_offsetInfo.list != ListValue.References) { a = node.GetScript(_offsetInfo); } else { if (_externalEntry == null && _offsetInfo.index >= 0 && _offsetInfo.index < _root.ReferenceList.Count) { _externalEntry = _root.ReferenceList[_offsetInfo.index]; _externalEntry.References.Add(this); } return; } if (a == null) { a = GetScript(); } if (a != null) { a._actionRefs.Add(this); } else { throw new Exception("Script not found."); } _script = a; }