public static Macro FromOffsetOrRead(Pointer offset, Reader reader) { if (offset == null) { return(null); } Macro m = FromOffset(offset); if (m == null) { Pointer.DoAt(ref reader, offset, () => { m = Macro.Read(reader, offset); }); } return(m); }
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 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); }