public virtual void Create(IWorld world, IRoom room, IFaction faction, RoomBlueprint roomBlueprintIfAny) { var max = roomBlueprintIfAny?.OptionalActorsMax ?? 5; if (max <= 0) { return; } var min = roomBlueprintIfAny?.OptionalActorsMin ?? 1; if (min > max) { throw new ArgumentOutOfRangeException($"OptionalActorsMin should be lower than OptionalActorsMax for room blueprint '{roomBlueprintIfAny}'"); } int numberOfNpc = world.R.Next(min, max + 1); var pickFrom = Blueprints.Where(b => b.SuitsFaction(faction)).ToList(); if (roomBlueprintIfAny != null) { pickFrom = pickFrom.Union(roomBlueprintIfAny.OptionalActors).ToList(); } if (pickFrom.Any()) { for (int i = 0; i < numberOfNpc; i++) { Create(world, room, faction, pickFrom.GetRandom(world.R), roomBlueprintIfAny); } } }
public IRoom Create(IWorld world) { return(Create(world, Blueprints.Where(Spawnable).ToArray().GetRandom(world.R))); }