Skip to content

Commit

Permalink
Disabled in Campaign mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zingabopp committed Apr 17, 2019
1 parent a27912f commit 6be80f6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
31 changes: 30 additions & 1 deletion BailOutMode/BailOutController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -22,6 +23,14 @@ class BailOutController : MonoBehaviour
public static int numFails = 0;
public static float failTextFontSize = 15f;

public bool IsEnabled
{
get
{
return Plugin.IsEnabled && (!isCampaign);
}
}

public TextMeshProUGUI FailText
{
get
Expand Down Expand Up @@ -118,9 +127,29 @@ public void Awake()
public void Start()
{
//Logger.Trace("BailOutController Start()");
StartCoroutine(Initialize());
LevelFailedEffect = GameObject.FindObjectsOfType<LevelFailedTextEffect>().FirstOrDefault();
if ((GameManager != null) && (EnergyCounter != null) && Plugin.IsEnabled)

}

private bool isCampaign = false;

private IEnumerator Initialize()
{
yield return new WaitForSeconds(0.5f);
//Logger.Trace("Checking for Campaign mode");
if (GameObject.FindObjectsOfType<MissionGameplaySceneSetup>().Count() > 0)
{
Logger.Info("Campaign mode detected, BailOutMode unavailable.");
isCampaign = true;
}
else
{
isCampaign = false;
}
if ((GameManager != null) && (EnergyCounter != null) && IsEnabled)
{
Logger.Info("BailOutMode enabled");
//Logger.Trace("Removing HandleGameEnergyDidReach0");
EnergyCounter.gameEnergyDidReach0Event -= GameManager.HandleGameEnergyDidReach0;
}
Expand Down
5 changes: 4 additions & 1 deletion BailOutMode/Harmony_Patches/GameEnergyCounterAddEnergy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class GameEnergyCounterAddEnergy
static bool Prefix(GameEnergyCounter __instance, ref float value)
{
//Logger.Trace("In GameEnergyCounter.AddEnergy()");
if (Plugin.IsEnabled && value < 0f)
bool enabled = false;
if (BailOutController.Instance != null)
enabled = BailOutController.Instance.IsEnabled;
if (enabled && value < 0f)
{
//Logger.Trace("Negative energy change detected: {0}", value);
if (__instance.energy + value <= 0)
Expand Down
3 changes: 1 addition & 2 deletions BailOutMode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"version": "1.2.0",
"gameVersion": "0.13.2",
"author": "Zingabopp",
"dependsOn": {
},
"features": [
"no-update"
]
}

0 comments on commit 6be80f6

Please sign in to comment.