- self.actions = []
- if rank is None:
- rank = parent.rank if parent else 0.5
- for action, params in actions:
- # New bullets reset the parent hierarchy.
- self.actions.append(Action(self, None, action, params, rank))
+ self.rank = rank
+ self.tags = set(tags)
+ # New bullets reset the parent hierarchy.
+ self._actions = [Action(self, None, action, params, rank)
+ for action, params in actions]
+
+ @classmethod
+ def FromDocument(cls, doc, x=0, y=0, direction=0, speed=0, target=None,
+ params=(), rank=0.5, Action=Action):
+ """Construct a new Bullet from a loaded BulletML document."""
+ actions = [a(params, rank) for a in doc.actions]
+ return cls(x=x, y=y, direction=direction, speed=speed,
+ target=target, actions=actions, rank=rank, Action=Action)