Verify that action tree is starting to work!

This commit is contained in:
Marek Wolan
2023-09-05 15:53:22 +01:00
parent ffe1e92664
commit 1dccceaf56
2 changed files with 35 additions and 3 deletions

View File

@@ -60,6 +60,9 @@ class Action(BaseModel):
"""
# TODO: maybe this can be renamed to something like action selector?
# Because there are two ways it's used, to select from a list of action verbs, or to select a child object to which to
# forward the request.
class ActionManager(BaseModel):
"""
ActionManager is used by `SimComponent` instances to keep track of actions.
@@ -132,14 +135,13 @@ class ActionManager(BaseModel):
self.actions.pop(name)
def get_action_tree(self) -> List[List[str]]:
"""Recursively generate action tree for this component."""
actions = []
for act_name, act in self.actions.items():
if isinstance(act.func, ActionManager):
sub_actions = act.func.get_action_tree()
sub_actions = [[act_name]+a for a in sub_actions]
sub_actions = [[act_name] + a for a in sub_actions]
actions.extend(sub_actions)
else:
actions.append([act_name])