Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }