Skip to content

Commit 1bc2423

Browse files
committed
Use AttachAudioClip
1 parent 341b9d5 commit 1bc2423

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

ResoniteFish/ResoniteFish.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
21
using System;
3-
42
using Elements.Core;
53
using FrooxEngine;
64
using HarmonyLib;
@@ -13,39 +11,38 @@ public class ResoniteFish : ResoniteMod {
1311
public override string Author => "Delta & Raidriar";
1412
public override string Version => VERSION_CONSTANT;
1513
public override string Link => "https://github.com/XDelta/ResoniteFish";
16-
public static ModConfiguration? Config;
1714

18-
[AutoRegisterConfigKey] public static readonly ModConfigurationKey<bool> FishSound =
19-
new ModConfigurationKey<bool>("FishSound", "Enable Sounds", () => false);
15+
[AutoRegisterConfigKey]
16+
public static readonly ModConfigurationKey<bool> FishSound = new("FishSound", "Enable Sounds", () => false);
17+
18+
public static ModConfiguration? Config;
2019

2120
public override void OnEngineInit() {
2221
Harmony harmony = new("net.deltawolf.Fish");
2322
harmony.PatchAll();
2423
Config = GetConfiguration()!;
25-
Config!.Save(true);
24+
Config!.Save(true);
2625
}
2726

2827
[HarmonyPatch(typeof(InteractionHandler), "OpenContextMenu")]
29-
private class ContextMenuOpenMenuAPatch {
28+
private class ContextMenuOpenMenuPatch {
3029
public static void Postfix(InteractionHandler __instance, InteractionHandler.MenuOptions options) {
3130
ContextMenu ctx = __instance.ContextMenu;
3231
if (options == InteractionHandler.MenuOptions.Default) {
33-
var Button = ctx.AddItem("Fish", new Uri("resdb:///5a56714e4cc021888cb51162cc34b55a7a1333fe8bc162c8be906f9345206b3c.png"), colorX.Cyan);
32+
ContextMenuItem Button = ctx.AddItem("Fish", new Uri("resdb:///5a56714e4cc021888cb51162cc34b55a7a1333fe8bc162c8be906f9345206b3c.png"), colorX.Cyan);
3433

3534
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");
35+
Slot MenuSlot = Button.Slot;
36+
var StaticAudio = MenuSlot.AttachAudioClip(new Uri("resdb:///1ed74a85e7d9a8e2456fadbd276cb9dd223ad96377ad230409693d408524606e.wav"));
4037

4138
var ClipPlayer = MenuSlot.AttachComponent<RandomAudioClipPlayer>();
4239
ClipPlayer.Clips.Add();
4340
ClipPlayer.Clips.GetElement(0).Clip.Target = StaticAudio;
44-
41+
4542
var Trigger = MenuSlot.AttachComponent<ButtonActionTrigger>();
4643
Trigger.OnPressed.Target = ClipPlayer.Play;
4744
}
4845
}
4946
}
5047
}
51-
}
48+
}

ResoniteFish/ResoniteFish.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<RootNamespace>ResoniteFish</RootNamespace>
4-
<AssemblyName>ResoniteFish</AssemblyName>
4+
<AssemblyName>Fish</AssemblyName>
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
66
<TargetFramework>net472</TargetFramework>
77
<FileAlignment>512</FileAlignment>
@@ -40,10 +40,6 @@
4040
<HintPath>$(ResonitePath)Resonite_Data\Managed\Elements.Core.dll</HintPath>
4141
<Private>False</Private>
4242
</Reference>
43-
<Reference Include="Elements.Assets">
44-
<HintPath>$(ResonitePath)Resonite_Data\Managed\Elements.Assets.dll</HintPath>
45-
<Private>False</Private>
46-
</Reference>
4743
</ItemGroup>
4844

4945
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(CopyToMods)'=='true'">

0 commit comments

Comments
 (0)