public static DsgVar Read(EndianBinaryReader reader, Pointer offset, DsgMem dsgMem = null) { DsgVar dsgVar = new DsgVar(offset); dsgVar.off_dsgMemBuffer = Pointer.Read(reader); dsgVar.off_dsgVarInfo = Pointer.Read(reader); // Unknown stuff if (dsgMem == null) { dsgVar.something3 = reader.ReadUInt32(); } if (dsgMem == null) { dsgVar.amountOfInfos = reader.ReadUInt32(); dsgVar.dsgMemBufferLength = reader.ReadUInt32() * 4; } else { dsgVar.dsgMemBufferLength = reader.ReadUInt32(); dsgVar.amountOfInfos = reader.ReadUInt32(); } dsgVar.dsgVarInfos = new DsgVarInfoEntry[dsgVar.amountOfInfos]; if (dsgVar.off_dsgVarInfo != null && dsgVar.amountOfInfos > 0) { Pointer off_current = Pointer.Goto(ref reader, dsgVar.off_dsgVarInfo); for (int i = 0; i < dsgVar.amountOfInfos; i++) { DsgVarInfoEntry infoEntry = DsgVarInfoEntry.Read(reader, Pointer.Current(reader)); if (dsgMem != null) { infoEntry.value = dsgVar.ReadValueFromDsgMemBuffer(reader, infoEntry, dsgMem); } else { infoEntry.value = dsgVar.ReadValueFromDsgVarBuffer(reader, infoEntry, dsgVar); } dsgVar.dsgVarInfos[i] = infoEntry; } Pointer.Goto(ref reader, off_current); // Move the reader back to where it was } /*if (d.off_AI_model != null) { * Pointer.Goto(ref reader, d.off_AI_model); * d.AI_model = AIModel.Read(reader, d.off_AI_model); * }*/ return(dsgVar); }
public static DsgMem Read(EndianBinaryReader reader, Pointer offset) { DsgMem dsgMem = new DsgMem(offset); Pointer dsgVarPointer = Pointer.Read(reader); Pointer original = Pointer.Goto(ref reader, dsgVarPointer); dsgMem.off_dsgVar = Pointer.Read(reader); Pointer.Goto(ref reader, original); dsgMem.memBufferInitial = Pointer.Read(reader); dsgMem.memBuffer = Pointer.Read(reader); if (dsgMem.off_dsgVar != null) { Pointer.Goto(ref reader, dsgMem.off_dsgVar); dsgMem.dsgVar = DsgVar.Read(reader, dsgMem.off_dsgVar, dsgMem); } return(dsgMem); }
public static string DsgVarEntryToCSharpAssignment(DsgVar dsgVar, int index) { DsgVarInfoEntry dsgVarEntry = dsgVar.dsgVarInfos[index]; string text = ""; string typeText = DsgVarInfoEntry.GetCSharpStringFromType(dsgVarEntry.type); text += typeText + " " + "dsgVar_" + dsgVarEntry.number; if (dsgVar.defaultValues != null) { text += " = "; string stringVal = dsgVar.defaultValues[index].ToString(); text += stringVal; } text += ";"; return(text); }
public static DsgMem Read(Reader reader, Pointer offset) { DsgMem dsgMem = new DsgMem(offset); //MapLoader.Loader.print("DsgMem " + offset); Pointer dsgVarPointer = Pointer.Read(reader); Pointer.DoAt(ref reader, dsgVarPointer, () => { if (Settings.s.game == Settings.Game.R2Demo) { Pointer.Read(reader); } dsgMem.off_dsgVar = Pointer.Read(reader); }); dsgMem.memBufferInitial = Pointer.Read(reader); dsgMem.memBuffer = Pointer.Read(reader); Pointer.DoAt(ref reader, dsgMem.off_dsgVar, () => { dsgMem.dsgVar = DsgVar.Read(reader, dsgMem.off_dsgVar, dsgMem); }); return(dsgMem); }
protected override void ReadInternal(Reader reader) { //MapLoader.Loader.print("DsgMem " + Offset); Pointer dsgVarPointer = Pointer.Read(reader); Pointer.DoAt(ref reader, dsgVarPointer, () => { off_dsgVar = Pointer.Read(reader); }); memBufferInitial = Pointer.Read(reader); memBuffer = Pointer.Read(reader); dsgVar = MapLoader.Loader.FromOffsetOrRead <DsgVar>(reader, off_dsgVar); if (dsgVar != null && dsgVar.amountOfInfos > 0) { if (memBuffer != null && Settings.s.platform != Settings.Platform.DC) { // Current MemBuffer is cleared in DC files values = new DsgVarValue[dsgVar.amountOfInfos]; for (int i = 0; i < dsgVar.amountOfInfos; i++) { values[i] = new DsgVarValue(dsgVar.dsgVarInfos[i].type, this); values[i].ReadFromDsgMemBuffer(reader, dsgVar.dsgVarInfos[i], this); values[i].RegisterReferences(this); } } if (memBufferInitial != null) { valuesInitial = new DsgVarValue[dsgVar.amountOfInfos]; for (int i = 0; i < dsgVar.amountOfInfos; i++) { valuesInitial[i] = new DsgVarValue(dsgVar.dsgVarInfos[i].type, this); valuesInitial[i].ReadFromDsgMemBufferInitial(reader, dsgVar.dsgVarInfos[i], this); valuesInitial[i].RegisterReferences(this); } } } }
public void ReadFromDsgVarBuffer(Reader reader, DsgVarInfoEntry infoEntry, DsgVar dsgVar) { currentbuf = "dsgvar"; ReadFromBuffer(reader, infoEntry, dsgVar.off_dsgMemBuffer); }
protected override void ReadInternal(Reader reader) { MapLoader l = MapLoader.Loader; l.aiModels.Add(this); //l.print("AIModel @ " + Offset); off_behaviors_normal = Pointer.Read(reader); off_behaviors_reflex = Pointer.Read(reader); off_dsgVar = Pointer.Read(reader); if (Settings.s.engineVersion >= Settings.EngineVersion.R2) { off_macros = Pointer.Read(reader); flags = reader.ReadUInt32(); } Pointer.DoAt(ref reader, off_behaviors_normal, () => { Pointer off_entries = Pointer.Read(reader); uint num_entries = reader.ReadUInt32(); behaviors_normal = new Behavior[num_entries]; if (num_entries > 0) { Pointer.DoAt(ref reader, off_entries, () => { for (int i = 0; i < num_entries; i++) { behaviors_normal[i] = l.FromOffsetOrRead <Behavior>(reader, Pointer.Current(reader), inline: true); behaviors_normal[i].type = Behavior.BehaviorType.Intelligence; behaviors_normal[i].aiModel = this; behaviors_normal[i].index = i; } }); } }); Pointer.DoAt(ref reader, off_behaviors_reflex, () => { Pointer off_entries = Pointer.Read(reader); uint num_entries = reader.ReadUInt32(); behaviors_reflex = new Behavior[num_entries]; if (num_entries > 0) { Pointer.DoAt(ref reader, off_entries, () => { for (int i = 0; i < num_entries; i++) { behaviors_reflex[i] = l.FromOffsetOrRead <Behavior>(reader, Pointer.Current(reader), inline: true); behaviors_reflex[i].type = Behavior.BehaviorType.Reflex; behaviors_reflex[i].aiModel = this; behaviors_reflex[i].index = i; } }); } }); dsgVar = l.FromOffsetOrRead <DsgVar>(reader, off_dsgVar); Pointer.DoAt(ref reader, off_macros, () => { Pointer off_entries = Pointer.Read(reader); byte num_entries = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); macros = new Macro[num_entries]; if (num_entries > 0) { Pointer.DoAt(ref reader, off_entries, () => { for (int i = 0; i < num_entries; i++) { macros[i] = l.FromOffsetOrRead <Macro>(reader, Pointer.Current(reader), inline: true); macros[i].aiModel = this; macros[i].index = i; } }); } }); }
public static AIModel Read(EndianBinaryReader reader, Pointer offset) { MapLoader l = MapLoader.Loader; AIModel ai = new AIModel(offset); ai.off_behaviors_normal = Pointer.Read(reader); ai.off_behaviors_reflex = Pointer.Read(reader); ai.off_dsgVar = Pointer.Read(reader); ai.off_macros = Pointer.Read(reader); ai.flags = reader.ReadUInt32(); if (ai.off_behaviors_normal != null) { Pointer.Goto(ref reader, ai.off_behaviors_normal); Pointer off_entries = Pointer.Read(reader); uint num_entries = reader.ReadUInt32(); ai.behaviors_normal = new Behavior[num_entries]; if (num_entries > 0 && off_entries != null) { Pointer.Goto(ref reader, off_entries); for (int i = 0; i < num_entries; i++) { ai.behaviors_normal[i] = Behavior.Read(reader, Pointer.Current(reader)); } } } if (ai.off_behaviors_reflex != null) { Pointer.Goto(ref reader, ai.off_behaviors_reflex); Pointer off_entries = Pointer.Read(reader); uint num_entries = reader.ReadUInt32(); ai.behaviors_reflex = new Behavior[num_entries]; if (num_entries > 0 && off_entries != null) { Pointer.Goto(ref reader, off_entries); for (int i = 0; i < num_entries; i++) { ai.behaviors_reflex[i] = Behavior.Read(reader, Pointer.Current(reader)); } } } if (l.mode == MapLoader.Mode.Rayman2PC && ai.off_dsgVar != null) { Pointer.Goto(ref reader, ai.off_dsgVar); ai.dsgVar = DsgVar.Read(reader, ai.off_dsgVar); } if (ai.off_macros != null) { Pointer.Goto(ref reader, ai.off_macros); Pointer off_entries = Pointer.Read(reader); byte num_entries = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); ai.macros = new Macro[num_entries]; if (num_entries > 0 && off_entries != null) { Pointer.Goto(ref reader, off_entries); for (int i = 0; i < num_entries; i++) { ai.macros[i] = Macro.Read(reader, Pointer.Current(reader)); } } } l.aiModels.Add(ai); return(ai); }
public static DsgVar Read(Reader reader, Pointer offset, DsgMem dsgMem = null) { MapLoader l = MapLoader.Loader; //l.print("DsgVar " + offset); DsgVar dsgVar = new DsgVar(offset); dsgVar.off_dsgMemBuffer = Pointer.Read(reader); dsgVar.off_dsgVarInfo = Pointer.Read(reader); /*if (dsgMem != null) { * l.print(offset + " - " + dsgVar.off_dsgMemBuffer + " - " + dsgVar.off_dsgVarInfo); * l.print("DsgMem initial: " + dsgMem.memBufferInitial + " - cur: " + dsgMem.memBuffer); * }*/ // Unknown stuff if (dsgMem == null && Settings.s.platform != Settings.Platform.GC && Settings.s.platform != Settings.Platform.DC && Settings.s.platform != Settings.Platform.Xbox360 && Settings.s.game != Settings.Game.R2Revolution && Settings.s.game != Settings.Game.LargoWinch && Settings.s.engineVersion >= Settings.EngineVersion.R2) { dsgVar.something3 = reader.ReadUInt32(); } if (Settings.s.game == Settings.Game.R2Revolution) { dsgVar.dsgMemBufferLength = reader.ReadUInt16(); dsgVar.amountOfInfos = reader.ReadUInt16(); } else if (Settings.s.platform == Settings.Platform.GC || Settings.s.platform == Settings.Platform.DC || Settings.s.platform == Settings.Platform.Xbox360 || Settings.s.engineVersion < Settings.EngineVersion.R2 || Settings.s.game == Settings.Game.LargoWinch) { dsgVar.dsgMemBufferLength = reader.ReadUInt32(); dsgVar.amountOfInfos = reader.ReadByte(); } else if (dsgMem == null) { dsgVar.amountOfInfos = reader.ReadUInt32(); dsgVar.dsgMemBufferLength = reader.ReadUInt32() * 4; } else { dsgVar.dsgMemBufferLength = reader.ReadUInt32(); dsgVar.amountOfInfos = reader.ReadUInt32(); } if (dsgMem != null && dsgMem.memBufferInitial == null) { dsgMem.memBufferInitial = dsgVar.off_dsgMemBuffer; } dsgVar.dsgVarInfos = new DsgVarInfoEntry[dsgVar.amountOfInfos]; if (dsgVar.amountOfInfos > 0) { Pointer.DoAt(ref reader, dsgVar.off_dsgVarInfo, () => { //l.print(dsgVar.amountOfInfos); for (uint i = 0; i < dsgVar.amountOfInfos; i++) { DsgVarInfoEntry infoEntry = DsgVarInfoEntry.Read(reader, Pointer.Current(reader), i); //l.print(infoEntry.offset + " - " + infoEntry.typeNumber + " - " + infoEntry.type + " - " + infoEntry.offsetInBuffer); if (dsgMem != null) { if (Settings.s.platform != Settings.Platform.DC) { infoEntry.value = dsgVar.ReadValueFromDsgMemBuffer(reader, infoEntry, dsgMem); } if (dsgMem.memBufferInitial != null) { infoEntry.initialValue = dsgVar.ReadInitialValueFromDsgMemBuffer(reader, infoEntry, dsgMem); if (Settings.s.platform == Settings.Platform.DC) { infoEntry.value = infoEntry.initialValue; } } } else { infoEntry.value = dsgVar.ReadValueFromDsgVarBuffer(reader, infoEntry, dsgVar); } dsgVar.dsgVarInfos[i] = infoEntry; } }); } /*if (d.off_AI_model != null) { * Pointer.Goto(ref reader, d.off_AI_model); * d.AI_model = AIModel.Read(reader, d.off_AI_model); * }*/ return(dsgVar); }
public object ReadValueFromDsgVarBuffer(Reader reader, DsgVarInfoEntry infoEntry, DsgVar dsgVar) { return(ReadValueFromBuffer(reader, infoEntry, dsgVar.off_dsgMemBuffer)); }
public static AIModel Read(Reader reader, Pointer offset) { MapLoader l = MapLoader.Loader; AIModel ai = new AIModel(offset); //l.print("AIModel @ " + offset); ai.off_behaviors_normal = Pointer.Read(reader); ai.off_behaviors_reflex = Pointer.Read(reader); ai.off_dsgVar = Pointer.Read(reader); if (Settings.s.engineVersion >= Settings.EngineVersion.R2) { ai.off_macros = Pointer.Read(reader); ai.flags = reader.ReadUInt32(); } if (ai.off_behaviors_normal != null) { Pointer.Goto(ref reader, ai.off_behaviors_normal); Pointer off_entries = Pointer.Read(reader); uint num_entries = reader.ReadUInt32(); ai.behaviors_normal = new Behavior[num_entries]; if (num_entries > 0 && off_entries != null) { Pointer.Goto(ref reader, off_entries); for (int i = 0; i < num_entries; i++) { ai.behaviors_normal[i] = Behavior.Read(reader, Pointer.Current(reader)); ai.behaviors_normal[i].type = Behavior.BehaviorType.Rule; ai.behaviors_normal[i].aiModel = ai; ai.behaviors_normal[i].index = i; } } } if (ai.off_behaviors_reflex != null) { Pointer.Goto(ref reader, ai.off_behaviors_reflex); Pointer off_entries = Pointer.Read(reader); uint num_entries = reader.ReadUInt32(); ai.behaviors_reflex = new Behavior[num_entries]; if (num_entries > 0 && off_entries != null) { Pointer.Goto(ref reader, off_entries); for (int i = 0; i < num_entries; i++) { ai.behaviors_reflex[i] = Behavior.Read(reader, Pointer.Current(reader)); ai.behaviors_reflex[i].type = Behavior.BehaviorType.Reflex; ai.behaviors_reflex[i].aiModel = ai; ai.behaviors_reflex[i].index = i; } } } if (ai.off_dsgVar != null) { Pointer.Goto(ref reader, ai.off_dsgVar); ai.dsgVar = DsgVar.Read(reader, ai.off_dsgVar); } if (ai.off_macros != null) { Pointer.Goto(ref reader, ai.off_macros); Pointer off_entries = Pointer.Read(reader); byte num_entries = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); ai.macros = new Macro[num_entries]; if (num_entries > 0 && off_entries != null) { Pointer.Goto(ref reader, off_entries); for (int i = 0; i < num_entries; i++) { ai.macros[i] = Macro.Read(reader, Pointer.Current(reader)); ai.macros[i].aiModel = ai; ai.macros[i].index = i; } } } //l.aiModels.Add(ai); return(ai); }