Exemple #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);
            }
        }
Exemple #2
0
        private void openExternalIffToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Title = "Select an iff file. (iff)";
            SaveFile(dialog);
            try
            {
                var iff = new IffFile(dialog.FileName);
                iff.TSBO = true;
                var obj = new GameObject();
                obj.OBJ  = iff.List <OBJD>()?.FirstOrDefault() ?? new OBJD();
                obj.GUID = obj.OBJ.GUID;

                //var res = new GameObjectResource(iff, null, null, "what", Content.Content.Get());
                var res  = new GameObjectResource(iff, null, null, "what", Content.Content.Get());
                var res2 = new GameGlobalResource(iff, null);
                obj.Resource = res;

                IffManager.OpenResourceWindow(res2, obj);
            }
            catch
            {
            }
        }
Exemple #3
0
 public Task <RoslynSimanticsModule> GetSemiglobal(GameGlobalResource res)
 {
     lock (Semiglobals)
     {
         Task <RoslynSimanticsModule> result;
         if (!Semiglobals.TryGetValue(res.MainIff.Filename, out result))
         {
             // need to load it.
             Semiglobals[res.MainIff.Filename] = LoadModule(res);
         }
         return(result);
     }
 }
Exemple #4
0
        public EditorScope(GameObject obj, BHAV active)
        {
            Object = obj;
            var GLOBChunks = Object.Resource.List <GLOB>();

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

            AttributeTable = obj.Resource.Get <STR>(256);
            StackObject    = obj;
            CallerObject   = obj;

            BHAVNames = GetLabels(active.ChunkID);
            Active    = active;
        }
        public EditorScope(GameObject obj, BHAV active)
        {
            Object = obj;
            var GLOBChunks = Object?.Resource.List <GLOB>();

            if (GLOBChunks != null)
            {
                SemiGlobalName = GLOBChunks[0].Name;
                try
                {
                    SemiGlobal = FSO.Content.Content.Get().WorldObjectGlobals.Get(SemiGlobalName).Resource;
                }
                catch
                {
                    //failed to load semiglobal!
                }
            }

            AttributeTable = obj.Resource.Get <STR>(256);
            StackObject    = obj;
            CallerObject   = obj;

            ActiveTree = active.ChunkParent.Get <TREE>(active.ChunkID);
            if (ActiveTree == null)
            {
                ActiveTree = active.RuntimeTree;
            }
            if (ActiveTree == null)
            {
                ActiveTree = TREE.GenerateEmpty(active);
                //remember this tree as the user might start more than one window with it, and they need to be kept in sync
                //don't add to the iff unless a change is made.
                active.RuntimeTree = ActiveTree;
            }
            else
            {
                ActiveTree.CorrectConnections(active);
            }
            BHAVNames = GetLabels(active.ChunkID);
            Active    = active;
        }
Exemple #6
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);
        }
Exemple #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);
        }
Exemple #8
0
        //manually set the tree table for an object. Used for multitile objects, which inherit this from the master.
        /// <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)
        {
            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);
            }
        }