private void ReadjustWeightTableAfterRemove(int removedIndex) { int weightToRemove = _weightTable[removedIndex].orb.weight; _weightTable.RemoveAt(removedIndex); int weightCount = _weightTable.Count; for (int weightIndex = removedIndex; weightIndex < weightCount; weightIndex++) { WeightedEntry entry = _weightTable[weightIndex]; entry.accumulatedWeight -= weightToRemove; _weightTable[weightIndex] = entry; } _totalWeight -= weightToRemove; }
public RandomChoice(WeightedEntry[] entries) { this.entries = entries; weightSum = entries.Sum(e => e.weight); }