/// <summary> /// Looks up the records for the given id /// </summary> /// <param name="id">The id of the file, event, etc</param> /// <returns>null if no information, otherwise, the record</returns> object InfoFor(uint id) { // First, map the id to a string, if possible object objId; var name = AudioAssets.StringForID(id); if (null != name) { objId = name.ToUpper(); } else { objId = id; } // Try looking up the record objectId2Info.TryGetValue(objId, out var ret); return(ret); }
/// <summary> /// Add information about an id /// </summary> /// <param name="id">The internal 32-bit id form for events, sounds, etc.</param> /// <param name="info">Arbitrary extra information associated with the </param> void Add(uint id, object info) { // First, map the id to a string, if possible object objId; var name = AudioAssets.StringForID(id); if (null != name) { objId = name.ToUpper(); } else { objId = id; } // First, check that there is not already an ojbect in there with this // information if (objectId2Info.TryGetValue(objId, out _)) { throw new System.Exception("dang, there should not be two."); } objectId2Info[objId] = info; }
/// <summary> /// This reads a event to event action mapping /// </summary> /// <param name="eventId">the ID of the event that maps to an action</param> void ReadHIRCEvent(uint eventId, long endPos) { // Create a record so that we can look it up later var eventActions = new List <uint>(); // Fetch each of event actions var numObjects = binaryReader.ReadUInt32(); for (var idx = 0; idx < numObjects; idx++) { // Sanity check, since there is some weirdness with some files if (binaryReader.BaseStream.Position + 4 > endPos) { break; } // Append the event action id to the list // Note: I don't know how this action id is created, it doesn't seem // to be in the various metadata text fieles eventActions.Add(binaryReader.ReadUInt32()); } // Look up the record var info = (EventInfo)InfoFor(eventId); if (null != info) { info.EventActions = eventActions; } else { // map the id to this info var eventName = AudioAssets.StringForID(eventId); Add(eventId, new EventInfo { SoundBankName = soundBankName, Name = eventName ?? (object)eventId, EventActions = eventActions }); } }
/// <summary> /// This reads a event to event action mapping /// </summary> /// <param name="eventId">the ID of the event that maps to an action</param> /// <remarks> /// The action Ids refer to objects created in the Event Action /// </remarks> void ReadHIRCEvent(uint eventId, long endPos) { // Create a record so that we can look it up later var eventActions = new List <uint>(); // Fetch each of event actions // Note: this is a byte, not a uint32 as reported elsewhere var numObjects = binaryReader.ReadByte(); for (var idx = 0; idx < numObjects; idx++) { // Sanity check, since there is some weirdness with some files if (binaryReader.BaseStream.Position + 4 > endPos) { break; } // Append the event action id to the list eventActions.Add(binaryReader.ReadUInt32()); } // Look up the record var info = (EventInfo)InfoFor(eventId); if (null != info) { info.EventActionIds = eventActions; } else { // map the id to this info var eventName = AudioAssets.StringForID(eventId); Add(eventId, new EventInfo { SoundBank = this, Name = eventName ?? (object)eventId, EventActionIds = eventActions }); } }