def set_interaction_canceled(self, int_id, value): (int_info, _) = self._find_interaction(int_id) if int_info is not None: int_info.canceled = value interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), True) self._remove_routing_interaction_info(int_info)
def set_interaction_super_interaction(self, interaction, super_id): (int_info, queue_type) = self._find_interaction(interaction.id) if int_info is not None: int_info.super_id = self._get_super_id_for_mixer( super_id) or super_id interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), self._should_msg_be_immediate(queue_type))
def update_interaction_cancel_status(self, interaction): if not interaction.visible: return (int_info, _) = self._find_interaction(interaction.id) if int_info is not None: int_info.canceled = interaction.is_finishing int_info.user_cancelable = interaction.user_cancelable interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), True)
def running_transition(self, interaction): if not interaction.visible: return interaction_id = interaction.id for int_info in self._continuation_interactions: if int_info.interaction_id != interaction_id: continue int_info.ui_state = Sims_pb2.IQ_TRANSITIONING return int_info = None running_info_for_group = None previous_visible_group_info_id = None for (i, int_info) in enumerate(self._queued_interactions): if int_info.interaction_id != interaction_id: continue int_info.ui_state = Sims_pb2.IQ_TRANSITIONING next_index = i + 1 if next_index < len(self._queued_interactions): self._queued_interactions[next_index].insert_after_id = 0 previous_visible_group_info_id = self._get_visible_grouped_interaction_id( int_info.interaction_id) self._queued_interactions.remove(int_info) running_info_for_group = self._add_running_interaction(int_info) break else: logger.debug( 'SimId:{}, Interaction being marked as transitioning is not in queued interaction:{}', self._sim.id, interaction) return logger.debug('SimId:{}, Interaction being marked as transitioning:{}', self._sim.id, interaction) should_be_immediate = self._should_msg_be_immediate( self.QueueType.Super) if running_info_for_group is None or previous_visible_group_info_id is None: self._add_routing_interaction_info(int_info) if int_info.client_notified: interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), should_be_immediate) else: interaction_messages.send_interactions_add_msg( self._sim, (int_info, ), should_be_immediate) int_info.client_notified = True else: visible_int_info = running_info_for_group.pop() if int_info.client_notified: if visible_int_info is int_info: self._update_mixers(previous_visible_group_info_id, visible_int_info.interaction_id) interaction_messages.send_interactions_remove_msg( self._sim, (int_info, ), should_be_immediate) if visible_int_info is int_info: interaction_messages.send_interaction_replace_message( self._sim, previous_visible_group_info_id, int_info, should_be_immediate) int_info.client_notified = True
def transferred_to_si_state(self, interaction): self._update_skillbar_info(interaction) if not interaction.visible: return int_info = None if interaction.is_super: for cur_info in self._running_interactions: if cur_info.interaction_id == interaction.id: int_info = cur_info break if int_info is None: for cur_info in self._queued_interactions: if cur_info.interaction_id != interaction.id: continue if interaction.is_super: self.running_transition(interaction) else: self._queued_interactions.remove(cur_info) if cur_info.super_id != 0: cur_info.super_id = self._get_visible_grouped_interaction_id( cur_info.super_id) or cur_info.super_id self._add_running_interaction(cur_info) int_info = cur_info break if int_info is None: logger.debug( 'SimId:{}, Interaction Transfer To SI State could not find interaction to update:{}', self._sim.id, interaction) return logger.debug( 'SimId:{}, Interaction Transfer To SI State being marked as running:{}', self._sim.id, interaction) int_info.ui_state = Sims_pb2.IQ_RUNNING (int_info.ui_visual_type, visual_type_data) = interaction.get_interaction_queue_visual_type() if visual_type_data.icon is not None: int_info.set_icon_info( IconInfoData(icon_resource=visual_type_data.icon)) if visual_type_data.tooltip_text is not None: int_info.display_name = interaction.create_localized_string( visual_type_data.tooltip_text) force_remove = int_info.ui_visual_type == Sims_pb2.Interaction.POSTURE self._remove_routing_interaction_info(int_info, force_remove=force_remove) if int_info.visual_group_tag is None or self._get_visible_grouped_interaction_id( int_info.interaction_id) == int_info.interaction_id: if int_info.client_notified: interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), False) else: interaction_messages.send_interactions_add_msg( self._sim, (int_info, ), False) int_info.client_notified = True self._update_interaction_for_potential_cancel()
def set_interaction_icon_and_name(self, int_id, icon, name): (int_info, queue_type) = self._find_interaction(int_id) if int_info is not None: send_update = False if icon is not None: int_info.set_icon_info(icon) send_update = True if name is not None: int_info.display_name = name send_update = True if send_update: interaction_messages.send_interactions_update_msg(self._sim, (int_info,), self._should_msg_be_immediate(queue_type))
def _update_mixers(self, old_super_id, new_super_id): interaction_infos_to_update = [] for int_info in self._queued_interactions: if int_info.super_id == 0: pass if int_info.super_id != old_super_id: pass if int_info.super_id == new_super_id: pass int_info.super_id = new_super_id interaction_infos_to_update.append(int_info) if interaction_infos_to_update: interaction_messages.send_interactions_update_msg(self._sim, interaction_infos_to_update, self._should_msg_be_immediate(self.QueueType.Super))
def set_interaction_icon_and_name(self, int_id, icon, name): (int_info, queue_type) = self._find_interaction(int_id) if int_info is not None: send_update = False if icon is not None: int_info.set_icon_info(icon) send_update = True if name is not None: int_info.display_name = name send_update = True if send_update: interaction_messages.send_interactions_update_msg( self._sim, (int_info, ), self._should_msg_be_immediate(queue_type))
def _update_mixers(self, old_super_id, new_super_id): interaction_infos_to_update = [] for int_info in self._queued_interactions: if int_info.super_id == 0: continue if int_info.super_id != old_super_id: continue if int_info.super_id == new_super_id: continue int_info.super_id = new_super_id interaction_infos_to_update.append(int_info) if interaction_infos_to_update: interaction_messages.send_interactions_update_msg( self._sim, interaction_infos_to_update, self._should_msg_be_immediate(self.QueueType.Super))
def _update_interaction_for_potential_cancel(self): interaction_infos_to_update = set() for cur_info in self._super_interactions: if cur_info.interaction_id == interactions.base.interaction.ROUTING_POSTURE_INTERACTION_ID: pass interaction = self._sim.find_interaction_by_id(cur_info.interaction_id) if interaction is None: pass potential_canceled = SIState.potential_canceled_interaction_ids(interaction) if not cur_info.interactions_to_be_canceled.symmetric_difference(potential_canceled): pass cur_info.interactions_to_be_canceled = potential_canceled interaction_infos_to_update.add(cur_info) if interaction_infos_to_update: interaction_messages.send_interactions_update_msg(self._sim, interaction_infos_to_update, self._should_msg_be_immediate(self.QueueType.Super))
def transferred_to_si_state(self, interaction): self._update_skillbar_info(interaction) if not interaction.visible: return int_info = None if interaction.is_super: for cur_info in self._running_interactions: while cur_info.interaction_id == interaction.id: int_info = cur_info break if int_info is None: for cur_info in self._queued_interactions: if cur_info.interaction_id != interaction.id: pass if interaction.is_super: self.running_transition(interaction) else: self._queued_interactions.remove(cur_info) if cur_info.super_id != 0: cur_info.super_id = self._get_visible_grouped_interaction_id(cur_info.super_id) or cur_info.super_id self._add_running_interaction(cur_info) int_info = cur_info break if int_info is None: logger.debug('SimId:{}, Interaction Transfer To SI State could not find interaction to update:{}', self._sim.id, interaction) return logger.debug('SimId:{}, Interaction Transfer To SI State being marked as running:{}', self._sim.id, interaction) int_info.ui_state = Sims_pb2.IQ_RUNNING (int_info.ui_visual_type, visual_type_data) = interaction.get_interaction_queue_visual_type() if visual_type_data.icon is not None: int_info.set_icon_info((visual_type_data.icon, None)) if visual_type_data.tooltip_text is not None: int_info.display_name = interaction.create_localized_string(visual_type_data.tooltip_text) force_remove = int_info.ui_visual_type == Sims_pb2.Interaction.POSTURE self._remove_routing_interaction_info(int_info, force_remove=force_remove) if int_info.visual_group_tag is None or self._get_visible_grouped_interaction_id(int_info.interaction_id) == int_info.interaction_id: if int_info.client_notified: interaction_messages.send_interactions_update_msg(self._sim, (int_info,), False) else: interaction_messages.send_interactions_add_msg(self._sim, (int_info,), False) int_info.client_notified = True self._update_interaction_for_potential_cancel()
def running_transition(self, interaction): if not interaction.visible: return interaction_id = interaction.id for int_info in self._continuation_interactions: if int_info.interaction_id != interaction_id: pass int_info.ui_state = Sims_pb2.IQ_TRANSITIONING int_info = None running_info_for_group = None previous_visible_group_info_id = None for (i, int_info) in enumerate(self._queued_interactions): if int_info.interaction_id != interaction_id: pass int_info.ui_state = Sims_pb2.IQ_TRANSITIONING next_index = i + 1 if next_index < len(self._queued_interactions): self._queued_interactions[next_index].insert_after_id = 0 previous_visible_group_info_id = self._get_visible_grouped_interaction_id(int_info.interaction_id) self._queued_interactions.remove(int_info) running_info_for_group = self._add_running_interaction(int_info) break logger.debug('SimId:{}, Interaction being marked as transitioning is not in queued interaction:{}', self._sim.id, interaction) return logger.debug('SimId:{}, Interaction being marked as transitioning:{}', self._sim.id, interaction) should_be_immediate = self._should_msg_be_immediate(self.QueueType.Super) if running_info_for_group is None or previous_visible_group_info_id is None: self._add_routing_interaction_info(int_info) if int_info.client_notified: interaction_messages.send_interactions_update_msg(self._sim, (int_info,), should_be_immediate) else: interaction_messages.send_interactions_add_msg(self._sim, (int_info,), should_be_immediate) int_info.client_notified = True else: visible_int_info = running_info_for_group.pop() if int_info.client_notified: if visible_int_info is int_info: self._update_mixers(previous_visible_group_info_id, visible_int_info.interaction_id) interaction_messages.send_interactions_remove_msg(self._sim, (int_info,), should_be_immediate) if visible_int_info is int_info: interaction_messages.send_interaction_replace_message(self._sim, previous_visible_group_info_id, int_info, should_be_immediate) int_info.client_notified = True
def _update_interaction_for_potential_cancel(self): interaction_infos_to_update = set() for cur_info in self._super_interactions: if cur_info.interaction_id == interactions.base.interaction.ROUTING_POSTURE_INTERACTION_ID: continue interaction = self._sim.find_interaction_by_id( cur_info.interaction_id) if interaction is None: continue potential_canceled = SIState.potential_canceled_interaction_ids( interaction) if not cur_info.interactions_to_be_canceled.symmetric_difference( potential_canceled): continue cur_info.interactions_to_be_canceled = potential_canceled interaction_infos_to_update.add(cur_info) if interaction_infos_to_update: interaction_messages.send_interactions_update_msg( self._sim, interaction_infos_to_update, self._should_msg_be_immediate(self.QueueType.Super))
def set_interaction_super_interaction(self, interaction, super_id): (int_info, queue_type) = self._find_interaction(interaction.id) if int_info is not None: int_info.super_id = self._get_super_id_for_mixer(super_id) or super_id interaction_messages.send_interactions_update_msg(self._sim, (int_info,), self._should_msg_be_immediate(queue_type))
def set_interaction_canceled(self, int_id, value): (int_info, _) = self._find_interaction(int_id) if int_info is not None: int_info.canceled = value interaction_messages.send_interactions_update_msg(self._sim, (int_info,), True) self._remove_routing_interaction_info(int_info)