private ErrorCodes CollectEnvironmentData(long eid, int range, out int definition, out EntityEnvironmentDescription result) { result = new EntityEnvironmentDescription(); const ErrorCodes ec = ErrorCodes.NoError; definition = 0; var unit = _zone.GetUnit(eid); if (unit == null) { return(ErrorCodes.ItemNotFound); } definition = unit.Definition; var entityPosition = unit.CurrentPosition; var sampleArea = _zone.CreateArea(entityPosition, range); var turns = (int)(Math.Round(unit.Orientation, 2) / 0.25); var blocksTiles = CollectBlockingHeight(sampleArea, entityPosition, turns); if (blocksTiles.Count > 0) { result.blocksTiles = blocksTiles; } return(ec); }
/// <summary> /// Limits the amount of walls in an area /// </summary> private bool IsWallAmountMatch(IZone zone, int x, int y) { var area = zone.CreateArea(new Position(x, y), WALL_AMOUNT_AREA_RADIUS); return(zone.CountPlantsInArea(PlantType.Wall, area) <= WALL_AMOUNT_MAXCOUNT); }