public void IsBlocked_NotBlocked_ReturnsFalse() { MapCoordinate testMapCoordinate = GetTestMapCoordinate(); positionSystem.SetPosition(mover, testMapCoordinate); systemContainer.EntityEngine.AddComponent(mover, new Physical { Passable = true }); var result = positionSystem.IsBlocked(testMapCoordinate); result.Should().BeFalse(); }
public override ActionEventData ChooseAction(IEntity entity) { var position = _positionSystem.CoordinateOf(entity); var playerPosition = _positionSystem.CoordinateOf(_playerSystem.Player); if (position == null || playerPosition == null || Math.Abs(position.X - playerPosition.X) > 3 || Math.Abs(position.Y - playerPosition.Y) > 3) { return(null); } var adjacentToMe = position.AdjacentCells().Where(c => !_positionSystem.IsBlocked(c)); var adjacentToPlayer = playerPosition.AdjacentCells(); var validCells = adjacentToMe.Except(adjacentToPlayer).Except(new [] { playerPosition }).ToList(); if (validCells.Any()) { var vector = _random.PickOne(validCells) - position; return(new ActionEventData { Action = ActionType.Move, Parameters = vector.ToString(), Speed = entity.Get <Actor>().Speed }); } return(null); }