Skip to content

Commit 4f2b2b8

Browse files
committed
Prevent April Fools content from triggering for users in universes with optional setting to force april fools at any time.
This adds a fix for Yellow-Dog-Man/Resonite-Issues#4016 - If you're reading this, Prime, I hope this motivates you to fix it in vanilla before the end of the month, too ;)
1 parent d891579 commit 4f2b2b8

5 files changed

Lines changed: 57 additions & 3 deletions

File tree

CommunityBugFixCollection/BugFixOptions.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@ namespace CommunityBugFixCollection
44
{
55
internal sealed class BugFixOptions : SingletonConfigSection<BugFixOptions>
66
{
7+
private static readonly DefiningConfigKey<bool> _forceAprilFools = new("ForceAprilFools", "Whether to force April Fools content to be active.", () => false);
8+
79
private static readonly DefiningConfigKey<bool> _useIecByteFormat = new("UseIecByteFormat", "Whether to format bytes using IEC as opposed to decimal format when <i>LocalizedByteFormatting</i> is enabled.", () => true);
810

911
/// <inheritdoc/>
1012
public override string Description => "Contains the settings for the few fixes that offer them.";
1113

14+
/// <summary>
15+
/// Gets whether to force April Fools content to be active.
16+
/// </summary>
17+
public bool ForceAprilFools => _forceAprilFools;
18+
1219
/// <inheritdoc/>
1320
public override string Id => "Options";
1421

1522
/// <summary>
1623
/// Gets whether <see cref="LocalizedByteFormatting"/> should format bytes using IEC or decimal format.
1724
/// </summary>
18-
public bool UseIecByteFormat => _useIecByteFormat.GetValue();
25+
public bool UseIecByteFormat => _useIecByteFormat;
1926

2027
/// <inheritdoc/>
21-
public override Version Version { get; } = new(1, 0, 0);
28+
public override Version Version { get; } = new(1, 1, 0);
2229
}
2330
}

CommunityBugFixCollection/Locale/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"CommunityBugFixCollection.NoLossOfColorProfile.Description": "Verhindert, dass Farbprofile nicht bei allen Berechnungen erhalten bleiben.",
3838
"CommunityBugFixCollection.NoZeroScaleToolRaycast.Description": "Verhinder einen Crash wenn (Multi-)Werkzeuge auf null skaliert werden.",
3939
"CommunityBugFixCollection.NodeNameAdjustments.Description": "Verbessert die verwirrenden Namen der Remap [-1; 1] zu [0; 1] ProtoFlux Nodes.",
40+
"CommunityBugFixCollection.NoFunForCorporate.Description": "Verhindert, dass Aprilscherz-Inhalte ausgelöst werden, wenn der Nutzer in einem Universe ist.<br/>Dies wird durch die <i>Erzwinge Aprilscherze</i> Einstellung überschrieben, welche erzwingt, dass diese Inhalte aktiv sind.",
4041
"CommunityBugFixCollection.NonHDRColorClamping.Description": "Korrigiert, dass die nicht-HDR Varianten der Color(X) Kanal-Additionen die Werte nicht limitieren.",
4142
"CommunityBugFixCollection.NonLinearColorXFromHexCode.Description": "Zwingt colorX From HexCode das sRGB statt dem Linearen Farbprofil zu nutzen.",
4243
"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.",
@@ -51,6 +52,8 @@
5152

5253
"CommunityBugFixCollection.Config.Options.Name": "Optionen",
5354
"CommunityBugFixCollection.Config.Options.Description": "Enthällt die Einstellungen für die wenigen Fixes die diese anbieten.",
55+
"CommunityBugFixCollection.Config.Options.ForceAprilFools.Name": "Erzwinge Aprilscherze",
56+
"CommunityBugFixCollection.Config.Options.ForceAprilFools.Description": "Ob Aprilscherz-Inhalte erzwungenermaßen aktiv sein sollen.",
5457
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Name": "IEC Byte-Format Benutzen",
5558
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Description": "Ob Bytes nach IEC (Faktor 1024) statt dezimal (Faktor 1000) formatiert werden sollen, wenn <i>LocalizedByteFormatting</i> aktiviert ist.",
5659

CommunityBugFixCollection/Locale/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"CommunityBugFixCollection.NoLossOfColorProfile.Description": "Fixes Color Profile not being preserved on all operations.",
4444
"CommunityBugFixCollection.NoZeroScaleToolRaycast.Description": "Fixes a crash when a (multi)tool is scaled to zero.",
4545
"CommunityBugFixCollection.NodeNameAdjustments.Description": "Fixes the confusing names of the Remap [-1; 1] to [0; 1] ProtoFlux nodes.",
46+
"CommunityBugFixCollection.NoFunForCorporate.Description": "Prevents April Fools related content from triggering when the user is in a Universe.<br/>This is overridden by the <i>Force April Fools</i> setting, which forces this content to be active.",
4647
"CommunityBugFixCollection.NonHDRColorClamping.Description": "Fixes non-HDR variants of Color(X) channel addition not clamping.",
4748
"CommunityBugFixCollection.NonLinearColorXFromHexCode.Description": "Forces colorX From HexCode to use the sRGB rather than Linear profile.",
4849
"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.",
@@ -57,6 +58,8 @@
5758

5859
"CommunityBugFixCollection.Config.Options.Name": "Options",
5960
"CommunityBugFixCollection.Config.Options.Description": "Contains the settings for the few fixes that offer them.",
61+
"CommunityBugFixCollection.Config.Options.ForceAprilFools.Name": "Force April Fools",
62+
"CommunityBugFixCollection.Config.Options.ForceAprilFools.Description": "Whether to force April Fools content to be active.",
6063
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Name": "Use IEC Byte Format",
6164
"CommunityBugFixCollection.Config.Options.UseIecByteFormat.Description": "Whether to format bytes using IEC (factor 1024) as opposed to decimal format (factor 1000) when <i>LocalizedByteFormatting</i> is enabled.",
6265

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using FrooxEngine;
2+
using HarmonyLib;
3+
4+
namespace CommunityBugFixCollection
5+
{
6+
[HarmonyPatch]
7+
[HarmonyPatchCategory(nameof(NoFunForCorporate))]
8+
internal sealed class NoFunForCorporate : ResoniteBugFixMonkey<NoFunForCorporate>
9+
{
10+
public override IEnumerable<string> Authors => Contributors.Banane9;
11+
12+
[HarmonyPrefix]
13+
[HarmonyPatch(typeof(Engine), nameof(Engine.IsAprilFools), MethodType.Getter)]
14+
private static bool EngineIsAprilFoolsPrefix(ref bool __result)
15+
{
16+
if (!Enabled)
17+
return true;
18+
19+
if (ConfigSection.ForceAprilFools)
20+
{
21+
__result = true;
22+
return false;
23+
}
24+
25+
if (Engine.Current.InUniverse)
26+
{
27+
__result = false;
28+
return false;
29+
}
30+
31+
return true;
32+
}
33+
34+
[HarmonyPrefix]
35+
[HarmonyPatch(typeof(ViolentAprilFoolsExplosion), nameof(ViolentAprilFoolsExplosion.OnDestroying))]
36+
private static bool ViolentAprilFoolsExplosionOnDestroyingPrefix()
37+
=> !Enabled || ConfigSection.ForceAprilFools || !Engine.Current.InUniverse;
38+
}
39+
}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ just disable them in the settings in the meantime.
6060
* Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480)
6161
* Grid World floor shaking on AMD and Intel GPUs (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3829)
6262
* DuplicateSlot ProtoFlux node crashes game when if OverrideParent is identical to Template (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3950)
63+
* April Fools content is active for users in Universes (commercial usage) (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/4016)
6364
* Instantly removing an AudioOutput component crashes the session (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/4286)
6465

6566
Fixes with no issue (that could be found).
@@ -91,7 +92,8 @@ just disable them in the settings in the meantime.
9192

9293
## Closed Issues
9394

94-
The issues that were first closed in this mod but have officially been closed now will be linked in the following list.
95+
The issues that were first covered by this mod,
96+
but have officially been implemented now, will be linked in the following list.
9597
If they appear here, their implementation has been removed from the mod,
9698
unless it is marked with `(Legacy)`.
9799
In that case, the original fix is left in but disabled by default.

0 commit comments

Comments
 (0)