feat: implement audio object definitions and refactor audio system

- Add AudioObjectDefinitions.cs with name-to-ID mappings and ambiguity detection
- Update AudioSystem.cs to support Play(uint) and deprecated Play(string) with warnings
- Rename PitchStepManager to PitchStepResolver and update all references
- Refactor generated code to use 'this.' prefix and foreach loops
- Remove TestEnum from audio enums and IDs
- Update SampleScene.unity to use new AudioSystem namespace and rain sound parameter
- Optimize binary serialization in generated audio classes
This commit is contained in:
2026-04-02 14:31:46 +08:00
parent d824d65549
commit 7fc3282e80
18 changed files with 208 additions and 32 deletions
@@ -58,7 +58,7 @@ public partial class AmbiencePathConfig : IBinarySerializable
public List<AmbiencePath> AmbiencePathList()
{
this.m_ambiencePathInfoList ??= new List<AmbiencePath>(m_ambiencePathInfos.Values);
this.m_ambiencePathInfoList ??= new List<AmbiencePath>(this.m_ambiencePathInfos.Values);
return this.m_ambiencePathInfoList;
}
@@ -65,7 +65,7 @@ public partial class AmbienceTransitionConfig : IBinarySerializable
public List<AmbienceTransition> AmbienceTransitionList()
{
this.m_ambienceTransitionInfoList ??= new List<AmbienceTransition>(m_ambienceTransitionInfos.Values);
this.m_ambienceTransitionInfoList ??= new List<AmbienceTransition>(this.m_ambienceTransitionInfos.Values);
return this.m_ambienceTransitionInfoList;
}
@@ -9,12 +9,9 @@ namespace OCES.Audio
{
public const uint GameState = 1;
public const uint TestEnum = 2;
public static void RegisterAllGameState()
{
StateGroupRegistry.Register<GameState>(1);
StateGroupRegistry.Register<TestEnum>(2);
}
}
}
@@ -15,10 +15,4 @@ namespace OCES.Audio
Bass = 6, // 测试用值
}
public enum TestEnum
{
Holiday = -1,
Regular = 5,
}
}
@@ -60,7 +60,7 @@ public partial class AudioGroupConfig : IBinarySerializable
public List<AudioGroup> AudioGroupList()
{
this.m_audioGroupInfoList ??= new List<AudioGroup>(m_audioGroupInfos.Values);
this.m_audioGroupInfoList ??= new List<AudioGroup>(this.m_audioGroupInfos.Values);
return this.m_audioGroupInfoList;
}
@@ -178,9 +178,9 @@ public partial class AudioObject : IBinarySerializable
else
{
writer.Write(Name.Count);
for (int i = 0; i < Name.Count; i++)
foreach (var t in Name)
{
writer.Write(Name[i]);
writer.Write(t);
}
}
writer.Write(Comment);
@@ -213,7 +213,7 @@ public partial class AudioObjectConfig : IBinarySerializable
public List<AudioObject> AudioObjectList()
{
this.m_audioObjectInfoList ??= new List<AudioObject>(m_audioObjectInfos.Values);
this.m_audioObjectInfoList ??= new List<AudioObject>(this.m_audioObjectInfos.Values);
return this.m_audioObjectInfoList;
}
@@ -0,0 +1,145 @@
/* auto generated, do not modify */
using System.Collections.Generic;
namespace OCES.Audio
{
public static class AudioObjectDefinitions
{
public static readonly Dictionary<string, uint> NameToId = new()
{
{ "AnimCollision", 1 },
{ "AnimToWeapon", 2 },
{ "ArrowFire", 3 },
{ "BoxBeSelected", 4 },
{ "BoxCollision", 5 },
{ "BoxMove", 6 },
{ "BoxTouch", 7 },
{ "BoxToWeapon", 8 },
{ "ChangeColor", 9 },
{ "ClickButton", 10 },
{ "CoinFly", 11 },
{ "DamageByArrow", 12 },
{ "DamageByBullet", 13 },
{ "DamageByCannonBall", 14 },
{ "Defeat", 15 },
{ "DestroyBox", 16 },
{ "DevilAttackShield", 17 },
{ "DevilBeHit_01", 18 },
{ "DevilBeHit_02", 18 },
{ "DevilBeHit_03", 18 },
{ "DevilDie", 19 },
{ "DevilFire", 20 },
{ "DevilResurrection", 21 },
{ "DragonAttackShield", 22 },
{ "DragonBeHit", 23 },
{ "DragonDie", 24 },
{ "DragonFire", 25 },
{ "DragonResurrection", 26 },
{ "GhostAttackShield", 27 },
{ "GhostBeHit", 28 },
{ "GhostDie", 29 },
{ "GhostFire", 30 },
{ "GhostResurrection", 31 },
{ "GunFire", 32 },
{ "HorseMove", 33 },
{ "LevelBegins", 34 },
{ "PrincessDown", 35 },
{ "PrincessFear", 36 },
{ "ShieldBroken", 37 },
{ "ShieldUnderAttack", 38 },
{ "Spin", 39 },
{ "TigerMove", 40 },
{ "UnlockProp", 41 },
{ "UnlockTurret", 42 },
{ "Victory", 43 },
{ "WeaponExhausted", 44 },
{ "WeaponFire", 45 },
{ "au_stream", 46 },
{ "rain", 46 },
{ "Chinese Number 01", 48 },
{ "Chinese Number 02", 48 },
{ "Chinese Number 03", 48 },
{ "Chinese Number 04", 48 },
{ "Chinese Number 05", 48 },
{ "Chinese Number 06", 49 },
{ "Chinese Number 07", 49 },
{ "Chinese Number 08", 49 },
{ "Chinese Number 09", 49 },
{ "Chinese Number 10", 49 },
{ "sfx_amb_desert", 2000 },
{ "sfx_amb_forest", 2001 },
{ "sfx_anim_common_item_fly", 3000 },
{ "sfx_anim_corePlay_character_footstep_grass", 3001 },
{ "sfx_anim_corePlay_character_footstep_sand", 3002 },
{ "sfx_anim_corePlay_character_footstep_stone", 3003 },
{ "sfx_anim_corePlay_fireBall", 3004 },
{ "sfx_anim_corePlay_freeze", 3005 },
{ "sfx_anim_corePlay_getIn_devil", 3006 },
{ "sfx_anim_corePlay_getIn_dragon", 3007 },
{ "sfx_anim_corePlay_getIn_ghost", 3008 },
{ "sfx_anim_corePlay_newBoxFromStorage", 3009 },
{ "sfx_anim_corePlay_shield_broke_wood", 3010 },
{ "sfx_anim_corePlay_shield_broke_crystal", 3011 },
{ "sfx_anim_corePlay_shield_broke_eggRoll", 3012 },
{ "sfx_anim_corePlay_shield_show_crystal", 3013 },
{ "sfx_anim_corePlay_shield_show_eggRoll", 3014 },
{ "sfx_anim_corePlay_shield_show_wood", 3015 },
{ "sfx_anim_corePlay_shield_underAttack_wood", 3016 },
{ "sfx_anim_corePlay_shield_underAttack_crystal", 3017 },
{ "sfx_anim_corePlay_shield_underAttack_eggRoll", 3018 },
{ "sfx_anim_corePlay_slow", 3019 },
{ "sfx_anim_corePlay_speedUp", 3020 },
{ "sfx_anim_corePlay_useProp_", 3021 },
{ "sfx_anim_cutScene_in", 3022 },
{ "sfx_anim_cutScene_out", 3023 },
{ "sfx_notice_common_negative", 4000 },
{ "sfx_notice_corePlay_losing", 4001 },
{ "sfx_notice_corePlay_restart", 4002 },
{ "sfx_notice_corePlay_warning", 4003 },
{ "sfx_notice_guide", 4004 },
{ "sfx_notice_spinWheel_click", 4005 },
{ "sfx_notice_spinWheel_getReward", 4006 },
{ "sfx_notice_corePlay_levelStart_hard", 4007 },
{ "sfx_ui_labelSwitch_home", 5000 },
{ "sfx_ui_panel_common_close", 5001 },
{ "sfx_ui_panel_common_open", 5002 },
{ "sfx_ui_panel_continue_open", 5003 },
{ "sfx_ui_panel_corePlay_guide_open", 5004 },
{ "sfx_ui_panel_initPack_open", 5005 },
{ "sfx_ui_panel_piggyBank_close", 5006 },
{ "sfx_ui_panel_piggyBank_open", 5007 },
{ "sfx_ui_panel_removeAds_open", 5008 },
{ "0", 5009 },
{ "sfx_ui_panel_summerPack_open", 5010 },
{ "sfx_ui_panel_unlockItem_open", 5011 },
{ "voice_princess_fear", 9000 },
};
public static readonly HashSet<string> AmbiguousNames = new()
{
"DevilBeHit_01",
"DevilBeHit_02",
"DevilBeHit_03",
"Chinese Number 01",
};
public static readonly HashSet<string> SharedIdNames = new()
{
"DevilBeHit_01",
"DevilBeHit_02",
"DevilBeHit_03",
"au_stream",
"rain",
"Chinese Number 01",
"Chinese Number 02",
"Chinese Number 03",
"Chinese Number 04",
"Chinese Number 05",
"Chinese Number 06",
"Chinese Number 07",
"Chinese Number 08",
"Chinese Number 09",
"Chinese Number 10",
};
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 524b2a6c9b0c412a8979b5a28b1247b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -94,9 +94,9 @@ public partial class MusicContainer : IBinarySerializable
else
{
writer.Write(Segments.Count);
for (int i = 0; i < Segments.Count; i++)
foreach (var t in Segments)
{
writer.Write(Segments[i]);
writer.Write(t);
}
}
writer.Write((byte)ContainerType);
@@ -116,7 +116,7 @@ public partial class MusicContainerConfig : IBinarySerializable
public List<MusicContainer> MusicContainerList()
{
this.m_musicContainerInfoList ??= new List<MusicContainer>(m_musicContainerInfos.Values);
this.m_musicContainerInfoList ??= new List<MusicContainer>(this.m_musicContainerInfos.Values);
return this.m_musicContainerInfoList;
}
@@ -58,7 +58,7 @@ public partial class MusicPathConfig : IBinarySerializable
public List<MusicPath> MusicPathList()
{
this.m_musicPathInfoList ??= new List<MusicPath>(m_musicPathInfos.Values);
this.m_musicPathInfoList ??= new List<MusicPath>(this.m_musicPathInfos.Values);
return this.m_musicPathInfoList;
}
@@ -44,7 +44,7 @@ public partial class MusicSegmentConfig : IBinarySerializable
public List<MusicSegment> MusicSegmentList()
{
this.m_musicSegmentInfoList ??= new List<MusicSegment>(m_musicSegmentInfos.Values);
this.m_musicSegmentInfoList ??= new List<MusicSegment>(this.m_musicSegmentInfos.Values);
return this.m_musicSegmentInfoList;
}
@@ -81,7 +81,7 @@ public partial class MusicTransitionConfig : IBinarySerializable
public List<MusicTransition> MusicTransitionList()
{
this.m_musicTransitionInfoList ??= new List<MusicTransition>(m_musicTransitionInfos.Values);
this.m_musicTransitionInfoList ??= new List<MusicTransition>(this.m_musicTransitionInfos.Values);
return this.m_musicTransitionInfoList;
}