Ejemplo n.º 1
0
 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);
     }
 }