-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(station) west square objects & bus stops, part II (#61)
- Loading branch information
Showing
32 changed files
with
3,427 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from dataclasses import dataclass | ||
from .symmetry import BuildingSymmetricalY, BuildingDiamond, BuildingCylindrical, BuildingDiagonalAlt, BuildingDiagonal | ||
|
||
|
||
@dataclass | ||
class SlopeType: | ||
value: int | ||
|
||
|
||
slope_types = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 23, 27, 29, 30] | ||
|
||
flat = BuildingCylindrical.create_variants([SlopeType(0)]) | ||
ortho = BuildingSymmetricalY.create_variants([SlopeType(3), SlopeType(6), SlopeType(12), SlopeType(9)]) | ||
para = BuildingDiamond.create_variants([SlopeType(5), SlopeType(10)]) | ||
mono = BuildingDiagonalAlt.create_variants([SlopeType(1), SlopeType(4), SlopeType(8), SlopeType(2)]) | ||
tri = BuildingDiagonal.create_variants([SlopeType(7), SlopeType(14), SlopeType(11), SlopeType(13)]) | ||
steep = BuildingDiagonal.create_variants([SlopeType(23), SlopeType(30), SlopeType(27), SlopeType(29)]) | ||
|
||
|
||
def make_slopes(sprites, sym): | ||
ret = {i: {} for i in sym.render_indices()} | ||
|
||
for slopeGroup in [flat, ortho, para, mono, tri, steep]: | ||
for slopeIndex, slopeType in zip(slopeGroup.render_indices(), slopeGroup.all_variants): | ||
for i in sym.render_indices(): | ||
for slopeIndex2, slopeType2 in zip(slopeGroup.render_indices(), slopeGroup.all_variants): | ||
if ( | ||
slopeType._symmetry_descriptor[slopeType.compose_symmetry_indices(slopeIndex2, i)] | ||
== slopeType._symmetry_descriptor[slopeIndex] | ||
): | ||
ret[i][slopeType.value] = sprites[slopeType2.value].symmetry_index(i) | ||
break | ||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from dataclasses import dataclass | ||
from symmetry import BuildingCylindrical, BuildingSymmetricalX, BuildingFull | ||
from agrf.lib.building.slope import make_slopes, slope_types | ||
|
||
|
||
@dataclass | ||
class MockObject: | ||
debug_id: int | ||
|
||
|
||
def test_cylindrical(): | ||
sprites = {i: BuildingCylindrical.create_variants([MockObject(i)]) for i in slope_types} | ||
ret = make_slopes(sprites, BuildingCylindrical) | ||
|
||
for i in slope_types: | ||
assert ret[0][i] is sprites[i] | ||
|
||
|
||
def test_x(): | ||
sprites = {i: BuildingSymmetricalX.create_variants([MockObject(i * 4 + j) for j in range(4)]) for i in slope_types} | ||
ret = make_slopes(sprites, BuildingSymmetricalX) | ||
|
||
for i in slope_types: | ||
assert ret[0][i] is sprites[i] | ||
for j in [1, 4, 5]: | ||
print(i, j) | ||
assert i in ret[j] | ||
assert ret[1][0] is sprites[0].M | ||
|
||
|
||
def test_full(): | ||
sprites = {i: BuildingFull.create_variants([MockObject(i * 8 + j) for j in range(8)]) for i in slope_types} | ||
ret = make_slopes(sprites, BuildingFull) | ||
|
||
for i in slope_types: | ||
assert ret[0][i] is sprites[i] | ||
for j in range(1, 8): | ||
assert i in ret[j] | ||
assert ret[1][1] is sprites[4].M | ||
assert ret[2][3] is sprites[12].R | ||
assert ret[1][3] is sprites[6].M | ||
assert ret[1][7] is sprites[7].M | ||
assert ret[2][7] is sprites[14].R | ||
assert ret[3][7] is sprites[14].R.M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .object import AObject | ||
from .switch import GraphicalSwitch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from agrf.magic import Switch | ||
from agrf.utils import unique_tuple | ||
|
||
|
||
class GraphicalSwitch(Switch): | ||
def __init__(self, code, ranges, default, *, feature=None, ref_id=None, related_scope=False, subroutines=None): | ||
super().__init__( | ||
code, ranges, default, feature=feature, ref_id=ref_id, related_scope=related_scope, subroutines=subroutines | ||
) | ||
|
||
@property | ||
def sprites(self): | ||
return unique_tuple([s for sw in [self.default] + [r.ref for r in self._ranges] for s in sw.sprites]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.