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); } } if (entity.SemiGlobal != null) { var sglobbhavs = entity.SemiGlobal.Resource.List<BHAV>(); if (bhavs != null) { foreach (var bhav in sglobbhavs) { 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)); } } }
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); }
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); }
//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) 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); } }
/// <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>(); var GLOBChunks = obj.Resource.List<GLOB>(); if (GLOBChunks != null) { SemiGlobal = FSO.Content.Content.Get().WorldObjectGlobals.Get(GLOBChunks[0].Name); Object.Resource.SemiGlobal = SemiGlobal.Resource; //used for tuning constant fetching. } 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.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]; SetFlag(VMEntityFlags.ChairFacing, true); }