Skip to content

Commit

Permalink
Make it work locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Banane9 committed Apr 16, 2022
1 parent 3b656b9 commit 5236383
Showing 1 changed file with 19 additions and 52 deletions.
71 changes: 19 additions & 52 deletions PacifistAprilFoolsExplosion/PacifistAprilFoolsExplosion.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using BaseX;
using CodeX;
using BaseX;
using FrooxEngine;
using FrooxEngine.LogiX;
using FrooxEngine.LogiX.Data;
using FrooxEngine.LogiX.ProgramFlow;
using FrooxEngine.UIX;
using HarmonyLib;
using NeosModLoader;

Expand All @@ -20,18 +11,14 @@ public class PacifistAprilFoolsExplosion : NeosMod

private const string explosionSlotName = "Explosion";

[AutoRegisterConfigKey]
private static ModConfigurationKey<bool> DisableExplosion = new ModConfigurationKey<bool>("DisableExplosion", "Disable the Violent Explosion component locally when it's loaded.", () => true);

/*
[AutoRegisterConfigKey]
private static ModConfigurationKey<bool> HideFlames = new ModConfigurationKey<bool>("HideFlames", "Hide the Violent Explosion's flame particles.", () => true);

[AutoRegisterConfigKey]
private static ModConfigurationKey<bool> MuteBloating = new ModConfigurationKey<bool>("MuteBloating", "Mute the Violent Explosion's bloating sound effect.", () => false);

[AutoRegisterConfigKey]
private static ModConfigurationKey<bool> MuteExplosion = new ModConfigurationKey<bool>("MuteExplosion", "Mute the Violent Explosion's explosion sound effect.", () => true);*/
private static ModConfigurationKey<bool> MuteExplosion = new ModConfigurationKey<bool>("MuteExplosion", "Mute the Violent Explosion's explosion sound effect.", () => true);

public override string Author => "Banane9";
public override string Link => "https://github.com/Banane9/NeosPacifistAprilFoolsExplosion";
Expand All @@ -46,63 +33,43 @@ public override void OnEngineInit()
harmony.PatchAll();
}

[HarmonyPatch(typeof(ViolentAprilFoolsExplosion))]
private static class ViolentAprilFoolsExplosionPatch
{
[HarmonyPostfix]
[HarmonyPatch("OnAwake")]
private static void OnAwakePostfix(ViolentAprilFoolsExplosion __instance)
{
__instance.RunInUpdates(2, () => ValueUserOverride.OverrideForUser(__instance.EnabledField, __instance.World.LocalUser, !Config.GetValue(DisableExplosion)));
}
}

/*
[HarmonyPatch(typeof(StaticAudioClip))]
private static class StaticAudioClipPatch
{
[HarmonyPatch("OnAwake")]
[HarmonyPostfix]
[HarmonyPatch("OnAwake")]
private static void OnAwakePostfix(StaticAudioClip __instance)
{
Msg("Muting potential explosion awake");
__instance.RunInUpdates(5, () =>
__instance.RunInUpdates(1, () =>
{
Msg("Muting potential explosion pre");
if (__instance.Slot.ActiveSelf || __instance.Slot.Name != explosionSlotName)
if (__instance.Slot.PersistentSelf || __instance.Slot.Name != explosionSlotName)
return;

Msg("Muting potential explosion");
if (Config.GetValue(MuteBloating) && __instance.URL == NeosAssets.Common.Sound_Effect.Bloating)
ValueUserOverride.OverrideForUser(__instance.URL, __instance.World.LocalUser, null);
else if (Config.GetValue(MuteExplosion) && __instance.URL == NeosAssets.Common.Sound_Effect.Explosion)
ValueUserOverride.OverrideForUser(__instance.URL, __instance.World.LocalUser, null);
__instance.URL.OverrideForUser(__instance.World.LocalUser, null);

if (Config.GetValue(MuteExplosion) && __instance.URL == NeosAssets.Common.Sound_Effect.Explosion)
__instance.URL.OverrideForUser(__instance.World.LocalUser, null);
});
}
}

[HarmonyPatch(typeof(ComponentBase<Component>))]
[HarmonyPatch(typeof(UnlitMaterial))]
private static class UnlitMaterialPatch
{
[HarmonyPostfix]
[HarmonyPatch("OnChanges")]
private static void OnChangesPostfix(Component __instance)
[HarmonyPatch("OnAwake")]
private static void OnAwakePostfix(UnlitMaterial __instance)
{
if (__instance.Slot.ActiveSelf || !(__instance is UnlitMaterial) || __instance.Slot.Name != explosionSlotName)
return;
Msg("Hiding potential flames");
__instance.RunInUpdates(5, () =>
__instance.RunInUpdates(1, () =>
{
var material = (UnlitMaterial)__instance;
if (Config.GetValue(HideFlames) && (material.Texture.Target.Asset as StaticTexture2D)?.URL == NeosAssets.Common.Particles.Effects.Flame_Atlas8x8)
ValueUserOverride.OverrideForUser(material.TintColor, __instance.World.LocalUser, color.Black);
if (__instance.Slot.PersistentSelf || !Config.GetValue(HideFlames) || __instance.Slot.Name != explosionSlotName)
return;

if ((__instance.Texture.Target as StaticTexture2D)?.URL == NeosAssets.Common.Particles.Effects.Flame_Atlas8x8)
__instance.TintColor.OverrideForUser(__instance.World.LocalUser, color.Black);
});
}
}*/
}
}
}

0 comments on commit 5236383

Please sign in to comment.