def normal_carry_callback(): arb = animation.arb.Arb() self.append_transition_to_arb(arb, source_posture, locked_params=locked_params, in_xevt_handler=True) distribute_arb_element(arb)
def event_handler_swap_carry(event_data): nonlocal got_callback if got_callback: logger.warn( 'Animation({}) calling to start a carry multiple times', event_data.event_data.get('clip_name')) return got_callback = True arb_exit = Arb() original_carry_posture.append_exit_to_arb(arb_exit, None, carry_nothing_posture, carry_nothing_var_map, exit_while_holding=True) carry_nothing_posture.append_transition_to_arb( arb_exit, original_carry_posture, in_xevt_handler=True) distribute_arb_element(arb_exit) original_carry_posture.target.transient = True original_carry_posture.target.clear_parent(sim.transform, sim.routing_surface) original_carry_posture.target.remove_from_client() arb_enter = Arb() locked_params = final_posture.get_locked_params(None) if carry_nothing_posture is not None: carry_nothing_posture.append_exit_to_arb( arb_enter, final_posture_state, final_posture, final_var_map) final_posture.append_transition_to_arb(arb_enter, carry_nothing_posture, locked_params=locked_params, in_xevt_handler=True) distribute_arb_element(arb_enter)
def normal_carry_callback(): arb = animation.arb.Arb() self.append_exit_to_arb(arb, dest_state, dest_posture, var_map, exit_while_holding=True) distribute_arb_element(arb)
def on_throw_impact(self, event_data): if self._throw_asm is None or self._finished: return if not self._finished and self.throw_impact_data.asm_state_name is not None: impact_arb = animation.arb.Arb(additional_blockers={self.sim}) self._throw_asm.request(self.throw_impact_data.asm_state_name, impact_arb) distribute_arb_element(impact_arb, master=self.target) self._finished = True
def start_posture_idle(*_, **__): nonlocal posture_idle_started if posture_idle_started: return dest.log_info('Idle') posture_idle_started = True idle_arb = animation.arb.Arb() dest.append_idle_to_arb(idle_arb) distribute_arb_element(idle_arb, master=sim)
def _on_linked_posture_exit(*_, **__): linked_arb = Arb() self._carried_linked_posture.append_exit_to_arb( linked_arb, *args, **kwargs) if destination_posture is not None: destination_posture.append_transition_to_arb( linked_arb, self._carried_linked_posture) destination_posture.append_idle_to_arb(linked_arb) distribute_arb_element(linked_arb, master=self.target)
def event_handler_exit_carry(event_data): nonlocal exited_carry exited_carry = True arb = Arb() old_carry_posture.append_exit_to_arb(arb, None, new_posture, var_map, exit_while_holding=True) new_posture.append_transition_to_arb(arb, old_carry_posture, in_xevt_handler=True) distribute_arb_element(arb, master=sim)
def _set_posture(self, *args, **kwargs): self._xevt_triggered = True from postures.posture_state import PostureState sim = self.interaction.sim self._previous_posture_state = sim.posture_state origin_posture_spec = get_origin_spec(self.posture_type) sim.posture_state = PostureState( sim, None, origin_posture_spec, {PostureSpecVariable.HAND: (Hand.LEFT, )}) sim.posture_state.body.source_interaction = sim.create_default_si() idle_arb = animation.arb.Arb() sim.posture.append_transition_to_arb(idle_arb, None) sim.posture.append_idle_to_arb(idle_arb) distribute_arb_element(idle_arb, master=sim)
def execute(self, actor, path=None): previous_posture_state = actor.posture_state origin_posture_spec = get_origin_spec(self.posture_type) var_map = {PostureSpecVariable.HAND: Hand.LEFT} carry_posture_overrides = {previous_posture_state.left.track: previous_posture_state.left, previous_posture_state.right.track: previous_posture_state.right} actor.posture_state = PostureState(actor, actor.posture_state, origin_posture_spec, var_map, carry_posture_overrides=carry_posture_overrides) actor.posture_state.body.source_interaction = actor.create_default_si() final_routing_surface = path.final_location.routing_surface idle_arb = animation.arb.Arb() actor.posture.append_transition_to_arb(idle_arb, None) actor.posture.append_idle_to_arb(idle_arb) distribute_arb_element(idle_arb, master=actor) running_interaction = actor.queue.running if running_interaction is not None: running_interaction.satisfied = True def kickstart_posture(_timeline): result = yield from actor.posture_state.body.kickstart_gen(_timeline, actor.posture_state, final_routing_surface) return result yield def end_body_aspect(_timeline): if previous_posture_state.body: result = yield from element_utils.run_child(_timeline, previous_posture_state.body.end()) if not result: return result yield return True yield timeline = services.time_service().sim_timeline.get_sub_timeline() element = element_utils.build_element(actor.posture.get_idle_behavior()) timeline.schedule(element) if not timeline.simulate(timeline.now): logger.error('Failed trying to run idle behavior on Sim {} during a set posture route event.', actor) element = element_utils.build_element(flush_all_animations) timeline.schedule(element) if not timeline.simulate(timeline.now): logger.error('Failed trying to flush animations on Sim {} during a set posture route event.', actor) element = element_utils.build_element(kickstart_posture) timeline.schedule(element) if not timeline.simulate(timeline.now): logger.error('Failed trying to kickstart a posture on Sim {} during a set posture route event.', actor) element = element_utils.build_element(end_body_aspect) timeline.schedule(element) if not timeline.simulate(timeline.now): logger.error('Failed trying to end previous body aspect on Sim {} during a set posture route event.', actor)
def update_overlay(self): def restart_overlay_asm(asm): asm.set_current_state('entry') return True if self._overlay_interaction is None: return overlay_animation = self._overlay_animation( self._overlay_interaction, setup_asm_additional=restart_overlay_asm, enable_auto_exit=False) asm = overlay_animation.get_asm() if asm is None: logger.warn(' Unable to get a valid overlay ASM ({}) for {}.', self._overlay_animation, self._sim) return arb = Arb() overlay_animation.append_to_arb(asm, arb) distribute_arb_element(arb)
def event_handler_enter_carry(event_data): nonlocal got_callback if got_callback: logger.warn( 'Animation({}) calling to start a carry multiple times', event_data.event_data.get('clip_name')) return got_callback = True arb = Arb() locked_params = new_posture.get_locked_params(None) old_carry_posture = sim.posture_state.get_aspect(track) if old_carry_posture is not None: old_carry_posture.append_exit_to_arb(arb, new_posture_state, new_posture, var_map) new_posture.append_transition_to_arb(arb, old_carry_posture, locked_params=locked_params, in_xevt_handler=True) distribute_arb_element(arb)
def add_arb(self, arb, on_done_fn=None): if isinstance(arb, list): arbs = arb else: arbs = (arb,) for sub_arb in arbs: if not sub_arb._actors(): logger.error('Attempt to play animation that has no connected actors:') sub_arb.log_request_history(dump_logger.error) if self._in_flush: for sub_arb in arbs: logger.debug('\n\nEvent-triggered ARB:\n{}\n\n', sub_arb.get_contents_as_string()) distribute_arb_element(sub_arb) if on_done_fn is not None: on_done_fn() return self._arb_sequence.append(arb) if on_done_fn is not None: self._on_done.append(on_done_fn)
def process(self, actor): if self.arb is not None: distribute_arb_element(self.arb, master=actor, immediate=True)
def _event_handler_start_pose(self, *args, **kwargs): arb = animation.arb.Arb() self.asm.request(self._state_name, arb) distribute_arb_element(arb)
def start_carry(*_, **__): idle_arb = animation.arb.Arb() carry_posture.asm.request(carry_posture._state_name, idle_arb) distribute_arb_element(idle_arb)
def _send_arb(timeline): route_event_animation.append_to_arb(asm, self.arb) route_event_animation.append_exit_to_arb(asm, self.arb) distribute_arb_element(self.arb, master=actor, immediate=True) return True