Skip to content

Commit e2eefc9

Browse files
committed
Prevent ChildParentAudioClipPlayer component crashing the game
Adds a fix for Yellow-Dog-Man/Resonite-Issues#1457
1 parent cd84c1f commit e2eefc9

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

CommunityBugFixCollection/Locale/de.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"CommunityBugFixCollection.NodeNameAdjustments.Description": "Verbessert die verwirrenden Namen der Remap [-1; 1] zu [0; 1] ProtoFlux Nodes.",
3939
"CommunityBugFixCollection.NonHDRColorClamping.Description": "Korrigiert, dass die nicht-HDR Varianten der Color(X) Kanal-Additionen die Werte nicht limitieren.",
4040
"CommunityBugFixCollection.NonLinearColorXFromHexCode.Description": "Zwingt colorX From HexCode das sRGB statt dem Linearen Farbprofil zu nutzen.",
41+
"CommunityBugFixCollection.NoParentUnderSelfAudioClipPlayer.Description": "Verhindert, dass die ChildParentAudioClipPlayer-Komponente das Spiel crasht, wenn ihr <i>ParentUnder</i>-Feld auf den Slot, auf dem sie ist, gesetzt ist. Fügt außerdem eine Erklärung des Problems im Header hinzu.",
4142
"CommunityBugFixCollection.PauseAnimatorUpdates.Description": "Verhindert, dass Animatoren jeden Frame in alle assoziierten Felder schreiben, obwohl sie nicht am animieren sind.",
4243
"CommunityBugFixCollection.ReallyNoDestroyUndo.Description": "Sorgt dafür, dass die NoDestroyUndo Komponente tatsächlich verhindert, dass das Zerstören eines Objekts rückgängig gemacht werden kann.",
4344
"CommunityBugFixCollection.SmoothDraggables.Description": "Umgeht, dass Slider und Joints in Headless-Sessions verrutschen.",
@@ -50,6 +51,8 @@
5051
"CommunityBugFixCollection.Config.Options.Name": "Optionen",
5152
"CommunityBugFixCollection.Config.Options.Description": "Enthällt die Einstellungen für die wenigen Fixes die diese anbieten.",
5253
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Name": "IEC Byte-Format Benutzen",
53-
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Description": "Ob Bytes nach IEC (Faktor 1024) statt dezimal (Faktor 1000) formatiert werden sollen, wenn <i>LocalizedByteFormatting</i> aktiviert ist."
54+
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Description": "Ob Bytes nach IEC (Faktor 1024) statt dezimal (Faktor 1000) formatiert werden sollen, wenn <i>LocalizedByteFormatting</i> aktiviert ist.",
55+
56+
"CommunityBugFixCollection.ChildParentAudioClipPlayer.Header": "Das <i>ParentUnder</i>-Feld dieser AudioClipPlayer-Komponente darf niemals auf den Slot, auf dem sie ist, gesetzt werden. Andernfalls crasht das Spiel wenn ein Clip ausgelöst wird."
5457
}
5558
}

CommunityBugFixCollection/Locale/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"CommunityBugFixCollection.NodeNameAdjustments.Description": "Fixes the confusing names of the Remap [-1; 1] to [0; 1] ProtoFlux nodes.",
4545
"CommunityBugFixCollection.NonHDRColorClamping.Description": "Fixes non-HDR variants of Color(X) channel addition not clamping.",
4646
"CommunityBugFixCollection.NonLinearColorXFromHexCode.Description": "Forces colorX From HexCode to use the sRGB rather than Linear profile.",
47+
"CommunityBugFixCollection.NoParentUnderSelfAudioClipPlayer.Description": "Prevents the ChildParentAudioClipPlayer components from crashing the game if their <i>ParentUnder</i> field is set to the slot that it's on. Also adds a header text explaining the problem.",
4748
"CommunityBugFixCollection.PauseAnimatorUpdates.Description": "Fixes animators updating all associated fields every frame while enabled but not playing.",
4849
"CommunityBugFixCollection.ReallyNoDestroyUndo.Description": "Makes the NoDestroyUndo component actually prevent undoing destroying something.",
4950
"CommunityBugFixCollection.SmoothDraggables.Description": "Workaround for Sliders and Joints snapping in sessions hosted by a headless.",
@@ -70,6 +71,8 @@
7071
"CommunityBugFixCollection.StorageUnits.MB": "MB",
7172
"CommunityBugFixCollection.StorageUnits.GB": "GB",
7273
"CommunityBugFixCollection.StorageUnits.TB": "TB",
73-
"CommunityBugFixCollection.StorageUnits.PB": "PB"
74+
"CommunityBugFixCollection.StorageUnits.PB": "PB",
75+
76+
"CommunityBugFixCollection.ChildParentAudioClipPlayer.Header": "This AudioClipPlayer component's <i>ParentUnder</i> field must never be set to the slot it's on. Otherwise, the game will crash when a clip is triggered."
7477
}
7578
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using FrooxEngine;
2+
using HarmonyLib;
3+
using MonkeyLoader.Resonite;
4+
using MonkeyLoader.Resonite.UI.Inspectors;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
9+
namespace CommunityBugFixCollection
10+
{
11+
[HarmonyPatch(typeof(ChildParentAudioClipPlayer))]
12+
[HarmonyPatchCategory(nameof(NoParentUnderSelfAudioClipPlayer))]
13+
internal sealed class NoParentUnderSelfAudioClipPlayer : ResoniteEventHandlerMonkey<NoParentUnderSelfAudioClipPlayer, ResolveInspectorHeaderTextEvent>
14+
{
15+
public override IEnumerable<string> Authors => Contributors.Banane9;
16+
17+
public override bool CanBeDisabled => true;
18+
19+
public override int Priority => HarmonyLib.Priority.Low;
20+
21+
protected override void Handle(ResolveInspectorHeaderTextEvent eventData)
22+
=> eventData.AddItem(new(Mod.GetLocaleString("ChildParentAudioClipPlayer.Header")));
23+
24+
[HarmonyPostfix]
25+
[HarmonyPatch(nameof(ChildParentAudioClipPlayer.OnAwake))]
26+
private static void OnAwakePostfix(ChildParentAudioClipPlayer __instance)
27+
{
28+
if (Enabled && __instance.ParentUnder.Target == __instance.Slot)
29+
__instance.ParentUnder.Target = null!;
30+
31+
__instance.ParentUnder.OnTargetChange += _ =>
32+
{
33+
if (Enabled && __instance.ParentUnder.Target == __instance.Slot)
34+
__instance.RunSynchronously(() => __instance.ParentUnder.Target = null!);
35+
};
36+
}
37+
38+
[HarmonyPostfix]
39+
[HarmonyPatch(nameof(ChildParentAudioClipPlayer.PlayClip))]
40+
private static void PlayClipPrefix(ChildParentAudioClipPlayer __instance)
41+
{
42+
if (Enabled && __instance.World.CanMakeSynchronousChanges && __instance.ParentUnder.Target == __instance.Slot)
43+
__instance.ParentUnder.Target = null!;
44+
}
45+
}
46+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ just disable them in the settings in the meantime.
5353
* https://github.com/Yellow-Dog-Man/Locale/issues/186
5454
* FlipAtUser component does not respect view position (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1335)
5555
* ColorX From HexCode (ProtoFlux node) defaults to Linear profile (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1404)
56+
* ChildParentAudioClipPlayer component crashes the game when it's triggered while its *ParentUnder* field is set to the slot it's on (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1457)
5657
* Resolution scale may get stuck at 0.5 when opening and closing the SteamVR dashboard while the game is hitching (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2337)
5758
* `ValueMod<Decimal>` node crashes the game when B input is set to zero or disconnected. (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2746)
5859
* Grid World grid being off-center (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2754)

0 commit comments

Comments
 (0)