Skip to content

Commit

Permalink
hotfix/develop: Fixed an issue where you couldn't totally disable FS …
Browse files Browse the repository at this point in the history
…modifiers + fixing console error spamming
  • Loading branch information
Shoko84 committed Jan 29, 2020
1 parent fb34be7 commit 5994d4c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions FightSabers/FightSabers/Models/Modifiers/ColorSucker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ApplyColorVisualOnNote(bool lerpMode)
{
if (!Cnv)
Cnv = transform.parent.GetComponent<ColorNoteVisuals>();
var color = lerpMode ? Color.Lerp(Color.grey, Cnv.noteColor, ModifierManager.instance.lerpValue) : Cnv.noteColor;
var color = lerpMode ? Color.Lerp(Color.grey, Cnv.noteColor, ModifierManager.instance != null ? ModifierManager.instance.lerpValue : 0.2f) : Cnv.noteColor;
if (!_isDisappearingArrow)
{
var arrowSpriteRenderer = Cnv.GetPrivateField<SpriteRenderer>("_arrowGlowSpriteRenderer");
Expand All @@ -85,7 +85,8 @@ public override void EnableModifier()
if (!Cnv)
Cnv = transform.parent.GetComponent<ColorNoteVisuals>();
Cnv.didInitEvent += OnDidInitEvent;
ModifierManager.instance.lerpValue = StartingColorValue;
if (ModifierManager.instance)
ModifierManager.instance.lerpValue = StartingColorValue;
ApplyColorVisualOnNotes(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ public static void Postfix(GameNoteController __instance)
{
var noteShrinker = __instance.noteTransform.gameObject.AddComponent<NoteShrinker>();
noteShrinker.gameNoteController = __instance;
noteShrinker.strength = ModifierManager.instance.noteShrinkerStrength;
noteShrinker.strength = ModifierManager.instance != null ? ModifierManager.instance.noteShrinkerStrength : 1;

}
if (!__instance.noteTransform.gameObject.GetComponent<ColorSucker>())
{
var colorSucker = __instance.noteTransform.gameObject.AddComponent<ColorSucker>();
colorSucker.gameNoteController = __instance;
colorSucker.strength = ModifierManager.instance.colorSuckerStrength;
colorSucker.strength = ModifierManager.instance != null ? ModifierManager.instance.colorSuckerStrength : 1;
colorSuckers.Add(colorSucker);
}

void OnMonsterAdded(object self, MonsterStatus status)
{
if (!ModifierManager.instance) return;
foreach (var monsterModifier in ModifierManager.instance.modifiers)
{
if (__instance.noteTransform.gameObject.GetComponent(monsterModifier) is Modifier modifier)
Expand All @@ -48,14 +49,15 @@ void OnMonsterAdded(object self, MonsterStatus status)

void OnMonsterRemoved(object self, MonsterStatus status)
{
if (!ModifierManager.instance) return;
foreach (var monsterModifier in ModifierManager.instance.modifiers)
{
if (__instance.noteTransform.gameObject.GetComponent(monsterModifier) is Modifier modifier)
modifier.DisableModifier();
}
}

if (!Plugin.config.Value.Enabled)
if (!Plugin.config.Value.Enabled && ModifierManager.instance != null)
{
ModifierManager.instance.noteCountDuration = (int)Math.Ceiling(35 * FightSabersGameplaySetup.instance.ColorSuckerStrength);
foreach (var monsterModifier in ModifierManager.instance.modifiers)
Expand Down
2 changes: 2 additions & 0 deletions FightSabers/FightSabers/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ private static void OnMenuSceneActive()
ExperienceSystem.instance.ApplyExperience();
QuestManager.instance.UnlinkGameEventsForActivatedQuests();
}
if (ModifierManager.instance)
ModifierManager.instance.modifiers = new Type[]{};
CurrentSceneState = SceneState.Menu;
}

Expand Down
4 changes: 2 additions & 2 deletions FightSabers/FightSabers/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.1")]
[assembly: AssemblyFileVersion("0.3.1")]
[assembly: AssemblyVersion("0.3.2")]
[assembly: AssemblyFileVersion("0.3.2")]
2 changes: 1 addition & 1 deletion FightSabers/FightSabers/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"gameVersion": "1.6.2",
"id": "FightSabers",
"name": "FightSabers",
"version": "0.3.1",
"version": "0.3.2",
"dependsOn": {
"BeatSaberMarkupLanguage": "^1.1.3",
"BS Utils": "^1.4.1"
Expand Down

0 comments on commit 5994d4c

Please sign in to comment.