private void CreateEntity(IEcs ecs, int number, ActorType actor) { var rng = new Random(); var locationSystem = ecs.GetSystem <HasLocation>() as LocationSystem; for (var i = 0; i < number; i++) { var entity = ecs.NewEntity() .WithComponent(this.FindSafeLocation(locationSystem, rng)); if (actor == ActorType.Tree) { this.MakeEntityIntoTree(entity); } else { this.MakeEntityIntoDrowner(entity); } } }
private Entity CreateGeralt(IEcs ecs) { // Make a pathfinder for Geralt's AI that knows where the trees are. var trees = ecs.EntitiesWithComponent <IsActor>() .Where(e => ecs.GetComponent <IsActor>(e).Type == ActorType.Tree) .Select(e => ecs.GetComponent <HasLocation>(e)) .Select(l => new Coord(l.X, l.Y)); var pathFinder = new PathFinder(new Coord(this.boundsX, this.boundsY), trees); return (ecs.NewEntity() .WithComponent(new HasName("Geralt")) .WithComponent(this.FindSafeLocation(ecs.GetSystem <HasLocation>() as LocationSystem, new Random())) .WithComponent(new Renders('G', ConsoleColor.DarkMagenta)) .WithComponent(new IsActor(ActorType.Witcher)) .WithComponent(new HasAi(new WitcherAi(pathFinder))) .WithComponent(new Talks(Logger.AddLog).RandomlySay(Talks.GeraltSpeaks, 0.02)) .WithComponent <HasMoney>() .Entity); }