private static bool IsInitialized(uGUI_PowerIndicator instance) { if (initializedField == null) { initializedField = typeof(uGUI_PowerIndicator).GetField("initialized", BindingFlags.NonPublic | BindingFlags.Instance); } return((bool)initializedField.GetValue(instance)); }
private static void CreateTracker(uGUI_PowerIndicator __instance) { var parent = __instance.text.transform.parent; if (parent == null) { Logger.Error("Tried to create tracker but hud was null!"); } tracker = BlueprintTracker.Create(parent); }
private static void InitializeTracker(uGUI_PowerIndicator __instance) { if (tracker == null) { tracker = GameObject.FindObjectOfType <BlueprintTracker>(); if (tracker == null) { CreateTracker(__instance); } } }
private static void Postfix(uGUI_PowerIndicator __instance) { if (tracker != null) { return; } if (Inventory.main == null) { return; } InitializeTracker(__instance); }
private static void Postfix(uGUI_PowerIndicator __instance) { if (initialized) { if (Player.main == null) { Logger.Log("Deinitialize from no player"); initialized = false; } return; } if (Inventory.main == null) { return; } Mod.LoadSaveData(); initialized = true; }
private static void Postfix(uGUI_PowerIndicator __instance) { if (initialized) { if (Player.main == null) { Log.Info("Deinitialize from no player"); initialized = false; } return; } if (Inventory.main == null) { return; } Log.Info("Initialized Works"); initialized = true; }
private static void Postfix(uGUI_PowerIndicator __instance) { bool indicatorInitialized = IsInitialized(__instance); if (!indicatorInitialized || __instance.text == null) { initialized = false; return; } if (initialized) { return; } if (__instance.gameObject.GetComponent <GameController>() == null) { __instance.gameObject.AddComponent <GameController>(); initialized = true; } }
public static bool IsPowerEnabled(uGUI_PowerIndicator powerIndicator, out int power, out int maxPower, out PowerSystem.Status status) { power = 0; maxPower = 0; status = PowerSystem.Status.Offline; if ( !IsPowerInitialized(powerIndicator) || !uGUI.isMainLevel || uGUI.isIntro || LaunchRocket.isLaunching || !GameModeUtils.RequiresPower() ) { return(false); } var main = Player.main; if (main == null) { return(false); } var pda = main.GetPDA(); if (pda != null && pda.isInUse) { return(false); } if (main.escapePod.value) { var currentEscapePod = main.currentEscapePod; if (currentEscapePod != null) { var component = currentEscapePod.GetComponent <PowerRelay>(); if (component != null) { power = Mathf.RoundToInt(component.GetPower()); maxPower = Mathf.RoundToInt(component.GetMaxPower()); status = component.GetPowerStatus(); return(true); } } } var currentSub = main.currentSub; if (currentSub == null) { return(false); } var powerRelay = currentSub.powerRelay; if (powerRelay == null) { return(false); } power = Mathf.RoundToInt(powerRelay.GetPower()); maxPower = Mathf.RoundToInt(powerRelay.GetMaxPower()); status = powerRelay.GetPowerStatus(); return(true); }
private static bool IsPowerInitialized(uGUI_PowerIndicator powerIndicator) { return((bool)Field.GetValue(powerIndicator)); }