Skip to content

Commit

Permalink
Fix some null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 6, 2020
1 parent dd56d20 commit 02c904b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions KK_BecomeTrap/BecomeTrap.Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private static class Hooks
{
private static BecomeTrapController GetController(Player player)
{
return player?.chaCtrl?.gameObject.GetComponent<BecomeTrapController>();
if (player == null || player.chaCtrl == null) return null;
return player.chaCtrl.gameObject.GetComponent<BecomeTrapController>();
}

/// <summary>
Expand Down Expand Up @@ -140,10 +141,9 @@ public static void GetListCommandPostfix(Info __instance, ref List<Info.BasicInf
// Calling only StackTrace would be enough but this is much faster for most calls
if (_stage >= 2 || _group != ActionGame.Communication.Info.Group.Introduction || _command != 0) return;

var player = Game.Instance?.actScene?.Player;
if (player == null) return;
if (Game.Instance == null || Game.Instance.actScene == null) return;

var controller = GetController(player);
var controller = GetController(Game.Instance.actScene.Player);
// Only applicable if the player is a trap
if (controller == null || !controller.IsTrap) return;

Expand Down

0 comments on commit 02c904b

Please sign in to comment.