public override void Process(Random randomStream, Tile tile) { var propTable = Props.Clone(); GetPropCountDelegate getCountDelegate; if (!GetCountMethods.TryGetValue(CountMode, out getCountDelegate)) { throw new NotImplementedException("LocalPropSet count mode \"" + CountMode + "\" is not yet implemented"); } int count = getCountDelegate(this, randomStream, tile); List <GameObject> toKeep = new List <GameObject>(count); for (int i = 0; i < count; i++) { var chosenEntry = propTable.GetRandom(randomStream, tile.Placement.IsOnMainPath, tile.Placement.NormalizedDepth, null, true, true); if (chosenEntry != null && chosenEntry.Value != null) { toKeep.Add(chosenEntry.Value); } } foreach (var prop in Props.Weights) { if (!toKeep.Contains(prop.Value)) { UnityUtil.Destroy(prop.Value); } } }
public override void Process(System.Random randomStream, Tile tile) { var propTable = Props.Clone(); int count = PropCount.GetRandom(randomStream); count = Mathf.Clamp(count, 0, Props.Weights.Count); List <GameObject> toKeep = new List <GameObject>(count); for (int i = 0; i < count; i++) { var chosenEntry = propTable.GetRandom(randomStream, tile.Placement.IsOnMainPath, tile.Placement.NormalizedDepth, null, true, true); if (chosenEntry != null && chosenEntry.Value != null) { toKeep.Add(chosenEntry.Value); } } foreach (var prop in Props.Weights) { if (!toKeep.Contains(prop.Value)) { UnityUtil.Destroy(prop.Value); } } }