make null checks on unity objects better

This commit is contained in:
XtraCube committed 2024-08-23 15:18:06 -04:00
1 parent e0c1038658
commit 6604fb345a
8 files changed
+9 -9

No files matched your search

@@ -63,7 +63,7 @@ public class ModdedEnumOption : ModdedOption<int>
public override void OnValueChanged(int newValue)
{
DestroyableSingleton<HudManager>.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(newValue), false);
if (OptionBehaviour is null)
if (!OptionBehaviour)
{
return;
}
@@ -90,7 +90,7 @@ public class ModdedNumberOption : ModdedOption<float>
Value = Mathf.Clamp(newValue, Min, Max);
DestroyableSingleton<HudManager>.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(Value), false);
if (OptionBehaviour is null)
if (!OptionBehaviour)
{
return;
}
@@ -63,7 +63,7 @@ public class ModdedStringOption : ModdedOption<int>
public override void OnValueChanged(int newValue)
{
DestroyableSingleton<HudManager>.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(newValue), false);
if (OptionBehaviour is null)
if (!OptionBehaviour)
{
return;
}
@@ -55,7 +55,7 @@ public class ModdedToggleOption : ModdedOption<bool>
public override void OnValueChanged(bool newValue)
{
DestroyableSingleton<HudManager>.Instance.Notifier.AddSettingsChangeMessage(StringName, newValue ? "On" : "Off", false);
if (OptionBehaviour is null)
if (!OptionBehaviour)
{
return;
}
+2 -2
View File
@@ -40,7 +40,7 @@ public static class HudManagerPatches
if (customRole.SetTabText() != null)
{
if (_roleTab == null)
if (!_roleTab)
{
_roleTab = CustomRoleManager.CreateRoleTab(customRole);
}
@@ -114,7 +114,7 @@ public static class HudManagerPatches
[HarmonyPatch(nameof(HudManager.SetHudActive), typeof(PlayerControl), typeof(RoleBehaviour), typeof(bool))]
public static void SetHudActivePostfix(HudManager __instance, [HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] RoleBehaviour roleBehaviour, [HarmonyArgument(2)] bool isActive)
{
if (player.Data == null)
if (!player.Data)
{
return;
}
+1 -1
View File
@@ -23,7 +23,7 @@ public static class NameTagPatch
return true;
}
if (PlayerControl.LocalPlayer == null || PlayerControl.LocalPlayer.Data == null || PlayerControl.LocalPlayer.Data.Role == null || otherPlayerRole == null)
if (!PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.Data || !PlayerControl.LocalPlayer.Data.Role || !otherPlayerRole)
{
__result = Color.white;
}
+1 -1
View File
@@ -12,7 +12,7 @@ public static class RoleManagerPatches
[HarmonyPatch(nameof(RoleManager.AssignRoleOnDeath))]
public static bool AssignRoleOnDeath(RoleManager __instance, [HarmonyArgument(0)] PlayerControl plr)
{
if (plr == null || !plr.Data.IsDead)
if (!plr || !plr.Data.IsDead)
{
return false;
}
+1 -1
View File
@@ -35,7 +35,7 @@ public static class TaskPanelPatch
vector2.x += vector.x * 2f;
__instance.tab.transform.localPosition = vector2;
if (GameManager.Instance == null)
if (!GameManager.Instance)
{
return false;
}