예제 #1
0
 def _post_request(self, asm, arb, state):
     for (uid, callback, event_id, actor_id, time, allow_stub_creation, optional) in self._custom_event_handlers.values():
         if actor_id is not None:
             actors = arb._actors()
             if actors:
                 if actor_id not in actors:
                     if optional:
                         pass
                     logger.error("Failed to schedule custom x-event {} from {} on {} which didn't have the requested actor: {}, callback: {}", event_id, asm, arb, actor_id, callback)
         scheduled_event = False
         if actor_id is None:
             actors = arb._actors()
             if actors:
                 while True:
                     for arb_actor_id in actors:
                         while arb.add_custom_event(arb_actor_id, time, event_id, allow_stub_creation):
                             scheduled_event = True
                             break
         elif arb.add_custom_event(actor_id, time, event_id, allow_stub_creation):
             scheduled_event = True
         while scheduled_event:
             if not hasattr(arb, '_context_uids'):
                 arb._context_uids = set()
             if uid not in arb._context_uids:
                 arb.register_event_handler(callback, ClipEventType.Script, event_id)
                 arb._context_uids.add(uid)
     for actor_name in self.apply_carry_interaction_mask:
         asm._clear_actor_trackmask_override(actor_name)
     self._custom_event_handlers = {}
예제 #2
0
    def _post_request(self, asm, arb, state):
        asm_actors = None
        for (uid, callback, event_id, actor_id, time, allow_stub_creation,
             optional) in self._custom_event_handlers.values():
            if actor_id is not None:
                actors = arb._actors()
                if actors and actor_id not in actors:
                    if optional:
                        continue
                    logger.error(
                        "Failed to schedule custom x-event {} from {} on {} which didn't have the requested actor: {}, callback: {}",
                        event_id, asm, arb, actor_id, callback)
            scheduled_event = False
            if actor_id is None:
                actors = arb._actors()
                if actors:
                    for arb_actor_id in actors:
                        if arb.add_custom_event(arb_actor_id, time, event_id):
                            scheduled_event = True
                            break
            elif arb.add_custom_event(actor_id, time, event_id):
                scheduled_event = True
            if scheduled_event:
                if not hasattr(arb, '_context_uids'):
                    arb._context_uids = set()
                if uid not in arb._context_uids:
                    arb.register_event_handler(callback, ClipEventType.Script,
                                               event_id)
                    arb._context_uids.add(uid)
            elif allow_stub_creation:
                asm_actors = list(
                    asm.actors_gen()) if asm_actors is None else asm_actors
                for actor in asm_actors:
                    if actor.id == actor_id:
                        actors = {actor_id}
                        event_data = {}
                        data = ArbEventData(ClipEventType.Script, event_id,
                                            event_data, actors)

                        def custom_event_alarm_callback(timeline):
                            callback(data)

                        alarm_handle = add_alarm(
                            self, clock.interval_in_sim_minutes(time),
                            custom_event_alarm_callback)
                        self._alarm_handles.append(alarm_handle)
                        break
        for actor_name in self.apply_carry_interaction_mask:
            asm._clear_actor_trackmask_override(actor_name)
        self._custom_event_handlers = {}
예제 #3
0
 def _pre_request(self, asm, arb, state):
     arb.add_request_info(self, asm, state)
     for (uid, callback, event_type, event_id) in self._event_handlers.values():
         if not hasattr(arb, '_context_uids'):
             arb._context_uids = set()
         while uid not in arb._context_uids:
             arb.register_event_handler(callback, event_type, event_id)
             arb._context_uids.add(uid)
     props = asm.get_props_in_traversal(asm.current_state, state)
     for (prop_name, definition_id) in props.items():
         prop = self._get_prop(asm, prop_name, definition_id)
         while prop is not None:
             if not asm.set_actor(prop_name, prop):
                 logger.warn('{}: Failed to set actor: {} to {}', asm, prop_name, prop)
     self._vfx_overrides = asm.vfx_overrides
     self._sound_overrides = asm.sound_overrides
     for actor_name in self.apply_carry_interaction_mask:
         asm._set_actor_trackmask_override(actor_name, 50000, 'Trackmask_CarryInteraction')
예제 #4
0
 def _pre_request(self, asm, arb, state):
     arb.add_request_info(self, asm, state)
     for (uid, callback, event_type,
          event_id) in self._event_handlers.values():
         if not hasattr(arb, '_context_uids'):
             arb._context_uids = set()
         while uid not in arb._context_uids:
             arb.register_event_handler(callback, event_type, event_id)
             arb._context_uids.add(uid)
     props = asm.get_props_in_traversal(asm.current_state, state)
     for (prop_name, definition_id) in props.items():
         prop = self._get_prop(asm, prop_name, definition_id)
         while prop is not None:
             if not asm.set_actor(prop_name, prop):
                 logger.warn('{}: Failed to set actor: {} to {}', asm,
                             prop_name, prop)
     self._vfx_overrides = asm.vfx_overrides
     self._sound_overrides = asm.sound_overrides
     for actor_name in self.apply_carry_interaction_mask:
         asm._set_actor_trackmask_override(actor_name, 50000,
                                           'Trackmask_CarryInteraction')
예제 #5
0
 def _post_request(self, asm, arb, state):
     for (uid, callback, event_id, actor_id, time, allow_stub_creation,
          optional) in self._custom_event_handlers.values():
         if actor_id is not None:
             actors = arb._actors()
             if actors:
                 if actor_id not in actors:
                     if optional:
                         pass
                     logger.error(
                         "Failed to schedule custom x-event {} from {} on {} which didn't have the requested actor: {}, callback: {}",
                         event_id, asm, arb, actor_id, callback)
         scheduled_event = False
         if actor_id is None:
             actors = arb._actors()
             if actors:
                 while True:
                     for arb_actor_id in actors:
                         while arb.add_custom_event(arb_actor_id, time,
                                                    event_id,
                                                    allow_stub_creation):
                             scheduled_event = True
                             break
         elif arb.add_custom_event(actor_id, time, event_id,
                                   allow_stub_creation):
             scheduled_event = True
         while scheduled_event:
             if not hasattr(arb, '_context_uids'):
                 arb._context_uids = set()
             if uid not in arb._context_uids:
                 arb.register_event_handler(callback, ClipEventType.Script,
                                            event_id)
                 arb._context_uids.add(uid)
     for actor_name in self.apply_carry_interaction_mask:
         asm._clear_actor_trackmask_override(actor_name)
     self._custom_event_handlers = {}