public static bool IsOwnedByNPC(this IMyTerminalBlock Block, bool AllowNobody = true, bool CheckBuilder = false) { if (!CheckBuilder) { if (Block.IsOwnedByPirates()) { return(true); } if (!AllowNobody && Block.IsOwnedByNobody()) { return(false); } IMyPlayer Owner = MyAPIGateway.Players.GetPlayerByID(Block.OwnerId); return(Owner != null ? Owner.IsBot : true); } else { if (!Block.IsOwnedByNPC(AllowNobody)) { return(false); } long BuilderID = Block.GetBuiltBy(); if (!AllowNobody && BuilderID == 0) { return(false); } IMyPlayer Owner = MyAPIGateway.Players.GetPlayerByID(BuilderID); return(Owner != null ? Owner.IsBot : true); } }
public static bool IsOwnedByNpc(this IMyTerminalBlock block, bool allowNobody = true, bool checkBuilder = false) { if (!checkBuilder) { if (block.IsOwnedByPirates()) { return(true); } if (!allowNobody && block.IsOwnedByNobody()) { return(false); } IMyPlayer owner = MyAPIGateway.Players.GetPlayerById(block.OwnerId); return(owner?.IsBot ?? true); } else { if (!block.IsOwnedByNpc(allowNobody)) { return(false); } long builderId = block.GetBuiltBy(); if (!allowNobody && builderId == 0) { return(false); } IMyPlayer owner = MyAPIGateway.Players.GetPlayerById(builderId); return(owner == null || owner.IsBot); } }