// This is probably hella slow, but it's the easy way to do this. Would be better to cache lists by biome in a System. private MonsterList GetMonsterList(ISystemContainer systemContainer, IEntity branch) { var list = new MonsterList(); var monsters = systemContainer.EntityEngine .AllEntities .Where(e => e.HasAll(new SystemComponents { typeof(Biome), typeof(Health), typeof(Prototype) })) .Where(e => HasMatchingBiome(branch, e)); foreach (var monster in monsters) { var cr = monster.Has <Challenge>() ? monster.Get <Challenge>().ChallengeRating : 0; if (list.ContainsKey(cr)) { list[cr].Add(monster); } else { list.Add(cr, new HashSet <IEntity> { monster }); } } return(list); }
private IEntity PickMonsterToSpawn(MonsterList monsterList, int power, IRandom random) { if (!monsterList.ContainsKey(power)) { return(null); } return(random.PickOne(monsterList[power].ToList())); }