예제 #1
0
        public GameObjectResource(IffFile iff, IffFile sprites, OTFFile tuning, string iname)
        {
            this.Iff     = iff;
            this.Sprites = sprites;
            this.Tuning  = tuning;
            this.Name    = iname;

            if (iff == null)
            {
                return;
            }
            var GLOBChunks = iff.List <GLOB>();

            if (GLOBChunks != null && GLOBChunks[0].Name != "")
            {
                var sg = FSO.Content.Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name);
                if (sg != null)
                {
                    SemiGlobal = sg.Resource;             //used for tuning constant fetching.
                }
            }

            TreeByName = new Dictionary <string, VMTreeByNameTableEntry>();
            var bhavs = List <BHAV>();

            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    string name = bhav.ChunkLabel;
                    for (var i = 0; i < name.Length; i++)
                    {
                        if (name[i] == 0)
                        {
                            name = name.Substring(0, i);
                            break;
                        }
                    }
                    if (!TreeByName.ContainsKey(name))
                    {
                        TreeByName.Add(name, new VMTreeByNameTableEntry(bhav));
                    }
                }
            }
            //also add semiglobals

            if (SemiGlobal != null)
            {
                bhavs = SemiGlobal.List <BHAV>();
                if (bhavs != null)
                {
                    foreach (var bhav in bhavs)
                    {
                        string name = bhav.ChunkLabel;
                        for (var i = 0; i < name.Length; i++)
                        {
                            if (name[i] == 0)
                            {
                                name = name.Substring(0, i);
                                break;
                            }
                        }
                        if (!TreeByName.ContainsKey(name))
                        {
                            TreeByName.Add(name, new VMTreeByNameTableEntry(bhav));
                        }
                    }
                }
            }
        }
예제 #2
0
        public override void Recache()
        {
            base.Recache();
            TreeByName = new Dictionary <string, VMTreeByNameTableEntry>();
            var bhavs = List <BHAV>();

            if (bhavs != null)
            {
                foreach (var bhav in bhavs)
                {
                    string name = bhav.ChunkLabel;
                    for (var i = 0; i < name.Length; i++)
                    {
                        if (name[i] == 0)
                        {
                            name = name.Substring(0, i);
                            break;
                        }
                    }
                    if (!TreeByName.ContainsKey(name))
                    {
                        TreeByName.Add(name, new VMTreeByNameTableEntry(GetRoutine(bhav.ChunkID)));
                    }
                }
            }
            //also add semiglobals

            if (SemiGlobal != null)
            {
                bhavs = SemiGlobal.List <BHAV>();
                if (bhavs != null)
                {
                    foreach (var bhav in bhavs)
                    {
                        string name = bhav.ChunkLabel;
                        for (var i = 0; i < name.Length; i++)
                        {
                            if (name[i] == 0)
                            {
                                name = name.Substring(0, i);
                                break;
                            }
                        }
                        if (!TreeByName.ContainsKey(name))
                        {
                            TreeByName.Add(name, new VMTreeByNameTableEntry(SemiGlobal.GetRoutine(bhav.ChunkID)));
                        }
                    }
                }
            }

            if (Tuning != null)
            {
                foreach (var table in Tuning.Tables)
                {
                    if (table == null)
                    {
                        continue;
                    }
                    foreach (var item in table.Keys)
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        TuningCache[((uint)table.ID << 16) | (uint)(item.ID)] = (short)item.Value;
                    }
                }
            }
        }