diff --git a/draftsman/environment/script.py b/draftsman/environment/script.py index 86aee60..bac4b23 100644 --- a/draftsman/environment/script.py +++ b/draftsman/environment/script.py @@ -182,9 +182,10 @@ def main(): args: DraftsmanCommandArgs = parser.parse_args(namespace=DraftsmanCommandArgs()) - if args.operation == "version": + if not args.operation: + parser.print_help() + elif args.operation == "version": print("Draftsman {}".format(__version__)) - elif args.operation == "factorio-version": if args.desired_version is None: # Grab and populate the repo, making sure its a git repo we expect diff --git a/draftsman/factorio-data b/draftsman/factorio-data index d7accb4..3588a37 160000 --- a/draftsman/factorio-data +++ b/draftsman/factorio-data @@ -1 +1 @@ -Subproject commit d7accb4077ef7b000298d327e974f94467d39bb8 +Subproject commit 3588a37b997e192f4d9d38418a469d516142c84f diff --git a/draftsman/prototypes/legacy_curved_rail.py b/draftsman/prototypes/legacy_curved_rail.py index da819cb..5f91d11 100644 --- a/draftsman/prototypes/legacy_curved_rail.py +++ b/draftsman/prototypes/legacy_curved_rail.py @@ -24,12 +24,12 @@ _collision_set_rotation = {} _collision_set_rotation[Direction.NORTH] = _left_turn _collision_set_rotation[Direction.NORTHEAST] = _right_turn -_collision_set_rotation[Direction.EAST] = _left_turn.rotate(2) -_collision_set_rotation[Direction.SOUTHEAST] = _right_turn.rotate(2) -_collision_set_rotation[Direction.SOUTH] = _left_turn.rotate(4) -_collision_set_rotation[Direction.SOUTHWEST] = _right_turn.rotate(4) -_collision_set_rotation[Direction.WEST] = _left_turn.rotate(6) -_collision_set_rotation[Direction.NORTHWEST] = _right_turn.rotate(6) +_collision_set_rotation[Direction.EAST] = _left_turn.rotate(4) +_collision_set_rotation[Direction.SOUTHEAST] = _right_turn.rotate(4) +_collision_set_rotation[Direction.SOUTH] = _left_turn.rotate(8) +_collision_set_rotation[Direction.SOUTHWEST] = _right_turn.rotate(8) +_collision_set_rotation[Direction.WEST] = _left_turn.rotate(12) +_collision_set_rotation[Direction.NORTHWEST] = _right_turn.rotate(12) _left_turn = CollisionSet( [AABB(0.25, 1.8, 1.75, 3.9), Rectangle((-0.375, -0.7175), 1.4, 5.45, -35)] @@ -40,12 +40,12 @@ _collision_set_rotation = {} _collision_set_rotation[Direction.NORTH] = _left_turn _collision_set_rotation[Direction.NORTHEAST] = _right_turn -_collision_set_rotation[Direction.EAST] = _left_turn.rotate(2) -_collision_set_rotation[Direction.SOUTHEAST] = _right_turn.rotate(2) -_collision_set_rotation[Direction.SOUTH] = _left_turn.rotate(4) -_collision_set_rotation[Direction.SOUTHWEST] = _right_turn.rotate(4) -_collision_set_rotation[Direction.WEST] = _left_turn.rotate(6) -_collision_set_rotation[Direction.NORTHWEST] = _right_turn.rotate(6) +_collision_set_rotation[Direction.EAST] = _left_turn.rotate(4) +_collision_set_rotation[Direction.SOUTHEAST] = _right_turn.rotate(4) +_collision_set_rotation[Direction.SOUTH] = _left_turn.rotate(8) +_collision_set_rotation[Direction.SOUTHWEST] = _right_turn.rotate(8) +_collision_set_rotation[Direction.WEST] = _left_turn.rotate(12) +_collision_set_rotation[Direction.NORTHWEST] = _right_turn.rotate(12) class LegacyCurvedRail(DoubleGridAlignedMixin, EightWayDirectionalMixin, Entity): diff --git a/draftsman/prototypes/legacy_straight_rail.py b/draftsman/prototypes/legacy_straight_rail.py index f68b2b3..fad848a 100644 --- a/draftsman/prototypes/legacy_straight_rail.py +++ b/draftsman/prototypes/legacy_straight_rail.py @@ -15,29 +15,29 @@ # TODO: currently hardcoded just for straight rail eps = 0.001 _vertical_collision = CollisionSet([AABB(-0.75, -1.0 + eps, 0.75, 1.0 - eps)]) -_horizontal_collision = _vertical_collision.rotate(2) +_horizontal_collision = _vertical_collision.rotate(4) _diagonal_collision = CollisionSet([Rectangle((-0.5, -0.5), 1.25, 1.40, 45)]) _collision_set_rotation = {} _collision_set_rotation[Direction.NORTH] = _vertical_collision -_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(2) +_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(4) _collision_set_rotation[Direction.EAST] = _horizontal_collision -_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(4) +_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(8) _collision_set_rotation[Direction.SOUTH] = _vertical_collision -_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-2) +_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-4) _collision_set_rotation[Direction.WEST] = _horizontal_collision _collision_set_rotation[Direction.NORTHWEST] = _diagonal_collision eps = 0.001 _vertical_collision = CollisionSet([AABB(-0.75, -1.0 + eps, 0.75, 1.0 - eps)]) -_horizontal_collision = _vertical_collision.rotate(2) +_horizontal_collision = _vertical_collision.rotate(4) _diagonal_collision = CollisionSet([Rectangle((-0.5, -0.5), 1.25, 1.40, 45)]) _collision_set_rotation = {} _collision_set_rotation[Direction.NORTH] = _vertical_collision -_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(2) +_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(4) _collision_set_rotation[Direction.EAST] = _horizontal_collision -_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(4) +_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(8) _collision_set_rotation[Direction.SOUTH] = _vertical_collision -_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-2) +_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-4) _collision_set_rotation[Direction.WEST] = _horizontal_collision _collision_set_rotation[Direction.NORTHWEST] = _diagonal_collision diff --git a/draftsman/prototypes/straight_rail.py b/draftsman/prototypes/straight_rail.py index 05f6776..94e7a4e 100644 --- a/draftsman/prototypes/straight_rail.py +++ b/draftsman/prototypes/straight_rail.py @@ -15,29 +15,29 @@ # TODO: currently hardcoded just for straight rail eps = 0.001 _vertical_collision = CollisionSet([AABB(-0.75, -1.0 + eps, 0.75, 1.0 - eps)]) -_horizontal_collision = _vertical_collision.rotate(2) +_horizontal_collision = _vertical_collision.rotate(4) _diagonal_collision = CollisionSet([Rectangle((-0.5, -0.5), 1.25, 1.40, 45)]) _collision_set_rotation = {} _collision_set_rotation[Direction.NORTH] = _vertical_collision -_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(2) +_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(4) _collision_set_rotation[Direction.EAST] = _horizontal_collision -_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(4) +_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(8) _collision_set_rotation[Direction.SOUTH] = _vertical_collision -_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-2) +_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-4) _collision_set_rotation[Direction.WEST] = _horizontal_collision _collision_set_rotation[Direction.NORTHWEST] = _diagonal_collision eps = 0.001 _vertical_collision = CollisionSet([AABB(-0.75, -1.0 + eps, 0.75, 1.0 - eps)]) -_horizontal_collision = _vertical_collision.rotate(2) +_horizontal_collision = _vertical_collision.rotate(4) _diagonal_collision = CollisionSet([Rectangle((-0.5, -0.5), 1.25, 1.40, 45)]) _collision_set_rotation = {} _collision_set_rotation[Direction.NORTH] = _vertical_collision -_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(2) +_collision_set_rotation[Direction.NORTHEAST] = _diagonal_collision.rotate(4) _collision_set_rotation[Direction.EAST] = _horizontal_collision -_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(4) +_collision_set_rotation[Direction.SOUTHEAST] = _diagonal_collision.rotate(8) _collision_set_rotation[Direction.SOUTH] = _vertical_collision -_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-2) +_collision_set_rotation[Direction.SOUTHWEST] = _diagonal_collision.rotate(-4) _collision_set_rotation[Direction.WEST] = _horizontal_collision _collision_set_rotation[Direction.NORTHWEST] = _diagonal_collision diff --git a/draftsman/utils.py b/draftsman/utils.py index 2c24512..0b69885 100644 --- a/draftsman/utils.py +++ b/draftsman/utils.py @@ -199,14 +199,14 @@ def rotate(self, amt: int) -> "AABB": :param amt: The amount to rotate, expressed as an increments of 45 degrees. """ - if amt % 2 != 0: - raise ValueError("Cannot rotate an AABB by 45 degree increments") + if amt % 4 != 0: + raise ValueError("Cannot rotate an AABB by anything other than 90 degree increments") # TODO: do this routine with a lookup table instead of float math and # min/max - rot_top_left = rotate_point(self.top_left, math.radians(amt * 45)) - rot_bot_right = rotate_point(self.bot_right, math.radians(amt * 45)) + rot_top_left = rotate_point(self.top_left, math.radians(amt * 22.5)) + rot_bot_right = rotate_point(self.bot_right, math.radians(amt * 22.5)) # top_left = Vector( # min(rot_top_left.x, rot_bot_right.x), min(rot_top_left.y, rot_bot_right.y) @@ -350,10 +350,10 @@ def rotate(self, amt: int) -> "Rectangle": degrees. """ return Rectangle( - rotate_point(self.position, math.radians(amt * 45)), + rotate_point(self.position, math.radians(amt * 22.5)), self.width, self.height, - self.angle + amt * 45, + self.angle + amt * 22.5, ) def __eq__(self, other: "Rectangle") -> bool: diff --git a/test/test_entity.py b/test/test_entity.py index e4691f6..bd17cc6 100644 --- a/test/test_entity.py +++ b/test/test_entity.py @@ -51,9 +51,12 @@ def test_set_tags(self): with pytest.raises(DataFormatError): container.tags = "incorrect" + # @pytest.mark.xfail(reason="issue 134 https://github.com/redruin1/factorio-draftsman/issues/134") def test_get_world_bounding_box(self): combinator = DeciderCombinator(tile_position=[3, 3], direction=Direction.EAST) - assert combinator.get_world_bounding_box() == AABB(3.65, 2.85, 4.35, 4.15) + assert combinator.get_world_bounding_box() == AABB(3.35, 3.15, 4.65, 3.85) + recycler = new_entity('recycler',tile_position=[3, 3], direction=Direction.EAST) + assert recycler.get_world_bounding_box() == AABB(3,3, 3.3, 6.7, 4.7) def test_set_name(self): iron_chest = Container("iron-chest") diff --git a/test/test_utils.py b/test/test_utils.py index 2a50100..09d17b7 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -90,7 +90,7 @@ def test_get_bounding_box(self): def test_rotate(self): aabb = utils.AABB(0, 0, 1, 1) - rotated_aabb = aabb.rotate(2) + rotated_aabb = aabb.rotate(4) assert round(abs(rotated_aabb.top_left[0] - -1), 7) == 0 assert round(abs(rotated_aabb.top_left[1] - 0), 7) == 0 assert round(abs(rotated_aabb.bot_right[0] - 0), 7) == 0