sm-blueprint-lib 0.0.12__py3-none-any.whl → 0.0.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sm_blueprint_lib/__init__.py +7 -0
- sm_blueprint_lib/bases/__init__.py +3 -0
- sm_blueprint_lib/bases/controllers/__init__.py +5 -0
- sm_blueprint_lib/bases/controllers/sensorcontroller.py +2 -2
- sm_blueprint_lib/bases/joints/__init__.py +6 -0
- sm_blueprint_lib/bases/joints/pistonjoint.py +2 -1
- sm_blueprint_lib/bases/joints/suspensionjoint.py +2 -1
- sm_blueprint_lib/bases/parts/__init__.py +4 -0
- sm_blueprint_lib/bases/parts/baseboundablepart.py +1 -4
- sm_blueprint_lib/bases/parts/baseinteractablepart.py +3 -0
- sm_blueprint_lib/bases/parts/baselogicpart.py +1 -3
- sm_blueprint_lib/bases/parts/basepart.py +22 -3
- sm_blueprint_lib/blueprint.py +12 -2
- sm_blueprint_lib/body.py +4 -0
- sm_blueprint_lib/constants.py +1064 -17
- sm_blueprint_lib/id.py +3 -0
- sm_blueprint_lib/parts/__init__.py +4 -0
- sm_blueprint_lib/parts/barrierblock.py +3 -1
- sm_blueprint_lib/parts/bearing.py +3 -1
- sm_blueprint_lib/parts/block.py +12 -0
- sm_blueprint_lib/parts/button.py +3 -1
- sm_blueprint_lib/parts/logicgate.py +3 -1
- sm_blueprint_lib/parts/piston.py +31 -1
- sm_blueprint_lib/parts/sensor.py +38 -2
- sm_blueprint_lib/parts/suspension.py +62 -2
- sm_blueprint_lib/parts/switch.py +3 -1
- sm_blueprint_lib/parts/timer.py +3 -1
- sm_blueprint_lib/rot.py +17 -0
- sm_blueprint_lib/utils.py +192 -0
- {sm_blueprint_lib-0.0.12.dist-info → sm_blueprint_lib-0.0.13.dist-info}/METADATA +3 -2
- sm_blueprint_lib-0.0.13.dist-info/RECORD +56 -0
- sm_blueprint_lib-0.0.12.dist-info/RECORD +0 -50
- {sm_blueprint_lib-0.0.12.dist-info → sm_blueprint_lib-0.0.13.dist-info}/WHEEL +0 -0
- {sm_blueprint_lib-0.0.12.dist-info → sm_blueprint_lib-0.0.13.dist-info}/licenses/LICENSE +0 -0
sm_blueprint_lib/__init__.py
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
"""
|
2
|
+
# sm_blueprint_lib
|
3
|
+
asdasdasdasds
|
4
|
+
"""
|
5
|
+
|
1
6
|
from .blueprint import *
|
2
7
|
from .body import *
|
3
8
|
from .bounds import *
|
@@ -8,3 +13,5 @@ from .utils import *
|
|
8
13
|
|
9
14
|
from .parts import *
|
10
15
|
from .prebuilds import *
|
16
|
+
from .rot import *
|
17
|
+
from .bases import *
|
@@ -7,7 +7,7 @@ from .basecontroller import BaseController
|
|
7
7
|
class SensorController(BaseController):
|
8
8
|
"""Sensor's Controller
|
9
9
|
"""
|
10
|
-
|
10
|
+
audioEnabled: bool
|
11
11
|
buttonMode: bool
|
12
12
|
color: str
|
13
13
|
colorMode: bool
|
@@ -19,6 +19,6 @@ class SensorController(BaseController):
|
|
19
19
|
if not isinstance(self.color, str):
|
20
20
|
self.color = "%02X%02X%02X" % (
|
21
21
|
self.color[0], self.color[1], self.color[2])
|
22
|
-
self.
|
22
|
+
self.audioEnabled = bool(self.audioEnabled)
|
23
23
|
self.buttonMode = bool(self.buttonMode)
|
24
24
|
self.colorMode = bool(self.colorMode)
|
@@ -10,4 +10,5 @@ class PistonJoint(BaseJoint):
|
|
10
10
|
|
11
11
|
def __post_init__(self):
|
12
12
|
super().__post_init__()
|
13
|
-
|
13
|
+
if not isinstance(self.controller, PistonJointController):
|
14
|
+
self.controller = PistonJointController(**self.controller)
|
@@ -10,4 +10,5 @@ class SuspensionJoin(BaseJoint):
|
|
10
10
|
|
11
11
|
def __post_init__(self):
|
12
12
|
super().__post_init__()
|
13
|
-
|
13
|
+
if not isinstance(self.controller, SuspensionJointController):
|
14
|
+
self.controller = SuspensionJointController(**self.controller)
|
@@ -2,16 +2,13 @@ from dataclasses import dataclass, field
|
|
2
2
|
|
3
3
|
from .basepart import BasePart
|
4
4
|
from ...bounds import Bounds
|
5
|
-
from ...constants import AXIS
|
6
5
|
|
7
6
|
|
8
7
|
@dataclass
|
9
8
|
class BaseBoundablePart(BasePart):
|
10
9
|
"""Base class for all Boundable parts (those that are draggable)
|
11
10
|
"""
|
12
|
-
bounds: Bounds
|
13
|
-
xaxis: int = field(kw_only=True, default=AXIS.DEFAULT_XAXIS)
|
14
|
-
zaxis: int = field(kw_only=True, default=AXIS.DEFAULT_ZAXIS)
|
11
|
+
bounds: Bounds = field(kw_only=True, default=(1,1,1))
|
15
12
|
|
16
13
|
def __post_init__(self):
|
17
14
|
super().__post_init__()
|
@@ -3,6 +3,7 @@ from dataclasses import dataclass, field
|
|
3
3
|
from ..controllers.basecontroller import BaseController
|
4
4
|
from .basepart import BasePart
|
5
5
|
from ...id import ID
|
6
|
+
from ...constants import AXIS
|
6
7
|
|
7
8
|
|
8
9
|
@dataclass
|
@@ -10,6 +11,8 @@ class BaseInteractablePart(BasePart):
|
|
10
11
|
"""Base class for Interactable parts
|
11
12
|
"""
|
12
13
|
controller: BaseController = field(default_factory=BaseController)
|
14
|
+
xaxis: int = field(kw_only=True, default=AXIS.DEFAULT_XAXIS_INTERACTABLE)
|
15
|
+
zaxis: int = field(kw_only=True, default=AXIS.DEFAULT_ZAXIS_INTERACTABLE)
|
13
16
|
|
14
17
|
def connect(self, o: "BaseInteractablePart"):
|
15
18
|
if not self.controller.controllers:
|
@@ -8,6 +8,4 @@ from ..controllers.baselogiccontroller import BaseLogicController
|
|
8
8
|
class BaseLogicPart(BaseInteractablePart):
|
9
9
|
"""Base class for Logic parts with active state (mostly Logic Gate and Timer)
|
10
10
|
"""
|
11
|
-
controller: BaseLogicController = field(default_factory=BaseLogicController)
|
12
|
-
xaxis: int = field(kw_only=True, default=1)
|
13
|
-
zaxis: int = field(kw_only=True, default=-2)
|
11
|
+
controller: BaseLogicController = field(default_factory=BaseLogicController)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from dataclasses import dataclass, field
|
2
2
|
from typing import Optional
|
3
3
|
|
4
|
-
from ...constants import AXIS,
|
4
|
+
from ...constants import ROTATION, SHAPEID, AXIS, COLOR
|
5
5
|
from ...pos import Pos
|
6
6
|
from ...id import ID
|
7
7
|
|
@@ -12,7 +12,7 @@ class BasePart:
|
|
12
12
|
"""
|
13
13
|
shapeId: str
|
14
14
|
pos: Pos
|
15
|
-
color: str
|
15
|
+
color: str = field(kw_only=True, default=COLOR.DEFAULT)
|
16
16
|
joints: Optional[list[ID]] = field(kw_only=True, default=None)
|
17
17
|
xaxis: int = field(kw_only=True, default=AXIS.DEFAULT_XAXIS)
|
18
18
|
zaxis: int = field(kw_only=True, default=AXIS.DEFAULT_ZAXIS)
|
@@ -24,12 +24,16 @@ class BasePart:
|
|
24
24
|
self.pos = Pos(**self.pos)
|
25
25
|
except TypeError:
|
26
26
|
self.pos = Pos(self.pos[0], self.pos[1], self.pos[2])
|
27
|
+
|
27
28
|
# if color given as (r, g, b) then convert to hex string
|
28
29
|
if not isinstance(self.color, str):
|
29
30
|
self.color = "%02X%02X%02X" % (
|
30
31
|
self.color[0], self.color[1], self.color[2])
|
31
32
|
if self.joints:
|
32
|
-
self.joints = [ID(**id)
|
33
|
+
self.joints = [ID(**id)
|
34
|
+
if not isinstance(id, ID) else
|
35
|
+
id
|
36
|
+
for id in self.joints]
|
33
37
|
|
34
38
|
def __init_subclass__(cls):
|
35
39
|
super().__init_subclass__()
|
@@ -37,3 +41,18 @@ class BasePart:
|
|
37
41
|
SHAPEID.SHAPEID_TO_CLASS[cls.shapeId.default] = cls
|
38
42
|
except AttributeError:
|
39
43
|
pass
|
44
|
+
|
45
|
+
def rotate(self, facing: ROTATION.FACING, rotated: ROTATION.ROTATED):
|
46
|
+
"""Sets the rotation of a Part.
|
47
|
+
|
48
|
+
Args:
|
49
|
+
facing (ROTATION.FACING): String indicating facing direction of the Part.
|
50
|
+
rotated (ROTATION.ROTATED): String indicating rotated direction of the face.
|
51
|
+
"""
|
52
|
+
x, y, z, x_axis, z_axis = ROTATION.ROTATION_TABLE[facing][rotated]
|
53
|
+
self.pos.x += x
|
54
|
+
self.pos.y += y
|
55
|
+
self.pos.z += z
|
56
|
+
self.xaxis = x_axis
|
57
|
+
self.zaxis = z_axis
|
58
|
+
return self
|
sm_blueprint_lib/blueprint.py
CHANGED
@@ -9,14 +9,24 @@ from .constants import VERSION, SHAPEID
|
|
9
9
|
|
10
10
|
@dataclass
|
11
11
|
class Blueprint:
|
12
|
+
"""Class that represents a Blueprint structure.
|
13
|
+
It is type hinted, meaning you can access its members
|
14
|
+
with the dot syntax instead of direcly indexing a JSON object.
|
15
|
+
"""
|
12
16
|
bodies: list[Body] = field(default_factory=lambda: [{}])
|
13
17
|
joints: Optional[list[BaseJoint]] = None
|
14
18
|
version: int = VERSION.BLUEPRINT_VERSION
|
15
19
|
|
16
20
|
def __post_init__(self):
|
17
|
-
self.bodies = [Body(**body)
|
21
|
+
self.bodies = [Body(**body)
|
22
|
+
if not isinstance(body, Body) else
|
23
|
+
body
|
24
|
+
for body in self.bodies]
|
18
25
|
if self.joints:
|
19
|
-
self.joints = [SHAPEID.JOINT_TO_CLASS[j["shapeId"]](**j)
|
26
|
+
self.joints = [SHAPEID.JOINT_TO_CLASS[j["shapeId"]](**j)
|
27
|
+
if not isinstance(j, BaseJoint) else
|
28
|
+
j
|
29
|
+
for j in self.joints]
|
20
30
|
|
21
31
|
def add(self, *obj, body=0):
|
22
32
|
"""Adds the object(s) to the blueprint.
|
sm_blueprint_lib/body.py
CHANGED
@@ -6,8 +6,12 @@ from .constants import SHAPEID
|
|
6
6
|
|
7
7
|
@dataclass
|
8
8
|
class Body:
|
9
|
+
"""Class that represents a Body inside a Blueprint, each Joint defines a new Body.
|
10
|
+
"""
|
9
11
|
childs: list[BasePart] = field(default_factory=list)
|
10
12
|
|
11
13
|
def __post_init__(self):
|
12
14
|
self.childs = [SHAPEID.SHAPEID_TO_CLASS[child["shapeId"]](**child)
|
15
|
+
if not isinstance(child, BasePart) else
|
16
|
+
child
|
13
17
|
for child in self.childs]
|