예제 #1
0
        public static State Read(Reader reader, Pointer offset, Family family, int index)
        {
            MapLoader l = MapLoader.Loader;
            //l.print("State " + Pointer.Current(reader));
            State s = new State(offset, family, index);

            l.states.Add(s);
            if (Settings.s.hasNames)
            {
                s.name = new string(reader.ReadChars(0x50)).TrimEnd('\0');
            }
            if (Settings.s.linkedListType != LinkedList.Type.Minimize)
            {
                s.off_entry_next = Pointer.Read(reader);
            }
            if (Settings.s.hasLinkedListHeaderPointers)
            {
                s.off_entry_prev = Pointer.Read(reader);
                Pointer.Read(reader); // another header at tail of state list
            }
            s.off_anim_ref     = Pointer.Read(reader);
            s.stateTransitions = LinkedList <Transition> .Read(ref reader, Pointer.Current(reader), element => {
                return(l.FromOffsetOrRead <Transition>(reader, element));
            });

            s.prohobitStates = LinkedList <Prohibit> .Read(ref reader, Pointer.Current(reader), element => {
                return(l.FromOffsetOrRead <Prohibit>(reader, element));
            });

            s.off_nextState       = Pointer.Read(reader, allowMinusOne: true);
            s.off_mechanicsIDCard = Pointer.Read(reader);
            if (Settings.s.engineVersion == Settings.EngineVersion.R3 &&
                Settings.s.game != Settings.Game.Dinosaur &&
                Settings.s.game != Settings.Game.LargoWinch)
            {
                s.off_cine_mapname = Pointer.Read(reader);
                s.off_cine_name    = Pointer.Read(reader);
            }
            if (Settings.s.engineVersion <= Settings.EngineVersion.Montreal)
            {
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                s.speed = reader.ReadByte();
            }
            else
            {
                reader.ReadByte();
                s.speed = reader.ReadByte();
                reader.ReadByte();
                s.customStateBits = reader.ReadByte();
                if (Settings.s.game == Settings.Game.LargoWinch)
                {
                    reader.ReadByte();
                }
            }
            if (s.off_mechanicsIDCard != null)
            {
                s.mechanicsIDCard = MechanicsIDCard.FromOffsetOrRead(s.off_mechanicsIDCard, reader);
            }
            Pointer.DoAt(ref reader, s.off_cine_mapname, () => {
                s.cine_mapname = reader.ReadNullDelimitedString();
            });
            Pointer.DoAt(ref reader, s.off_cine_name, () => {
                s.cine_name = reader.ReadNullDelimitedString();
            });
            if (Settings.s.engineVersion == Settings.EngineVersion.Montreal || Settings.s.game == Settings.Game.TTSE)
            {
                s.anim_refMontreal = l.FromOffsetOrRead <AnimationMontreal>(reader, s.off_anim_ref);
            }
            else
            {
                s.anim_ref = l.FromOffsetOrRead <AnimationReference>(reader, s.off_anim_ref);
            }
            return(s);
        }
예제 #2
0
        public static Family Read(Reader reader, Pointer offset)
        {
            MapLoader l = MapLoader.Loader;
            //l.print("Family " + offset);
            Family f = new Family(offset);

            f.off_family_next = Pointer.Read(reader);
            f.off_family_prev = Pointer.Read(reader);
            f.off_family_hdr  = Pointer.Read(reader); // at this offset, start and end pointers appear again
            if (Settings.s.game != Settings.Game.R2Revolution)
            {
                f.family_index = reader.ReadUInt32();
            }
            if (Settings.s.hasObjectTypes)
            {
                f.name = l.objectTypes[0][f.family_index].name;
            }
            //l.print("(" + f.family_index + ") " + f.name + " - " + offset);
            int stateIndex = 0;

            f.states = LinkedList <State> .Read(ref reader, Pointer.Current(reader), (off_element) => {
                //l.print(f.name + " [" + stateIndex + "]: " + off_element);
                State s = State.Read(reader, off_element, f, stateIndex++);
                return(s);
            });

            if (Settings.s.engineVersion == Settings.EngineVersion.R3 && Settings.s.game != Settings.Game.LargoWinch)
            {
                // (0x10 blocks: next, prev, list end, a3d pointer)
                f.preloadAnim = LinkedList <int> .ReadHeader(reader, Pointer.Current(reader));
            }
            if (Settings.s.game == Settings.Game.R2Revolution)
            {
                f.objectLists = LinkedList <ObjectList> .ReadHeader(reader, Pointer.Current(reader), LinkedList.Type.Double);
            }
            else
            {
                f.off_physical_list_default = Pointer.Read(reader);                 // Default objects table
                f.objectLists = LinkedList <ObjectList> .ReadHeader(reader, Pointer.Current(reader));
            }
            if (f.objectLists.off_head == f.objectLists.off_tail && f.objectLists.Count > 1)
            {
                f.objectLists.Count = 1;                                                                              // Correction for Rayman 2
            }
            f.off_bounding_volume = Pointer.Read(reader);
            if (Settings.s.game == Settings.Game.R3)
            {
                f.off_vector4s = Pointer.Read(reader);
                f.num_vector4s = reader.ReadUInt32();
                reader.ReadUInt32();
            }
            if (Settings.s.game == Settings.Game.LargoWinch)
            {
                reader.ReadUInt32();
                f.animBank   = reader.ReadByte();
                f.properties = reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
            }
            else if (Settings.s.engineVersion < Settings.EngineVersion.R3)
            {
                reader.ReadUInt32();
                f.animBank = reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                f.properties = reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
            }
            else
            {
                reader.ReadUInt32();
                reader.ReadByte();
                reader.ReadByte();
                f.animBank   = reader.ReadByte();
                f.properties = reader.ReadByte();
            }
            //l.print(f.name + " - Anim bank: " + f.animBank + " - id: " + l.objectTypes[0][f.family_index].id);
            f.objectLists.ReadEntries(ref reader, (off_list) => {
                ObjectList ol = ObjectList.FromOffsetOrRead(off_list, reader);
                f.AddNewPhysicalList(ol, alreadyAdded: true);

                if (Settings.s.game == Settings.Game.LargoWinch)
                {
                    foreach (State state in f.states)
                    {
                        if (state != null && state.anim_ref != null && state.anim_ref.a3dLargo != null)
                        {
                            foreach (Animation.Component.AnimNTTO n in state.anim_ref.a3dLargo.ntto)
                            {
                                if (!n.IsInvisibleNTTO && n.object_index < ol.entries.Length)
                                {
                                    ol.ReadPO(reader, n.object_index);
                                }
                            }
                        }
                    }
                }

                /*if (ol.containingFamilies.Count == 0) {
                 *  ol.Gao.transform.SetParent(f.Gao.transform);
                 * }
                 * if(!ol.containingFamilies.Contains(f)) ol.containingFamilies.Add(f);*/
                return(ol);
            });

            /*if (l.mode == MapLoader.Mode.Rayman3GC) {
             *  Pointer off_list_hdr_next = Pointer.Read(reader);
             *  Pointer off_list_hdr_prev = Pointer.Read(reader);
             *  Pointer off_list_hdr = Pointer.Read(reader);
             *  //if (off_list_hdr != null) Pointer.Goto(ref reader, off_list_hdr);
             * } else if (l.mode == MapLoader.Mode.Rayman3PC || l.mode == MapLoader.Mode.RaymanArenaPC) {
             *  reader.ReadUInt32(); // 0
             * } else if (l.mode == MapLoader.Mode.Rayman2PC) {
             *  Pointer off_list_hdr = Pointer.Read(reader);
             *  //if (off_list_hdr != null) Pointer.Goto(ref reader, off_list_hdr);
             * }
             * if (l.mode == MapLoader.Mode.Rayman3PC || l.mode == MapLoader.Mode.Rayman3GC) {
             *  Pointer off_list_hdr_1 = Pointer.Read(reader); // copy of off_subblocklist?
             *  Pointer off_list_hdr_2 = Pointer.Read(reader); // same?
             *  reader.ReadUInt32(); // 1?
             * }*/
            return(f);
        }
예제 #3
0
 public State(Pointer offset, Family family, int index)
 {
     this.offset = offset;
     this.family = family;
     this.index  = index;
 }