Add IsObjectTank method with error handling to CykUtil

This commit is contained in:
2025-02-24 15:41:54 +01:00
parent af0c47e9e5
commit 446ef52012

View File

@@ -1,3 +1,5 @@
using System;
namespace TerraTech { namespace TerraTech {
public class CykUtil { public class CykUtil {
public static bool IsPlayerTank(Module module) { public static bool IsPlayerTank(Module module) {
@@ -11,5 +13,18 @@ namespace TerraTech {
return false; return false;
return tank.ControllableByLocalPlayer; return tank.ControllableByLocalPlayer;
} }
public static bool IsObjectTank(object obj) {
if (obj == null)
return false;
try {
return IsPlayerTank(obj as Module);
} catch (Exception e) {
Console.WriteLine("Failed to check if object is a player tank: " + e.Message);
return false;
}
return false;
}
} }
} }