Exemplo n.º 1
0
 public static bool TryGetClosest(string kingdomType, Vector3Int position, out NpcKingdom kingdom)
 {
     if (Count < 1)
     {
         kingdom = null;
         return(false);
     }
     kingdom = GetAllByType(kingdomType).OrderBy(npcKingdom => Pipliz.Math.ManhattanDistance(position, npcKingdom.Origin)).First();
     return(true);
 }
Exemplo n.º 2
0
 public static void UnregisterKingdom(NpcKingdom npcKingdom)
 {
     try {
         KingdomsLock.EnterWriteLock();
         Kingdoms.Remove(npcKingdom);
     } finally {
         if (KingdomsLock.IsWriteLockHeld)
         {
             KingdomsLock.ExitWriteLock();
         }
     }
 }
Exemplo n.º 3
0
 public static void RegisterKingdom(NpcKingdom npcKingdom)
 {
     try {
         KingdomsLock.EnterWriteLock();
         Kingdoms.Add(npcKingdom);
     } finally {
         if (KingdomsLock.IsWriteLockHeld)
         {
             KingdomsLock.ExitWriteLock();
         }
     }
     npcKingdom.StartThread();
 }