Exemplo n.º 1
0
        /// <summary>
        /// Supply a game object who's tree table this VMEntity can use.
        /// See: TSO.Files.formats.iff.chunks.TTAB
        /// </summary>
        /// <param name="obj">GameObject instance with a tree table to use.</param>
        public void UseTreeTableOf(GameObject obj) //manually set the tree table for an object. Used for multitile objects, which inherit this from the master.
        {
            if (TreeTable != null)
            {
                return;
            }
            var        GLOBChunks = obj.Resource.List <GLOB>();
            GameGlobal SemiGlobal = null;

            if (GLOBChunks != null && GLOBChunks[0].Name != "")
            {
                SemiGlobal = FSO.Content.Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name);
            }

            TreeTable = obj.Resource.Get <TTAB>(obj.OBJ.TreeTableID);
            if (TreeTable != null)
            {
                TreeTableStrings = obj.Resource.Get <TTAs>(obj.OBJ.TreeTableID);
            }
            if (TreeTable == null && SemiGlobal != null)
            {
                TreeTable        = SemiGlobal.Resource.Get <TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal
                TreeTableStrings = SemiGlobal.Resource.Get <TTAs>(obj.OBJ.TreeTableID);
            }
        }
Exemplo n.º 2
0
        private void SetSelected(VMEntity entity, bool isPet)
        {
            interactionList = new List <string>();
            interactionList.Clear();
            if (entity.TreeTable != null && entity.TreeTableStrings != null)
            {
                TreeTableSelected = entity.TreeTable;

                if (isPet)
                {
                    foreach (var interaction in entity.TreeTable.Interactions)
                    {
                        if (interaction.Flags == TTABFlags.TS1AllowDogs || interaction.Flags == TTABFlags.TS1AllowCats)
                        {
                            interactionList.Add(entity.TreeTableStrings.GetString((int)interaction.TTAIndex));
                        }
                    }
                }

                else
                {
                    foreach (var interaction in entity.TreeTable.Interactions)
                    {
                        if (!interaction.Debug || !interaction.WhenDead || !interaction.Leapfrog ||
                            !interaction.AllowGhosts || !interaction.AllowCSRs || !interaction.AllowConsecutive ||
                            !interaction.AllowDogs || !interaction.AllowCats)
                        {
                            interactionList.Add(entity.TreeTableStrings.GetString((int)interaction.TTAIndex));
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void SetSelected(VMEntity entity)
        {
            SelectedEntity = entity;
            propertyGrid.SelectedObject = entity;

            bhavList.Items.Clear();
            var resource = entity.Object;
            var bhavs    = resource.Resource.List <BHAV>();

            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    bhavList.Items.Add(bhav);
                }
            }

            interactionList.Items.Clear();
            if (entity.TreeTable != null)
            {
                TreeTableSel = entity.TreeTable;
                foreach (var interaction in entity.TreeTable.Interactions)
                {
                    interactionList.Items.Add(entity.TreeTableStrings.GetString((int)interaction.TTAIndex));
                }
            }
        }
Exemplo n.º 4
0
        private void SetSelected(VMEntity entity, bool isPet)
        {
            interactionList = new List <string>();
            interactionList.Clear();
            if (entity.TreeTable != null)
            {
                TreeTableSelected = entity.TreeTable;

                if (isPet)
                {
                    foreach (var interaction in entity.TreeTable.Interactions)
                    {
                        if (interaction.Flags == TTABFlags.AllowDogs)
                        {
                            interactionList.Add(entity.TreeTableStrings.GetString((int)interaction.TTAIndex));
                        }
                    }
                }

                else
                {
                    foreach (var interaction in entity.TreeTable.Interactions)
                    {
                        if (!interaction.Debug)
                        {
                            interactionList.Add(entity.TreeTableStrings.GetString((int)interaction.TTAIndex));
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void UseSemiGlobalTTAB(string sgFile,ushort id)
        {
            GameGlobal obj = FSO.Content.Content.Get().WorldObjectGlobals.Get(sgFile);

            if (obj == null)
            {
                return;
            }

            TreeTable = obj.Resource.Get <TTAB>(id);
            if (TreeTable != null)
            {
                TreeTableStrings = obj.Resource.Get <TTAs>(id);
            }
        }
Exemplo n.º 6
0
        public void SetActiveResource(IffChunk chunk, GameIffResource res)
        {
            Resource   = res;
            Strings    = res.Get <TTAs>(chunk.ChunkID);
            ActiveTTAB = (TTAB)chunk;

            if (Strings == null)
            {
                //we have a problem... make us some strings!
                Strings                = new TTAs();
                Strings.ChunkLabel     = chunk.ChunkLabel;
                Strings.ChunkID        = chunk.ChunkID;
                Strings.ChunkProcessed = true;
                res.MainIff.AddChunk(Strings);
            }

            UpdateListing();
            UpdateSelection(-1);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Constructs a new VMEntity instance.
        /// </summary>
        /// <param name="obj">A GameObject instance.</param>
        public VMEntity(GameObject obj)
        {
            this.Object = obj;

            /**
             * For some reason, in the aquarium object (maybe others) the numAttributes is set to 0
             * but it should be 4. There are 4 entries in the label table. Go figure?
             */
            ObjectData   = new short[80];
            MeToObject   = new Dictionary <ushort,List <short> >();
            SoundThreads = new List <VMSoundEntry>();

            RTTI = new VMEntityRTTI();
            var numAttributes = obj.OBJ.NumAttributes;

            if (obj.OBJ.UsesFnTable == 0)
            {
                EntryPoints = GenerateFunctionTable(obj.OBJ);
            }
            else
            {
                var OBJfChunk = obj.Resource.Get <OBJf>(obj.OBJ.ChunkID); //objf has same id as objd
                if (OBJfChunk != null)
                {
                    EntryPoints = OBJfChunk.functions;
                }
            }

            if (obj.GUID == 0xa9bb3a76)
            {
                EntryPoints[17] = new OBJfFunctionEntry();
            }

            var test = obj.Resource.List <OBJf>();

            SemiGlobal = obj.Resource.SemiGlobal;

            Slots = obj.Resource.Get <SLOT>(obj.OBJ.SlotID); //containment slots are dealt with in the avatar and object classes respectively.

            var attributeTable = obj.Resource.Get <STR>(256);

            if (attributeTable != null)
            {
                numAttributes        = (ushort)Math.Max(numAttributes,attributeTable.Length);
                RTTI.AttributeLabels = new string[numAttributes];
                for (var i = 0; i < numAttributes; i++)
                {
                    RTTI.AttributeLabels[i] = attributeTable.GetString(i);
                }
            }

            TreeTable = obj.Resource.Get <TTAB>(obj.OBJ.TreeTableID);
            if (TreeTable != null)
            {
                TreeTableStrings = obj.Resource.Get <TTAs>(obj.OBJ.TreeTableID);
            }
            if (TreeTable == null && SemiGlobal != null)
            {
                TreeTable        = SemiGlobal.Get <TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal
                TreeTableStrings = SemiGlobal.Get <TTAs>(obj.OBJ.TreeTableID);
            }
            //no you cannot get global tree tables don't even ask

            this.Attributes = new List <short>(numAttributes);
            SetFlag(VMEntityFlags.ChairFacing,true);
        }
Exemplo n.º 8
0
        public VMEntity(GameObject obj)
        {
            this.Object = obj;

            /**
             * For some reason, in the aquarium object (maybe others) the numAttributes is set to 0
             * but it should be 4. There are 4 entries in the label table. Go figure?
             */
            ObjectData = new short[80];

            RTTI = new VMEntityRTTI();
            var numAttributes = obj.OBJ.NumAttributes;

            if (obj.OBJ.UsesInTable == 0)
            {
                EntryPoints = GenerateFunctionTable(obj.OBJ);
            }
            else
            {
                var OBJfChunks = obj.Resource.List <OBJf>();
                if (OBJfChunks != null)
                {
                    EntryPoints = OBJfChunks[0].functions;
                }
            }

            var GLOBChunks = obj.Resource.List <GLOB>();

            if (GLOBChunks != null)
            {
                SemiGlobal = Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name);
            }

            var attributeTable = obj.Resource.Get <STR>(256);

            if (attributeTable != null)
            {
                numAttributes        = (ushort)Math.Max(numAttributes, attributeTable.Length);
                RTTI.AttributeLabels = new string[numAttributes];
                for (var i = 0; i < numAttributes; i++)
                {
                    RTTI.AttributeLabels[i] = attributeTable.GetString(i);
                }
            }

            TreeTable = obj.Resource.Get <TTAB>(obj.OBJ.TreeTableID);
            if (TreeTable != null)
            {
                TreeTableStrings = obj.Resource.Get <TTAs>(obj.OBJ.TreeTableID);
            }
            if (TreeTable == null && SemiGlobal != null)
            {
                TreeTable        = SemiGlobal.Resource.Get <TTAB>(obj.OBJ.TreeTableID); //tree not in local, try semiglobal
                TreeTableStrings = SemiGlobal.Resource.Get <TTAs>(obj.OBJ.TreeTableID);
            }
            //no you cannot get global tree tables don't even ask

            this.Attributes = new short[numAttributes];
            if (obj.OBJ.GUID == 0x98E0F8BD)
            {
                this.Attributes[0] = 2;
            }
        }