88
99namespace ResoniteFish ;
1010public class ResoniteFish : ResoniteMod {
11- internal const string VERSION_CONSTANT = "1.0 .0" ;
11+ internal const string VERSION_CONSTANT = "1.1 .0" ;
1212 public override string Name => "Fish" ;
13- public override string Author => "Delta" ;
13+ public override string Author => "Delta & Raidriar " ;
1414 public override string Version => VERSION_CONSTANT ;
1515 public override string Link => "https://github.com/XDelta/ResoniteFish" ;
16+ public static ModConfiguration ? Config ;
17+
18+ [ AutoRegisterConfigKey ] public static readonly ModConfigurationKey < bool > FishSound =
19+ new ModConfigurationKey < bool > ( "FishSound" , "Enable Sounds" , ( ) => false ) ;
1620
1721 public override void OnEngineInit ( ) {
1822 Harmony harmony = new ( "net.deltawolf.Fish" ) ;
1923 harmony . PatchAll ( ) ;
24+ Config = GetConfiguration ( ) ! ;
25+ Config ! . Save ( true ) ;
2026 }
2127
2228 [ HarmonyPatch ( typeof ( InteractionHandler ) , "OpenContextMenu" ) ]
2329 private class ContextMenuOpenMenuAPatch {
2430 public static void Postfix ( InteractionHandler __instance , InteractionHandler . MenuOptions options ) {
2531 ContextMenu ctx = __instance . ContextMenu ;
2632 if ( options == InteractionHandler . MenuOptions . Default ) {
27- ctx . AddItem ( "Fish" , new Uri ( "resdb:///5a56714e4cc021888cb51162cc34b55a7a1333fe8bc162c8be906f9345206b3c.png" ) , colorX . Cyan ) ;
33+ var Button = ctx . AddItem ( "Fish" , new Uri ( "resdb:///5a56714e4cc021888cb51162cc34b55a7a1333fe8bc162c8be906f9345206b3c.png" ) , colorX . Cyan ) ;
34+
35+ if ( Config ! . GetValue ( FishSound ) == true ) {
36+ var MenuSlot = Button . Slot ;
37+
38+ var StaticAudio = MenuSlot . AttachComponent < StaticAudioClip > ( ) ;
39+ StaticAudio . URL . Value = new Uri ( "resdb:///1ed74a85e7d9a8e2456fadbd276cb9dd223ad96377ad230409693d408524606e.wav" ) ;
40+
41+ var ClipPlayer = MenuSlot . AttachComponent < RandomAudioClipPlayer > ( ) ;
42+ ClipPlayer . Clips . Add ( ) ;
43+ ClipPlayer . Clips . GetElement ( 0 ) . Clip . Target = StaticAudio ;
44+
45+ var Trigger = MenuSlot . AttachComponent < ButtonActionTrigger > ( ) ;
46+ Trigger . OnPressed . Target = ClipPlayer . Play ;
47+ }
2848 }
2949 }
3050 }
31- }
51+ }
0 commit comments