Exemple #1
0
 /// <summary>
 /// Tests the FAR1Archive class.
 /// </summary>
 private static void FAR1Test()
 {
     Console.WriteLine("Attempting to parse IFF...");
     //Testcases: djbooth.iff, trashcanvacation.iff, stair2.iff, stereos.iff, maid.iff, mask.iff, medicinecabinet.iff
     Iff  IffObject = FileManager.GetIFF("medicinecabinet.iff");
     OBJD Master    = IffObject.Master;
 }
        public static LogicElement C3prime(ParserState state)
        {
            Token t = state.PeepToken();

            if (t == null)
            {
                return(null);
            }
            if (t.Name == "<->")
            {
                state.PopToken();
                LogicElement exp = C4(state);
                if (exp.Right == null)
                {
                    exp.Right = C3prime(state);
                }
                Iff iff = new Iff(null, exp);
                return(iff);
            }
            else if (t.Type == TokenType.Operator)
            {
                return(null);
            }
            else if (t.Type != TokenType.Keyword && !state.Action.ContainsKey(t.Name))
            {
                t.ThrowException("Expected keyword token.");
            }
            return(null);
        }
Exemple #3
0
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         StringBuilder temp = new StringBuilder();
         var           num  = io.ReadByte();
         if (num < 48)
         { //less than smallest ASCII value for valid filename character, so assume this is a pascal string
             temp.Append(io.ReadCString(num));
         }
         else
         { //we're actually a null terminated string!
             temp.Append((char)num);
             while (stream.Position < stream.Length)
             {
                 char read = (char)io.ReadByte();
                 if (read == 0)
                 {
                     break;
                 }
                 else
                 {
                     temp.Append(read);
                 }
             }
         }
         Name = temp.ToString();
     }
 }
Exemple #4
0
        public GameGlobal Get(string filename)
        {
            lock (Cache)
            {
                if (Cache.ContainsKey(filename))
                {
                    return(Cache[filename]);
                }

                //if we can't load this let it throw an exception...
                //probably sanity check this when we add user objects.
                var iff = new Iff(Path.Combine(Content.Get().BasePath, "objectdata\\globals\\" + filename + ".iff"));
                OTF otf = null;
                try
                {
                    otf = new OTF(Path.Combine(Content.Get().BasePath, "objectdata\\globals\\" + filename + ".otf"));
                }
                catch (IOException)
                {
                    //if we can't load an otf, it probably doesn't exist.
                }
                var resource = new GameGlobalResource(iff, otf);

                var item = new GameGlobal
                {
                    Resource = resource
                };

                Cache.Add(filename, item);

                return(item);
            }
        }
Exemple #5
0
 /// <summary>
 /// Reads a FWAV chunk from a stream.
 /// </summary>
 /// <param name="iff">An Iff instance.</param>
 /// <param name="stream">A Stream object holding a FWAV chunk.</param>
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         Name = io.ReadNullTerminatedString();
     }
 }
        public void TestCorrectIFFParsing()
        {
            string GameDir   = CommonMethods.GetInstallDir();
            string Delimiter = (CommonMethods.IsLinux) ? "//" : "\\";

            FAR1Archive Arch = new FAR1Archive(GameDir + "objectdata" + Delimiter + "objects" + Delimiter +
                                               "objiff.far");

            Arch.ReadArchive(false);

            Iff Obj = new Iff();

            string TempFile = /*Path.GetTempFileName();*/ "C:\\anniversary.iff";

            byte[] EntryHash = FileUtilities.GenerateHash("anniversary.iff");

            Obj.Init(Arch.GrabEntry(EntryHash), false);
            BinaryWriter Writer    = new BinaryWriter(File.Open(TempFile, FileMode.OpenOrCreate));
            MemoryStream ObjStream = (MemoryStream)Obj.ToStream();

            Writer.Write(ObjStream.ToArray());
            Writer.Flush();
            Writer.Close();

            Assert.IsTrue(Obj.Init(File.Open(TempFile, FileMode.Open), true));
        }
Exemple #7
0
        public void Init()
        {
            Entries = new Dictionary <ulong, IffEntry <T> >();
            Cache   = new Dictionary <ulong, T>();

            MainIff = new Iff(IffFile);
        }
Exemple #8
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                Interactions = new TTABInteraction[io.ReadUInt16()];
                var version = io.ReadUInt16();
                IOProxy iop;
                if (version != 9 && version != 10) iop = new TTABNormal(io);
                else iop = new TTABFieldEncode(io); //haven't guaranteed that this works, since none of the objects in the test lot use it.

                for (int i = 0; i < Interactions.Length; i++)
                {
                    var result = new TTABInteraction();
                    result.ActionFunction = iop.ReadUInt16();
                    result.TestFunction = iop.ReadUInt16();
                    result.MotiveEntries = new TTABMotiveEntry[iop.ReadUInt32()];
                    result.Flags = iop.ReadUInt32();
                    result.TTAIndex = iop.ReadUInt32();
                    if (version > 6) result.AttenuationCode = iop.ReadUInt32();
                    result.AttenuationValue = iop.ReadFloat();
                    result.AutonomyThreshold = iop.ReadUInt32();
                    result.JoiningIndex = iop.ReadInt32();
                    for (int j = 0; j < result.MotiveEntries.Length; j++)
                    {
                        var motive = new TTABMotiveEntry();
                        if (version > 6) motive.EffectRangeMinimum = iop.ReadInt16();
                        motive.EffectRangeMaximum = iop.ReadInt16();
                        if (version > 6) motive.PersonalityModifier = iop.ReadUInt16();
                        result.MotiveEntries[j] = motive;
                    }
                    if (version > 9) result.Unknown = iop.ReadUInt32();
                    Interactions[i] = result;
                }
            }
        }
        public void Print <T>(Iff iff)
        {
            var type  = typeof(T);
            var items = iff.List <T>();

            if (items == null)
            {
                return;
            }

            if (type == typeof(SPR2))
            {
                Printer.H1("SPR2");
                foreach (var item in items)
                {
                    PrintSPR2((SPR2)(object)item);
                }
            }
            else if (type == typeof(OBJD))
            {
                Printer.H1("OBJD");
                foreach (var item in items)
                {
                    PrintOBJD((OBJD)(object)item);
                }
            }
            else if (type == typeof(SPR))
            {
                Printer.H1("SPR");
                foreach (var item in items)
                {
                    PrintSPR((SPR)(object)item);
                }
            }
        }
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         Name = io.ReadNullTerminatedString();
     }
 }
Exemple #11
0
        public CreditsScreen(ScreenManager Manager, SpriteBatch SBatch) : base(Manager, "Credits", SBatch,
                                                                               new Vector2(0, 0), new Vector2(float.Parse(ConfigurationManager.AppSettings["ScreenWidth"]), float.Parse(ConfigurationManager.AppSettings["ScreenHeight"])),
                                                                               ConfigurationManager.AppSettings["StartupPath"] + "/" + "gamedata/uiscripts/credits.uis")
        {
            BackgroundImg         = (UIImage)m_Elements["\"BackgroundImage\""];
            TSOLogoImage          = m_Controls["\"TSOLogoImage\""].Image;
            BackButtonIndentImage = m_Controls["\"BackButtonIndentImage\""].Image;
            WillImage             = (UIImage)m_Elements["\"WillImage\""];

            MaxisButton = (UIButton)m_Elements["\"MaxisButton\""];
            MaxisButton.OnButtonClicked += MaxisButton_OnButtonClicked;

            m_WillWrightDiag         = new WillWrightDiag(WillImage, this, new Vector2(100, 100));
            m_WillWrightDiag.IsDrawn = false;

            m_Credits     = FileManager.GetIFF("credits.iff");
            m_CreditsArea = (UIControl)m_Controls["\"CreditsArea\""];
            m_CreditsY    = m_CreditsArea.Size.Y;

            foreach (TranslatedString TStr in m_Credits.GetSTR(163).GetStringList(LanguageCodes.EngUS))
            {
                foreach (string Str in TStr.TranslatedStr.Split('\n'))
                {
                    m_CreditsStrings.Add(Str);
                }
            }

            m_CreditsTimer          = new Timer(300);
            m_CreditsTimer.Elapsed += M_CreditsTimer_Elapsed;
            m_CreditsTimer.Start();
        }
Exemple #12
0
        /// <summary>
        /// The user clicked on an item in the list of floors.
        /// </summary>
        private void LstFloors_MouseClick(object sender, MouseEventArgs e)
        {
            BtnZoomIn.Visible  = true;
            BtnZoomOut.Visible = true;

            HideFloorTextInterface();

            foreach (ListViewItem Item in LstFloors.Items)
            {
                //We only support selecting one item at a time.
                if (Item.Selected)
                {
                    byte[] Hash         = FileUtilities.GenerateHash(Item.Text);
                    int    ArchiveIndex = 0;

                    //This is NOT effective, but it's a tool so it doesn't have to be super fast...
                    foreach (FAR1Archive Archive in m_Archives)
                    {
                        ArchiveIndex++;

                        if (Archive.ContainsEntry(Hash))
                        {
                            m_CurrentIff = new Iff(RndFloors.GraphicsDevice);
                            m_CurrentIff.Init(Archive.GrabEntry(Hash), false);
                            RndFloors.AddSprite(m_CurrentIff.SPR2s[0]);

                            DirectoryInfo DirInfo = new DirectoryInfo(Archive.Path);
                            LblArchive.Text = "Floor is in: " + DirInfo.Parent + "\\" + Path.GetFileName(Archive.Path);
                            PopulateLanguagesAndStrings();
                        }
                    }
                }
            }
        }
Exemple #13
0
        public CreditsScreen(ScreenManager Manager, SpriteBatch SBatch) : base(Manager, "Credits", SBatch,
                                                                               new Vector2(0, 0), new Vector2(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight),
                                                                               GlobalSettings.Default.StartupPath + "\\" + "gamedata\\uiscripts\\credits.uis")
        {
            BackgroundImg         = (UIBackgroundImage)m_PResult.Elements["\"BackgroundImage\""];
            TSOLogoImage          = m_PResult.Controls["\"TSOLogoImage\""].Image;
            BackButtonIndentImage = m_PResult.Controls["\"BackButtonIndentImage\""].Image;
            WillImage             = (UIImage)m_PResult.Elements["\"WillImage\""];
            WillImage.Position    = new Vector2(/*22*/ 0, /*42*/ 0);

            MaxisButton = (UIButton)m_PResult.Elements["\"MaxisButton\""];
            MaxisButton.OnButtonClicked += MaxisButton_OnButtonClicked;

            BackButton           = (UIButton)m_PResult.Elements["\"BackButton\""];
            BackButton.DrawOrder = (int)DrawOrderEnum.UI;

            m_WillWrightDiag         = new WillWrightDiag(WillImage, this, new Vector2(100, 100));
            m_WillWrightDiag.Visible = false;
            RegisterElement(m_WillWrightDiag);

            m_Credits     = FileManager.Instance.GetIFF("credits.iff");
            m_CreditsArea = (UIControl)m_PResult.Controls["\"CreditsArea\""];
            m_CreditsY    = m_CreditsArea.Size.Y;

            int   StrID      = 0;
            float Separation = 1.0f;

            foreach (KeyValuePair <string, UIElement> KVP in m_PResult.Elements)
            {
                RegisterElement(KVP.Value);
            }

            foreach (TranslatedString TStr in m_Credits.GetSTR(163).GetStringList(LanguageCodes.EngUS))
            {
                foreach (string Str in TStr.TranslatedStr.Split('\n'))
                {
                    m_CreditsStrings.Add(new UILabel(Str, StrID++, new Vector2(m_CreditsArea.Position.X +
                                                                               m_CreditsCenterX, m_CreditsY + Separation), Manager.Font12px.MeasureString(Str),
                                                     Color.Wheat, 12, this)
                    {
                        DrawOrder = (int)DrawOrderEnum.Game
                    });
                    Separation += 15.0f;
                }
            }

            m_Tween    = new Tweener();
            Separation = 0.0f - (m_CreditsStrings.Count * 15.0f);

            foreach (UILabel Lbl in m_CreditsStrings)
            {
                m_Tween.Tween(Lbl, new { YPosition = Separation }, 1000);
                Separation += 15.0f;
            }

            HitVM.PlayEvent("bkground_credits");
        }
Exemple #14
0
        /// <summary>
        /// Creates a new XObject instance.
        /// </summary>
        /// <param name="Obj">The IFF from which to load this object.</param>
        public XObject(Iff Obj, ObjectModule Module) : base(Obj)
        {
            m_Module = Module;
            BHAV Main;

            if (Obj.Master.MainID < 8192) //The main subroutine is local.
            {
                Main = Obj.GetBHAV(Obj.Master.MainID);
            }
        }
Exemple #15
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                var num = io.ReadByte();
                Flags = io.ReadByte();

                Constants = new ushort[num];
                for (var i = 0; i < num; i++){
                    Constants[i] = io.ReadUInt16();
                }
            }
        }
Exemple #16
0
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         Interactions = new TTABInteraction[io.ReadUInt16()];
         var     version = io.ReadUInt16();
         IOProxy iop;
         if (version != 9 && version != 10)
         {
             iop = new TTABNormal(io);
         }
         else
         {
             iop = new TTABFieldEncode(io);  //haven't guaranteed that this works, since none of the objects in the test lot use it.
         }
         for (int i = 0; i < Interactions.Length; i++)
         {
             var result = new TTABInteraction();
             result.ActionFunction = iop.ReadUInt16();
             result.TestFunction   = iop.ReadUInt16();
             result.MotiveEntries  = new TTABMotiveEntry[iop.ReadUInt32()];
             result.Flags          = iop.ReadUInt32();
             result.TTAIndex       = iop.ReadUInt32();
             if (version > 6)
             {
                 result.AttenuationCode = iop.ReadUInt32();
             }
             result.AttenuationValue  = iop.ReadFloat();
             result.AutonomyThreshold = iop.ReadUInt32();
             result.JoiningIndex      = iop.ReadInt32();
             for (int j = 0; j < result.MotiveEntries.Length; j++)
             {
                 var motive = new TTABMotiveEntry();
                 if (version > 6)
                 {
                     motive.EffectRangeMinimum = iop.ReadInt16();
                 }
                 motive.EffectRangeMaximum = iop.ReadInt16();
                 if (version > 6)
                 {
                     motive.PersonalityModifier = iop.ReadUInt16();
                 }
                 result.MotiveEntries[j] = motive;
             }
             if (version > 9)
             {
                 result.Unknown = iop.ReadUInt32();
             }
             Interactions[i] = result;
         }
     }
 }
Exemple #17
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                var num = io.ReadByte();
                Flags = io.ReadByte();

                Constants = new ushort[num];
                for (var i = 0; i < num; i++)
                {
                    Constants[i] = io.ReadUInt16();
                }
            }
        }
        public void TestCorrectIFFParsing()
        {
            string GameDir   = GetInstallDir();
            string Delimiter = (IsLinux) ? "//" : "\\";

            FAR1Archive Arch = new FAR1Archive(GameDir + "objectdata" + Delimiter + "objects" + Delimiter +
                                               "objiff.far");

            Arch.ReadArchive(false);

            Iff Obj = new Iff();

            Assert.IsTrue(Obj.Init(Arch.GrabEntry(FileUtilities.GenerateHash("anniversary.iff")), false));
        }
Exemple #19
0
        /// <summary>
        /// Reads a BHAV from a stream.
        /// </summary>
        /// <param name="iff">Iff instance.</param>
        /// <param name="stream">A Stream instance holding a BHAV chunk.</param>
        public override void Read(Iff iff, System.IO.Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var version = io.ReadUInt16();
                uint count = 0;

                if (version == 0x8000)
                {
                    count = io.ReadUInt16();
                    io.Skip(8);
                }
                else if (version == 0x8001)
                {
                    count = io.ReadUInt16();
                    var unknown = io.ReadBytes(8);
                }
                else if (version == 0x8002)
                {
                    count = io.ReadUInt16();
                    this.Type = io.ReadByte();
                    this.Args = io.ReadByte();
                    this.Locals = io.ReadUInt16();
                    this.Flags = io.ReadUInt16();
                    io.Skip(2);
                }
                else if (version == 0x8003)
                {
                    this.Type = io.ReadByte();
                    this.Args = io.ReadByte();
                    this.Locals = io.ReadByte();
                    io.Skip(2);
                    this.Flags = io.ReadUInt16();
                    count = io.ReadUInt32();
                }

                Instructions = new BHAVInstruction[count];
                for (var i = 0; i < count; i++)
                {
                    var instruction = new BHAVInstruction();
                    instruction.Opcode = io.ReadUInt16();
                    instruction.TruePointer = io.ReadByte();
                    instruction.FalsePointer = io.ReadByte();
                    instruction.Operand = io.ReadBytes(8);
                    Instructions[i] = instruction;
                }
            }
        }
Exemple #20
0
 /// <summary>
 /// Reads a OBJf chunk from a stream.
 /// </summary>
 /// <param name="iff">An Iff instance.</param>
 /// <param name="stream">A Stream object holding a OBJf chunk.</param>
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         io.ReadUInt32(); //pad
         Version = io.ReadUInt32();
         string magic = io.ReadCString(4);
         functions = new OBJfFunctionEntry[io.ReadUInt32()];
         for (int i=0; i<functions.Length; i++) {
             var result = new OBJfFunctionEntry();
             result.ConditionFunction = io.ReadUInt16();
             result.ActionFunction = io.ReadUInt16();
             functions[i] = result;
         }
     }
 }
Exemple #21
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var  version    = io.ReadUInt16();
                uint imageCount = version < 20003 ? io.ReadUInt16() : io.ReadUInt32();
                Images = new DGRPImage[imageCount];

                for (var i = 0; i < imageCount; i++)
                {
                    var image = new DGRPImage(this);
                    image.Read(version, io);
                    Images[i] = image;
                }
            }
        }
        /// <summary>
        /// Loads a simantics object.
        /// </summary>
        /// <param name="ObjToLoad">The IFF from which to load the object.</param>
        public void Load(Iff ObjToLoad)
        {
            XObject Obj;
            XPerson Pers;

            if (ObjToLoad.Master.ObjectType == OBJDType.Person)
            {
                Pers = new XPerson(ObjToLoad, this);
                m_Persons.Add(Pers);
            }
            else
            {
                Obj = new XObject(ObjToLoad, this);
                m_Objects.Add(Obj);
            }
        }
        public BHAVEdit(Iff IffFile, BHAV CurrentBHAV)
        {
            InitializeComponent();

            m_CurrentBHAV = CurrentBHAV;
            m_Analyzer    = new BHAVAnalyzer(IffFile);

            foreach (byte[] Instruction in m_CurrentBHAV.Instructions)
            {
                IFFDecode DecodedInstruction = new IFFDecode(Instruction);
                m_Analyzer.DecodeInstruction(ref DecodedInstruction);

                m_DecodedInstructions.Add(DecodedInstruction);
                LstInstructions.Items.Add(DecodedInstruction.OutStream.ToString());
            }
        }
Exemple #24
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var version = io.ReadUInt16();
                uint imageCount = version < 20003 ? io.ReadUInt16() : io.ReadUInt32();
                Images = new DGRPImage[imageCount];

                for (var i = 0; i < imageCount; i++)
                {
                    var image = new DGRPImage(this);
                    image.Read(version, io);
                    Images[i] = image;
                }
            }
        }
        public override void Read(Iff iff, System.IO.Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                var  version = io.ReadUInt16();
                uint count   = 0;

                if (version == 0x8000)
                {
                    count = io.ReadUInt16();
                    io.Skip(8);
                }
                else if (version == 0x8001)
                {
                    count = io.ReadUInt16();
                    var unknown = io.ReadBytes(8);
                }
                else if (version == 0x8002)
                {
                    count       = io.ReadUInt16();
                    this.Type   = io.ReadByte();
                    this.Args   = io.ReadByte();
                    this.Locals = io.ReadUInt16();
                    this.Flags  = io.ReadUInt16();
                    io.Skip(2);
                }
                else if (version == 0x8003)
                {
                    this.Type   = io.ReadByte();
                    this.Args   = io.ReadByte();
                    this.Locals = io.ReadByte();
                    io.Skip(2);
                    this.Flags = io.ReadUInt16();
                    count      = io.ReadUInt32();
                }

                Instructions = new BHAVInstruction[count];
                for (var i = 0; i < count; i++)
                {
                    var instruction = new BHAVInstruction();
                    instruction.Opcode       = io.ReadUInt16();
                    instruction.TruePointer  = io.ReadByte();
                    instruction.FalsePointer = io.ReadByte();
                    instruction.Operand      = io.ReadBytes(8);
                    Instructions[i]          = instruction;
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// Reads a SPR chunk from a stream.
        /// </summary>
        /// <param name="iff">An Iff instance.</param>
        /// <param name="stream">A Stream object holding a SPR chunk.</param>
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var version1 = io.ReadUInt16();
                var version2 = io.ReadUInt16();
                uint version = 0;

                if (version1 == 0)
                {
                    io.ByteOrder = ByteOrder.BIG_ENDIAN;
                    version = version2;
                }
                else
                {
                    version = version1;
                }

                var spriteCount = io.ReadUInt32();
                PaletteID = (ushort)io.ReadUInt32();

                Frames = new List<SPRFrame>();
                if (version != 1001)
                {
                    var offsetTable = new List<uint>();
                    for (var i = 0; i < spriteCount; i++)
                    {
                        offsetTable.Add(io.ReadUInt32());
                    }
                    for (var i = 0; i < spriteCount; i++)
                    {
                        var frame = new SPRFrame(this);
                        frame.Read(version, io);
                        Frames.Add(frame);
                    }
                }
                else
                {
                    while (io.HasMore)
                    {
                        var frame = new SPRFrame(this);
                        frame.Read(version, io);
                        Frames.Add(frame);
                    }
                }
            }
        }
Exemple #27
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                var  version1 = io.ReadUInt16();
                var  version2 = io.ReadUInt16();
                uint version  = 0;

                if (version1 == 0)
                {
                    io.ByteOrder = ByteOrder.BIG_ENDIAN;
                    version      = version2;
                }
                else
                {
                    version = version1;
                }

                var spriteCount = io.ReadUInt32();
                PaletteID = (ushort)io.ReadUInt32();

                Frames = new List <SPRFrame>();
                if (version != 1001)
                {
                    var offsetTable = new List <uint>();
                    for (var i = 0; i < spriteCount; i++)
                    {
                        offsetTable.Add(io.ReadUInt32());
                    }
                    for (var i = 0; i < spriteCount; i++)
                    {
                        var frame = new SPRFrame(this);
                        frame.Read(version, io);
                        Frames.Add(frame);
                    }
                }
                else
                {
                    while (io.HasMore)
                    {
                        var frame = new SPRFrame(this);
                        frame.Read(version, io);
                        Frames.Add(frame);
                    }
                }
            }
        }
Exemple #28
0
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         io.ReadUInt32(); //pad
         Version = io.ReadUInt32();
         string magic = io.ReadCString(4);
         functions = new OBJfFunctionEntry[io.ReadUInt32()];
         for (int i = 0; i < functions.Length; i++)
         {
             var result = new OBJfFunctionEntry();
             result.ConditionFunction = io.ReadUInt16();
             result.ActionFunction    = io.ReadUInt16();
             functions[i]             = result;
         }
     }
 }
Exemple #29
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var version = io.ReadUInt32();
                var numEntries = io.ReadUInt32();
                var reserved = io.ReadBytes(8);

                Colors = new Color[numEntries];
                for (var i = 0; i < numEntries; i++)
                {
                    var r = io.ReadByte();
                    var g = io.ReadByte();
                    var b = io.ReadByte();
                    Colors[i] = new Color(r, g, b);
                }
            }
        }
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var version    = io.ReadUInt32();
                var numEntries = io.ReadUInt32();
                var reserved   = io.ReadBytes(8);

                Colors = new Color[numEntries];
                for (var i = 0; i < numEntries; i++)
                {
                    var r = io.ReadByte();
                    var g = io.ReadByte();
                    var b = io.ReadByte();
                    Colors[i] = new Color(r, g, b);
                }
            }
        }
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var  version     = io.ReadUInt32();
                uint spriteCount = 0;

                if (version == 1000)
                {
                    spriteCount      = io.ReadUInt32();
                    DefaultPaletteID = io.ReadUInt32();
                    var offsetTable = new uint[spriteCount];
                    for (var i = 0; i < spriteCount; i++)
                    {
                        offsetTable[i] = io.ReadUInt32();
                    }

                    Frames = new SPR2Frame[spriteCount];
                    for (var i = 0; i < spriteCount; i++)
                    {
                        var frame = new SPR2Frame(this);
                        io.Seek(SeekOrigin.Begin, offsetTable[i]);

                        frame.Read(version, io);
                        Frames[i] = frame;
                    }
                }
                else if (version == 1001)
                {
                    DefaultPaletteID = io.ReadUInt32();
                    spriteCount      = io.ReadUInt32();

                    Frames = new SPR2Frame[spriteCount];
                    for (var i = 0; i < spriteCount; i++)
                    {
                        var frame = new SPR2Frame(this);
                        frame.Read(version, io);
                        Frames[i] = frame;
                    }
                }
            }
        }
Exemple #32
0
        /// <summary>
        /// Reads a SPR2 chunk from a stream.
        /// </summary>
        /// <param name="iff">An Iff instance.</param>
        /// <param name="stream">A Stream object holding a SPR2 chunk.</param>
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var version = io.ReadUInt32();
                uint spriteCount = 0;

                if (version == 1000)
                {
                    spriteCount = io.ReadUInt32();
                    DefaultPaletteID = io.ReadUInt32();
                    var offsetTable = new uint[spriteCount];
                    for (var i = 0; i < spriteCount; i++)
                    {
                        offsetTable[i] = io.ReadUInt32();
                    }

                    Frames = new SPR2Frame[spriteCount];
                    for (var i = 0; i < spriteCount; i++)
                    {
                        var frame = new SPR2Frame(this);
                        io.Seek(SeekOrigin.Begin, offsetTable[i]);

                        frame.Read(version, io);
                        Frames[i] = frame;
                    }
                }
                else if (version == 1001)
                {
                    DefaultPaletteID = io.ReadUInt32();
                    spriteCount = io.ReadUInt32();

                    Frames = new SPR2Frame[spriteCount];
                    for (var i = 0; i < spriteCount; i++)
                    {
                        var frame = new SPR2Frame(this);
                        frame.Read(version, io);
                        Frames[i] = frame;
                    }
                }
            }
        }
        /// <summary>
        /// Creates a new SimulationObject instance.
        /// </summary>
        /// <param name="Obj">The OBJD for this object. Assumed to be the master OBJD if the object is multi-tile.</param>
        /// <param name="Container">The IFF archive where the OBJD resides.</param>
        public SimulationObject(OBJD Obj, Iff Container, string GUID)
        {
            m_GUID = GUID;

            if (!Obj.IsMultiTile)
            {
                m_MasterOBJD      = Obj;
                m_ObjectContainer = Container;
            }
            else //Load the OBJDs for the other tiles...
            {
                foreach (OBJD O in m_ObjectContainer.OBJDs)
                {
                    if (O.MasterID == Obj.MasterID)
                    {
                        m_Slaves.Add(O);
                    }
                }
            }
        }
Exemple #34
0
        public UIHeadlineRenderer(VMRuntimeHeadline headline)
            : base(headline)
        {
            if (Sprites == null)
            {
                Sprites = new Iff(Content.Get().GetPath("objectdata/globals/sprites.iff"));
                WhitePx = TextureUtils.TextureFromColor(GameFacade.GraphicsDevice, Color.White);
            }

            if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
            {
                Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
            }

            if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
            {
                BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
            }

            LastZoom = WorldZoom.Near;
            RecalculateTarget();
        }
Exemple #35
0
 public override void Read(Iff iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         StringBuilder temp = new StringBuilder();
         var num = io.ReadByte();
         if (num < 48)
         { //less than smallest ASCII value for valid filename character, so assume this is a pascal string
             temp.Append(io.ReadCString(num));
         }
         else
         { //we're actually a null terminated string!
             temp.Append((char)num);
             while (stream.Position < stream.Length)
             {
                 char read = (char)io.ReadByte();
                 if (read == 0) break;
                 else temp.Append(read);
             }
         }
         Name = temp.ToString();
     }
 }
Exemple #36
0
        /// <summary>
        /// Creates a new XPerson instance.
        /// </summary>
        /// <param name="Obj">The IFF from which to load this object.</param>
        public XPerson(Iff Obj, ObjectModule Module) : base(Obj)
        {
            bool IsGlobal = false;

            m_Module = Module;
            BHAV Main;

            if (Obj.Master.MasterID < 4096) //The main subroutine is global.
            {
                Main     = m_Module.Globals.GetBHAV(Obj.Master.MainID);
                IsGlobal = true;
            }
            if (Obj.Master.MainID < 8192 && IsGlobal != true) //The main subroutine is local.
            {
                Main = Obj.GetBHAV(Obj.Master.MainID);
            }
            else if (Obj.Master.MainID > 8192) //The main subroutine is semi-global.
            {
                //TODO: Is this the correct ID of the GLOB chunk?
                Iff SemiGlobal = FileManager.GetIFF(Obj.GetGLOB(Obj.Master.Global).SemiGlobalIFF);
                Main = SemiGlobal.GetBHAV(Obj.Master.MainID);
            }
        }
Exemple #37
0
        public override void Read(Iff iff, System.IO.Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                var zero = io.ReadUInt32();
                var version = io.ReadUInt32();
                var slotMagic = io.ReadBytes(4);
                var numSlots = io.ReadUInt32();

                Slots = new SLOTItem[numSlots];

                var span = 0;
                switch (version){
                    case 4:
                        span = 34;
                        break;
                    case 6:
                        span = 54;
                        break;
                    case 7:
                        span = 58;
                        break;
                    case 8:
                        span = 62;
                        break;
                    case 9:
                        span = 66;
                        break;
                    case 10:
                        span = 70;
                        break;
                }

                /** The span for version 4 is 34.  The span for version 6 is 54.  The span for version 7 is 58.  The span for version 8 is 62.  The span for version 9 is 66.  The span for version 10 is 70.  **/
                for (var i = 0; i < numSlots; i++){
                    io.Mark();

                    var item = new SLOTItem();
                    item.Type = io.ReadUInt16();
                    item.Offset = new Vector3(
                        io.ReadFloat(),
                        io.ReadFloat(),
                        io.ReadFloat()
                    );

                    var standing = io.ReadInt32();
                    var sitting = io.ReadInt32();
                    var ground = io.ReadInt32();
                    var rsflags = io.ReadInt32();
                    var snaptargetslot = io.ReadInt32();
                    var minproximity = io.ReadInt32();

                    item.Standing = standing;
                    item.Sitting = sitting;
                    item.Ground = ground;
                    item.Rsflags = (SLOTFlags)rsflags;
                    item.SnapTargetSlot = snaptargetslot;
                    item.MinProximity = minproximity;

                    if (version >= 6)
                    {
                        var maxproximity = io.ReadInt32();
                        var optimalproximity = io.ReadInt32();
                        var i9 = io.ReadInt32();
                        var i10 = io.ReadInt32();
                        var gradient = io.ReadFloat();

                        item.MaxProximity = maxproximity;
                        item.OptimalProximity = optimalproximity;
                        item.Gradient = gradient;
                    }

                    if (version >= 7)
                    {
                        var i11 = io.ReadInt32();
                    }

                    if (version >= 8){
                        var facing = io.ReadInt32();
                        var resolution = io.ReadInt32();
                    }

                    Slots[i] = item;
                }
            }
        }
        /// <summary>
        /// Initiates loading of floors.
        /// </summary>
        public void Init()
        {
            /**
             * TODO: We can make this lazy load a bit better. Inside the far archives we
             * could just keep far entry pointers rather than processing them. Assuming each file
             * in the far only contains 1 floor style. If its variable this may not be possible
             */

            this.ById   = new Dictionary <ushort, Floor>();
            this.Floors = new List <Floor>();

            var floorGlobalsPath = ContentManager.GetPath("objectdata/globals/floors.iff");
            var floorGlobals     = new Iff(floorGlobalsPath);

            /** There is a small handful of floors in a global file for some reason **/
            ushort floorID = 1;

            for (ushort i = 1; i < 30; i++)
            {
                var far    = floorGlobals.Get <SPR2>(i);
                var medium = floorGlobals.Get <SPR2>((ushort)(i + 256));
                var near   = floorGlobals.Get <SPR2>((ushort)(2048));

                this.AddFloor(new Floor
                {
                    ID     = floorID,
                    Far    = far,
                    Medium = medium,
                    Near   = near
                });
                floorID++;
            }

            floorID = 256;

            var archives = new string[]
            {
                "housedata/floors/floors.far",
                "housedata/floors2/floors2.far",
                "housedata/floors3/floors3.far",
                "housedata/floors4/floors4.far"
            };

            for (var i = 0; i < archives.Length; i++)
            {
                var archivePath = ContentManager.GetPath(archives[i]);
                var archive     = new FAR1Archive(archivePath);
                var entries     = archive.GetAllEntries();

                foreach (var entry in entries)
                {
                    var iff   = new Iff();
                    var bytes = archive.GetEntry(entry);
                    using (var stream = new MemoryStream(bytes))
                    {
                        iff.Read(stream);
                    }

                    var far    = iff.Get <SPR2>(1);
                    var medium = iff.Get <SPR2>(257);
                    var near   = iff.Get <SPR2>(513);

                    AddFloor(new Floor {
                        ID     = floorID,
                        Near   = near,
                        Medium = medium,
                        Far    = far
                    });
                    floorID++;
                }
            }
        }
 /// <summary>
 /// Reads this chunk from an IFF.
 /// </summary>
 /// <param name="iff">The IFF to read from.</param>
 /// <param name="stream">The stream to read from.</param>
 public abstract void Read(Iff iff, Stream stream);
Exemple #40
0
        /// <summary>
        /// Reads a STR chunk from a stream.
        /// </summary>
        /// <param name="iff">An Iff instance.</param>
        /// <param name="stream">A Stream object holding a STR chunk.</param>
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                var formatCode = io.ReadInt16();
                if (!io.HasMore){ return; }

                if (formatCode == 0)
                {
                    var numStrings = io.ReadUInt16();
                    Strings = new STRItem[numStrings];
                    for (var i = 0; i < numStrings; i++)
                    {
                        Strings[i] = new STRItem
                        {
                            Value = io.ReadPascalString()
                        };
                    }
                }
                //This format changed 00 00 to use C strings rather than Pascal strings.
                else if (formatCode == -1)
                {
                    var numStrings = io.ReadUInt16();
                    Strings = new STRItem[numStrings];
                    for (var i = 0; i < numStrings; i++)
                    {
                        Strings[i] = new STRItem
                        {
                            Value = io.ReadNullTerminatedString()
                        };
                    }
                }
                //This format changed FF FF to use string pairs rather than single strings.
                else if (formatCode == -2)
                {
                    var numStrings = io.ReadUInt16();
                    Strings = new STRItem[numStrings];
                    for (var i = 0; i < numStrings; i++)
                    {
                        Strings[i] = new STRItem
                        {
                            Value = io.ReadNullTerminatedString(),
                            Comment = io.ReadNullTerminatedString()
                        };
                    }
                }
                //This format changed FD FF to use a language code.
                else if (formatCode == -3)
                {
                    var numStrings = io.ReadUInt16();
                    Strings = new STRItem[numStrings];
                    for (var i = 0; i < numStrings; i++)
                    {
                        Strings[i] = new STRItem
                        {
                            LanguageCode = (byte)(io.ReadByte() + 1),
                            Value = io.ReadNullTerminatedString(),
                            Comment = io.ReadNullTerminatedString()
                        };
                    }
                }
                //This format is only used in The Sims Online. The format is essentially a performance improvement:
                //it counteracts both the short string limit of 255 characters found in 00 00 and the inherent slowness
                //of null-terminated strings in the other formats (which requires two passes over each string), and it
                //also provides a string pair count for each language set which eliminates the need for two passes over
                //each language set.
                else if (formatCode == -4)
                {
                    var numLanguageSets = io.ReadByte();
                    this.LanguageSets = new STRLanguageSet[numLanguageSets];

                    for(var i=0; i < numLanguageSets; i++)
                    {
                        var item = new STRLanguageSet();
                        var numStringPairs = io.ReadUInt16();
                        item.Strings = new STRItem[numStringPairs];
                        for (var x = 0; x < numStringPairs; x++)
                        {
                            item.Strings[x] = new STRItem
                            {
                                LanguageCode = (byte)(io.ReadByte() + 1),
                                Value = io.ReadVariableLengthPascalString(),
                                Comment = io.ReadVariableLengthPascalString()
                            };
                        }
                        this.LanguageSets[i] = item;
                    }
                }
            }
        }
Exemple #41
0
        public override void Read(Iff iff, System.IO.Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                var zero = io.ReadUInt32();
                var version = io.ReadUInt32();
                var slotMagic = io.ReadBytes(4);
                var numSlots = io.ReadUInt32();

                Slots = new Dictionary<ushort, List<SLOTItem>>();

                /** The span for version 4 is 34.
                 * The span for version 6 is 54.
                 * The span for version 7 is 58.
                 * The span for version 8 is 62.
                 * The span for version 9 is 66.
                 * The span for version 10 is 70.  **/
                for (var i = 0; i < numSlots; i++){
                    io.Mark();

                    var item = new SLOTItem();
                    item.Type = io.ReadUInt16();
                    item.Offset = new Vector3(
                        io.ReadFloat(),
                        io.ReadFloat(),
                        io.ReadFloat()
                    );

                    var standing = io.ReadInt32();
                    var sitting = io.ReadInt32();
                    var ground = io.ReadInt32();
                    var rsflags = io.ReadInt32();
                    var snaptargetslot = io.ReadInt32();
                    var minproximity = io.ReadInt32();

                    //bonuses (0 means never)
                    item.Standing = standing; //score bonus for standing destinations
                    item.Sitting = sitting; //score bonus for sitting destinations
                    item.Ground = ground; //score bonus for sitting on ground

                    item.Rsflags = (SLOTFlags)rsflags;
                    item.SnapTargetSlot = snaptargetslot;
                    item.MinProximity = minproximity;

                    if (version >= 6)
                    {
                        var maxproximity = io.ReadInt32();
                        var optimalproximity = io.ReadInt32();
                        var i9 = io.ReadInt32();
                        var i10 = io.ReadInt32();

                        item.MaxProximity = maxproximity;
                        item.OptimalProximity = optimalproximity;
                    }

                    if (version >= 7) item.Gradient = io.ReadFloat();

                    if (version >= 8) item.Height = io.ReadInt32();

                    if (version >= 9) item.Facing = (SLOTFacing)io.ReadInt32();

                    if (version >= 10) item.Resolution = io.ReadInt32();

                    if (!Slots.ContainsKey(item.Type)) Slots.Add(item.Type, new List<SLOTItem>());
                    Slots[item.Type].Add(item);
                }
            }
        }
Exemple #42
0
 public XMTObject(Iff IffObj)
 {
     m_IffObj = IffObj;
     m_Thread = new SimanticsThread(this);
 }
Exemple #43
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                this.Version = io.ReadUInt32();

                /**136 (80 fields)
                 *  138a (95 fields) - Used for The Sims 1 base game objects?
                 *  138b (108 fields) - Used for The Sims 1 expansion objects?
                 *  139 (96 fields)
                 *  140 (97 fields)
                 *  141 (97 fields)
                 *  142 (105 fields)**/
                var numFields = 80;
                if (Version == 138)
                {
                    numFields = 95;
                }
                else if (Version == 139)
                {
                    numFields = 96;
                }
                else if (Version == 140)
                {
                    numFields = 97;
                }
                else if (Version == 141)
                {
                    numFields = 97;
                }
                else if (Version == 142)
                {
                    numFields = 105;
                }

                numFields -= 2;
                RawData    = new ushort[numFields];
                io.Mark();

                for (var i = 0; i < numFields; i++)
                {
                    RawData[i] = io.ReadUInt16();
                }

                io.SeekFromMark(0);

                this.StackSize          = io.ReadUInt16();
                this.BaseGraphicID      = io.ReadUInt16();
                this.NumGraphics        = io.ReadUInt16();
                this.BHAV_MainID        = io.ReadUInt16();
                this.BHAV_GardeningID   = io.ReadUInt16();
                this.TreeTableID        = io.ReadUInt16();
                this.InteractionGroupID = io.ReadUInt16();
                this.ObjectType         = (OBJDType)io.ReadUInt16();
                this.MasterID           = io.ReadUInt16();
                this.SubIndex           = io.ReadUInt16();
                this.BHAV_WashHandsID   = io.ReadUInt16();
                this.AnimationTableID   = io.ReadUInt16();
                this.GUID                     = io.ReadUInt32();
                this.Disabled                 = io.ReadUInt16();
                this.OldTreeID                = io.ReadUInt16();
                this.Price                    = io.ReadUInt16();
                this.BodyStringID             = io.ReadUInt16();
                this.SlotID                   = io.ReadUInt16();
                this.BHAV_AllowIntersectionID = io.ReadUInt16();
                this.UsesInTable              = io.ReadUInt16();
                this.BitField1                = io.ReadUInt16();
                this.BHAV_PrepareFoodID       = io.ReadUInt16();
                this.BHAV_CookFoodID          = io.ReadUInt16();
                this.BHAV_PlaceSurfaceID      = io.ReadUInt16();
                this.BHAV_DisposeID           = io.ReadUInt16();
                this.BHAV_EatID               = io.ReadUInt16();
                this.BHAV_PickupID            = io.ReadUInt16();
                this.BHAV_WashDishID          = io.ReadUInt16();
                this.BHAV_EatSurfaceID        = io.ReadUInt16();
                this.BHAV_SitID               = io.ReadUInt16();
                this.BHAV_StandID             = io.ReadUInt16();

                this.SalePrice           = io.ReadUInt16();
                this.InitialDepreciation = io.ReadUInt16();
                this.DailyDepreciation   = io.ReadUInt16();
                this.SelfDepreciating    = io.ReadUInt16();
                this.DepreciationLimit   = io.ReadUInt16();
                this.RoomFlags           = io.ReadUInt16();
                this.FunctionFlags       = io.ReadUInt16();
                this.CatalogStringsID    = io.ReadUInt16();

                this.Global              = io.ReadUInt16();
                this.BHAV_Init           = io.ReadUInt16();
                this.BHAV_Place          = io.ReadUInt16();
                this.BHAV_UserPickup     = io.ReadUInt16();
                this.WallStyle           = io.ReadUInt16();
                this.BHAV_Load           = io.ReadUInt16();
                this.BHAV_UserPlace      = io.ReadUInt16();
                this.ObjectVersion       = io.ReadUInt16();
                this.BHAV_RoomChange     = io.ReadUInt16();
                this.MotiveEffectsID     = io.ReadUInt16();
                this.BHAV_Cleanup        = io.ReadUInt16();
                this.BHAV_LevelInfo      = io.ReadUInt16();
                this.CatalogID           = io.ReadUInt16();
                this.BHAV_ServingSurface = io.ReadUInt16();
                this.LevelOffset         = io.ReadUInt16();
                this.Shadow              = io.ReadUInt16();
                this.NumAttributes       = io.ReadUInt16();

                this.BHAV_Clean                = io.ReadUInt16();
                this.BHAV_QueueSkipped         = io.ReadUInt16();
                this.FrontDirection            = io.ReadUInt16();
                this.BHAV_WallAdjacencyChanged = io.ReadUInt16();
                this.MyLeadObject              = io.ReadUInt16();
                this.DynamicSpriteBaseId       = io.ReadUInt16();
                this.NumDynamicSprites         = io.ReadUInt16();

                if (this.NumAttributes == 0 && ObjectType != OBJDType.Portal)
                {
                    System.Diagnostics.Debug.WriteLine(GUID.ToString("x"));
                }
            }
        }
Exemple #44
0
        public override void Read(Iff iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN)){
                this.Version = io.ReadUInt32();

                /**136 (80 fields)
                    138a (95 fields) - Used for The Sims 1 base game objects?
                    138b (108 fields) - Used for The Sims 1 expansion objects?
                    139 (96 fields)
                    140 (97 fields)
                    141 (97 fields)
                    142 (105 fields)**/
                var numFields = 80;
                if (Version == 138){
                    numFields = 95;
                }else if (Version == 139){
                    numFields = 96;
                }else if (Version == 140){
                    numFields = 97;
                }else if (Version == 141){
                    numFields = 97;
                }else if (Version == 142){
                    numFields = 105;
                }

                numFields -= 2;
                RawData = new ushort[numFields];
                io.Mark();

                for (var i = 0; i < numFields; i++){
                    RawData[i] = io.ReadUInt16();
                }

                io.SeekFromMark(0);

                this.StackSize = io.ReadUInt16();
                this.BaseGraphicID = io.ReadUInt16();
                this.NumGraphics = io.ReadUInt16();
                this.BHAV_MainID = io.ReadUInt16();
                this.BHAV_GardeningID = io.ReadUInt16();
                this.TreeTableID = io.ReadUInt16();
                this.InteractionGroupID = io.ReadUInt16();
                this.ObjectType = (OBJDType)io.ReadUInt16();
                this.MasterID = io.ReadUInt16();
                this.SubIndex = io.ReadUInt16();
                this.BHAV_WashHandsID = io.ReadUInt16();
                this.AnimationTableID = io.ReadUInt16();
                this.GUID = io.ReadUInt32();
                this.Disabled = io.ReadUInt16();
                this.OldTreeID = io.ReadUInt16();
                this.Price = io.ReadUInt16();
                this.BodyStringID = io.ReadUInt16();
                this.SlotID = io.ReadUInt16();
                this.BHAV_AllowIntersectionID = io.ReadUInt16();
                this.UsesInTable = io.ReadUInt16();
                this.BitField1 = io.ReadUInt16();
                this.BHAV_PrepareFoodID = io.ReadUInt16();
                this.BHAV_CookFoodID = io.ReadUInt16();
                this.BHAV_PlaceSurfaceID = io.ReadUInt16();
                this.BHAV_DisposeID = io.ReadUInt16();
                this.BHAV_EatID = io.ReadUInt16();
                this.BHAV_PickupID = io.ReadUInt16();
                this.BHAV_WashDishID = io.ReadUInt16();
                this.BHAV_EatSurfaceID = io.ReadUInt16();
                this.BHAV_SitID = io.ReadUInt16();
                this.BHAV_StandID = io.ReadUInt16();

                this.SalePrice = io.ReadUInt16();
                this.InitialDepreciation = io.ReadUInt16();
                this.DailyDepreciation = io.ReadUInt16();
                this.SelfDepreciating = io.ReadUInt16();
                this.DepreciationLimit = io.ReadUInt16();
                this.RoomFlags = io.ReadUInt16();
                this.FunctionFlags = io.ReadUInt16();
                this.CatalogStringsID = io.ReadUInt16();

                this.Global = io.ReadUInt16();
                this.BHAV_Init = io.ReadUInt16();
                this.BHAV_Place = io.ReadUInt16();
                this.BHAV_UserPickup = io.ReadUInt16();
                this.WallStyle = io.ReadUInt16();
                this.BHAV_Load = io.ReadUInt16();
                this.BHAV_UserPlace = io.ReadUInt16();
                this.ObjectVersion = io.ReadUInt16();
                this.BHAV_RoomChange = io.ReadUInt16();
                this.MotiveEffectsID = io.ReadUInt16();
                this.BHAV_Cleanup = io.ReadUInt16();
                this.BHAV_LevelInfo = io.ReadUInt16();
                this.CatalogID = io.ReadUInt16();
                this.BHAV_ServingSurface = io.ReadUInt16();
                this.LevelOffset = io.ReadUInt16();
                this.Shadow = io.ReadUInt16();
                this.NumAttributes = io.ReadUInt16();

                this.BHAV_Clean = io.ReadUInt16();
                this.BHAV_QueueSkipped = io.ReadUInt16();
                this.FrontDirection = io.ReadUInt16();
                this.BHAV_WallAdjacencyChanged = io.ReadUInt16();
                this.MyLeadObject = io.ReadUInt16();
                this.DynamicSpriteBaseId = io.ReadUInt16();
                this.NumDynamicSprites = io.ReadUInt16();

                if (this.NumAttributes == 0 && ObjectType != OBJDType.Portal)
                {
                    System.Diagnostics.Debug.WriteLine(GUID.ToString("x"));
                }
            }
        }
 public ObjectModule()
 {
     Globals = FileManager.Instance.GetIFF("globals.iff");
 }
Exemple #46
0
 /// <summary>
 /// Reads a BMP chunk from a stream.
 /// </summary>
 /// <param name="iff">An Iff instance.</param>
 /// <param name="stream">A Stream object holding a BMP chunk.</param>
 public override void Read(Iff iff, Stream stream)
 {
     data = new byte[stream.Length];
     stream.Read(data, 0, (int)stream.Length);
 }