Skip to content

Commit

Permalink
Now also disables the Fury of the Fallen effect. There's now a menu w…
Browse files Browse the repository at this point in the history
…here you can set which effects you want or not.
  • Loading branch information
luizzeroxis committed May 1, 2023
1 parent 7544772 commit da1846b
Showing 1 changed file with 106 additions and 12 deletions.
118 changes: 106 additions & 12 deletions DisableLowHealthVignette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,134 @@
using UnityEngine;

namespace DisableLowHealthVignette {
public class DisableLowHealthVignette : Mod, ITogglableMod {
public class DisableLowHealthVignette : Mod, IMenuMod, IGlobalSettings<GlobalSettingsClass> {
new public string GetName() => "DisableLowHealthVignette";
public override string GetVersion() => "1.0.0.0";
public override string GetVersion() => "1.1.0.0";

public GameObject vignette;
public bool ToggleButtonInsideMenu => false;

static GlobalSettingsClass globalSettings = new GlobalSettingsClass();

GameObject vignette;
GameObject furyEffects;

public override void Initialize(Dictionary<string, Dictionary<string, GameObject>> preloadedObjects) {
On.HUDCamera.OnEnable += OnHUDCameraOnEnable;
DisableVignette();

UpdateEffects();
}

public void Unload() {
On.HUDCamera.OnEnable -= OnHUDCameraOnEnable;

EnableVignette();
vignette = null;
EnableFuryEffects();
}

private void OnHUDCameraOnEnable(On.HUDCamera.orig_OnEnable orig, HUDCamera self) {
void OnHUDCameraOnEnable(On.HUDCamera.orig_OnEnable orig, HUDCamera self) {
orig(self);

DisableVignette();
UpdateEffects();
}

public void DisableVignette() {
vignette = GameObject.Find("Low Health Vignette");
if (vignette) {
vignette.SetActive(false);
void UpdateEffects() {
if (globalSettings.showLow) {
EnableVignette();
} else {
DisableVignette();
}

if (globalSettings.showFury) {
EnableFuryEffects();
} else {
DisableFuryEffects();
}
}

void DisableVignette() {
GameObject currentVignette = GameObject.Find("Low Health Vignette");
if (currentVignette) {
currentVignette.SetActive(false);
vignette = currentVignette;
}
}

public void EnableVignette() {
void EnableVignette() {
if (vignette) {
vignette.SetActive(true);
vignette = null;
}
}

void DisableFuryEffects() {
GameObject currentFuryEffects = GameObject.Find("fury_effects_v2");
if (currentFuryEffects) {
currentFuryEffects.SetActive(false);
furyEffects = currentFuryEffects;
}
}

void EnableFuryEffects() {
if (furyEffects) {
furyEffects.SetActive(true);
furyEffects = null;
}
}

public List<IMenuMod.MenuEntry> GetMenuData(IMenuMod.MenuEntry? toggleButtonEntry) {
return new List<IMenuMod.MenuEntry> {
new IMenuMod.MenuEntry {
Name = "Show low health vignette effect?",
Values = new string[] {
"No",
"Yes",
},
Saver = opt => {
globalSettings.showLow = opt switch {
0 => false,
1 => true,
_ => throw new System.NotImplementedException(),
};
UpdateEffects();
},
Loader = () => globalSettings.showLow switch {
false => 0,
true => 1,
},
},
new IMenuMod.MenuEntry {
Name = "Show Fury of the Fallen effect?",
Values = new string[] {
"No",
"Yes",
},
Saver = opt => {
globalSettings.showFury = opt switch {
0 => false,
1 => true,
_ => throw new System.NotImplementedException(),
};
UpdateEffects();
},
Loader = () => globalSettings.showFury switch {
false => 0,
true => 1,
},
}
};
}

public void OnLoadGlobal(GlobalSettingsClass s) {
globalSettings = s;
}

public GlobalSettingsClass OnSaveGlobal() {
return globalSettings;
}
}

public class GlobalSettingsClass {
public bool showLow = false;
public bool showFury = false;
}
}

0 comments on commit da1846b

Please sign in to comment.