from tdw.add_ons.composite_object_manager import CompositeObjectManager
Manager add-on for static and dynamic composite object data.
Note that some useful information, such as the positions, rotations, names, of the objects, is not included here. See: ObjectManager
.
-
static
A dictionary ofCompositeObjectStatic
data that is set when this add-on intializes. Key = The object ID. -
dynamic
A dictionary ofCompositeObjectDynamic
data that is set per-frame. Key = The object ID. -
commands
These commands will be appended to the commands of the nextcommunicate()
call. -
initialized
If True, this module has been initialized.
CompositeObjectManager()
(no parameters)
self.get_initialization_commands()
This function gets called exactly once per add-on. To re-initialize, set self.initialized = False
.
Returns: A list of commands that will initialize this add-on.
self.on_send(resp)
This is called within Controller.communicate(commands)
after commands are sent to the build and a response is received.
Use this function to send commands to the build on the next Controller.communicate(commands)
call, given the resp
response.
Any commands in the self.commands
list will be sent on the next Controller.communicate(commands)
call.
Parameter | Type | Default | Description |
---|---|---|---|
resp | List[bytes] | The response from the build. |
self.before_send(commands)
This is called within Controller.communicate(commands)
before sending commands to the build. By default, this function doesn't do anything.
Parameter | Type | Default | Description |
---|---|---|---|
commands | List[dict] | The commands that are about to be sent to the build. |
self.get_early_initialization_commands()
This function gets called exactly once per add-on. To re-initialize, set self.initialized = False
.
These commands are added to the list being sent on communicate()
before any other commands, including those added by the user and by other add-ons.
Usually, you shouldn't override this function. It is useful for a small number of add-ons, such as loading screens, which should initialize before anything else.
Returns: A list of commands that will initialize this add-on.
self.is_open(object_id, sub_object_id)
self.is_open(object_id, sub_object_id, open_at=30)
Parameter | Type | Default | Description |
---|---|---|---|
object_id | int | The ID of the root object. | |
sub_object_id | int | The ID of one of the root object's hinges, motors, or springs. | |
open_at | float | 30 | A threshold of 'openness' in degrees. If the sub-object's angle is greater than or equal to this, it is considered 'open'. |
Returns: True if the hinge, motor, or spring is open.
self.reset()
Reset this add-on. Call this when resetting the scene.