public void ActivateMobSpawn(MonsterSpawn spawn) { var refCoords = spawn.SpawnData.Coords; int min = Mathf.Max(spawn.SpawnData.MinAmount, 1); int numMonsters = UnityEngine.Random.Range(min, spawn.SpawnData.MaxAmount); var monsterToChoose = spawn.SpawnData.Monster; if (monsterToChoose == null) { var candidates = FindMonstersMatchingTagCollection(spawn.SpawnData.SpawnTags); if (candidates.Count == 0) { Debug.Log($"Couldn't find candidate monsters to spawn @ {refCoords}"); return; } monsterToChoose = candidates[UnityEngine.Random.Range(0, candidates.Count - 1)]; } Vector2Int[] coordList = new Vector2Int[numMonsters]; coordList.Fill <Vector2Int>(refCoords); if (spawn.SpawnData.Scatter) { _map.SetRandomCoords(refCoords, ScatterLimitRadius, ref coordList, firstIsRef: false, (coords) => { bool matchesTile = monsterToChoose.MovingTraitData.MatchesTile(_map.GetTileAt(coords)); if (!matchesTile) { return(true); } bool occupied = _entityController.ExistsEntitiesAt(coords); return(occupied); }); } List <(MonsterData, Vector2Int)> monsterList = new List <(MonsterData, Vector2Int)>(); for (int i = 0; i < numMonsters; ++i) { monsterList.Add((monsterToChoose, coordList[i]));