using UnityEngine; public partial class AkWwiseProjectData : UnityEngine.ScriptableObject { public System.Collections.Generic.List AcousticTextureWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List AuxBusWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List BankWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List EventWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List RtpcWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List StateWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List SwitchWwu = new System.Collections.Generic.List(); public System.Collections.Generic.List TriggerWwu = new System.Collections.Generic.List(); ////Contains the int id of all items that are expanded in the Wwise picker public System.Collections.Generic.List ExpandedFileSystemItemIds = new System.Collections.Generic.List(); public System.Collections.Generic.List ExpandedWaapiItemIds = new System.Collections.Generic.List(); public bool AutoSyncSelection; public bool autoPopulateEnabled = true; public AkWwiseProjectInfo.DataSourceType currentDataSource; public string CurrentPluginConfig; public System.Collections.ArrayList GetWwuListByString(string in_wwuType) { if (string.Equals(in_wwuType, "Events", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(EventWwu); if (string.Equals(in_wwuType, "States", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(StateWwu); if (string.Equals(in_wwuType, "Switches", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(SwitchWwu); if (string.Equals(in_wwuType, "Master-Mixer Hierarchy", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(AuxBusWwu); if (string.Equals(in_wwuType, "SoundBanks", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(BankWwu); if (string.Equals(in_wwuType, "Game Parameters", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(RtpcWwu); if (string.Equals(in_wwuType, "Triggers", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(TriggerWwu); if (string.Equals(in_wwuType, "Virtual Acoustics", System.StringComparison.OrdinalIgnoreCase)) return System.Collections.ArrayList.Adapter(AcousticTextureWwu); return null; } public float GetEventMaxAttenuation(uint eventID) { var Event = GetEventInfo(eventID); return Event != null ? Event.maxAttenuation : 0.0f; } public Event GetEventInfo(uint eventID) { foreach (var wwu in EventWwu) { foreach (var entry in wwu.List) { if (entry.Id == eventID) { return entry; } } } return null; } public void Reset() { EventWwu = new System.Collections.Generic.List(); StateWwu = new System.Collections.Generic.List(); SwitchWwu = new System.Collections.Generic.List(); BankWwu = new System.Collections.Generic.List(); AuxBusWwu = new System.Collections.Generic.List(); RtpcWwu = new System.Collections.Generic.List(); TriggerWwu = new System.Collections.Generic.List(); AcousticTextureWwu = new System.Collections.Generic.List(); } public void Migrate() { foreach (var wwu in EventWwu) wwu.Migrate(); foreach (var wwu in StateWwu) wwu.Migrate(); foreach (var wwu in SwitchWwu) wwu.Migrate(); foreach (var wwu in BankWwu) wwu.Migrate(); foreach (var wwu in AuxBusWwu) wwu.Migrate(); foreach (var wwu in RtpcWwu) wwu.Migrate(); foreach (var wwu in TriggerWwu) wwu.Migrate(); foreach (var wwu in AcousticTextureWwu) wwu.Migrate(); UnityEditor.EditorUtility.SetDirty(this); } [System.Serializable] public class ByteArrayWrapper { public byte[] bytes; public ByteArrayWrapper(byte[] byteArray) { bytes = byteArray; } public static implicit operator ByteArrayWrapper(System.Guid guid) => new ByteArrayWrapper(guid.ToByteArray()); public static implicit operator System.Guid(ByteArrayWrapper bytes) => new System.Guid(bytes.bytes); } private static System.Guid GetGuid(byte[] bytes) { try { return new System.Guid(bytes); } catch { return System.Guid.Empty; } } [System.Serializable] public class AkBaseInformation : System.IComparable { [UnityEngine.SerializeField] [UnityEngine.Serialization.FormerlySerializedAs("Name")] private string name; public string Name { get { return name; } set { name = value; id = AkUtilities.ShortIDGenerator.Compute(value); } } [UnityEngine.HideInInspector] [UnityEngine.SerializeField] [UnityEngine.Serialization.FormerlySerializedAs("Guid")] private byte[] guid = null; public System.Guid Guid { get { return GetGuid(guid); } set { guid = value.ToByteArray(); } } [UnityEngine.SerializeField] [UnityEngine.Serialization.FormerlySerializedAs("ID")] private uint id; public uint Id { get { return id; } } [UnityEngine.HideInInspector] public System.Collections.Generic.List PathAndIcons = new System.Collections.Generic.List(); int System.IComparable.CompareTo(object other) { if (other == null) return 1; var otherAkInformation = other as AkBaseInformation; if (otherAkInformation == null) throw new System.ArgumentException("Object is not of type AkBaseInformation"); return Name.CompareTo(otherAkInformation.Name); } private class _CompareByGuid : System.Collections.Generic.IComparer { int System.Collections.Generic.IComparer.Compare(AkBaseInformation a, AkBaseInformation b) { if (a == null) return b == null ? 0 : -1; return a.Guid.CompareTo(b.Guid); } } public static System.Collections.Generic.IComparer CompareByGuid = new _CompareByGuid(); } [System.Serializable] public class AkInformation : AkBaseInformation { public string Path; } [System.Serializable] public class GroupValue : AkInformation { public System.Collections.Generic.List values = new System.Collections.Generic.List(); [UnityEngine.HideInInspector] [UnityEngine.SerializeField] private System.Collections.Generic.List ValueGuids = new System.Collections.Generic.List(); [UnityEngine.HideInInspector] [UnityEngine.SerializeField] private System.Collections.Generic.List ValueIcons = new System.Collections.Generic.List(); [UnityEngine.HideInInspector] [UnityEngine.SerializeField] [UnityEngine.Serialization.FormerlySerializedAs("values")] private System.Collections.Generic.List valuesInternal = new System.Collections.Generic.List(); public void Migrate() { var count = ValueGuids.Count; if (count < 1 || count != ValueIcons.Count || count != valuesInternal.Count) return; values.Clear(); for (var i = 0; i < count; ++i) { var value = new AkBaseInformation { Name = valuesInternal[i], Guid = GetGuid(ValueGuids[i].bytes) }; value.PathAndIcons.Add(ValueIcons[i]); values.Add(value); } } } [System.Serializable] public class Event : AkInformation { public float maxAttenuation; public float maxDuration = -1; public float minDuration = -1; } [System.Serializable] public class WorkUnit : System.IComparable { public string PhysicalPath; [UnityEngine.HideInInspector] public System.Collections.Generic.List PathAndIcons = new System.Collections.Generic.List(); [UnityEngine.Serialization.FormerlySerializedAs("ParentPhysicalPath")] public string ParentPath; [UnityEngine.HideInInspector] [UnityEngine.SerializeField] private byte[] guid = null; [UnityEngine.HideInInspector] [UnityEngine.SerializeField] [UnityEngine.Serialization.FormerlySerializedAs("Guid")] private string GuidInternal = string.Empty; public System.Guid Guid { get { return GetGuid(guid); } set { guid = value.ToByteArray(); } } [UnityEngine.HideInInspector] [UnityEngine.SerializeField] private long m_lastTime; public System.DateTime LastTime { get { return m_lastTime == 0 ? System.DateTime.MinValue : System.DateTime.FromBinary(m_lastTime); } set { m_lastTime = value.ToBinary(); } } public virtual void Migrate() { try { Guid = new System.Guid(GuidInternal); } catch { Guid = System.Guid.Empty; } } int System.IComparable.CompareTo(object other) { if (other == null) return 1; var otherWwu = other as WorkUnit; if (otherWwu == null) throw new System.ArgumentException("Object is not a WorkUnit"); return PhysicalPath.CompareTo(otherWwu.PhysicalPath); } public virtual System.Collections.ArrayList GetChildrenArrayList() { return null; } } [System.Serializable] public class GenericWorkUnit : WorkUnit where T : AkInformation { public System.Collections.Generic.List List = new System.Collections.Generic.List(); public T Find(string name) { foreach (var item in List) if (item.Name == name) return item; return null; } public override System.Collections.ArrayList GetChildrenArrayList() { return System.Collections.ArrayList.Adapter(List); } } [System.Serializable] public class AkInfoWorkUnit : GenericWorkUnit { } [System.Serializable] public class EventWorkUnit : GenericWorkUnit { } [System.Serializable] public class GroupValWorkUnit : GenericWorkUnit { public override void Migrate() { base.Migrate(); foreach (var item in List) item.Migrate(); } } [System.Serializable] public class PathElement { public string ElementName; public WwiseObjectType ObjectType; [UnityEngine.SerializeField] [UnityEngine.HideInInspector] private byte[] guid = null; public System.Guid ObjectGuid { get { return GetGuid(guid); } set { guid = value.ToByteArray(); } } public PathElement(string Name, WwiseObjectType objType, System.Guid guid) { ElementName = Name; ObjectType = objType; ObjectGuid = guid; } public static string GetProjectPathString(System.Collections.Generic.List pathElements, int index) { string path = ""; for (int i = 0; i<=index && i < pathElements.Count; i++) { path += $"/{pathElements[i].ElementName}"; } return path; } } }