629 {
631
632
633 bunkers.ShuffleArray();
634 #ifdef ENABLE_LOGGING
635 Log(
"Random bunker selection:");
636 #endif
638 {
639 if (!bunker)
640 continue;
642 available.Insert(bunker);
643 #ifdef ENABLE_LOGGING
644 else
645 Log(
string.Format(
"Bunker was already used (%1)", bunker.GetId()),
true);
646 #endif
647 }
648
649 int n = available.Count();
650 if (amount > n)
651 amount = n;
652
655
656 while (selected.Count() < amount)
657 {
658 int randomIndex = Math.RandomInt(0, n);
659
660 bool alreadyUsed = false;
661 foreach (int u : used)
662 {
663 if (u == randomIndex)
664 {
665 alreadyUsed = true;
666 break;
667 }
668 }
669
670 if (!alreadyUsed)
671 {
672 selected.Insert(available[randomIndex]);
673 #ifdef ENABLE_LOGGING
674 Log(
string.Format(
"Selecting bunker (%1)", available[randomIndex].
GetId()),
true);
675 #endif
676 used.Insert(randomIndex);
677 }
678 }
679
680 return selected;
681 }
void BunkerBroadcastComponentBase(notnull EntityAI parent)
array< ref BunkerBroadcastComponentBase > BunkerComponentsArray
class LogTemplates Log(string message, LogTemplateID template_id=0)
Creates debug log (optional) from LogTemplate which are registred.
ref SimpleCircularBuffer< int > m_ActiveBunkersHistory
const int INDEX_NOT_FOUND