def dialog_show(self, dialog, phone_ring_type, auto_response=DEFAULT, caller_id=None, immediate=False, **kwargs): if not self._enabled: return self._active_dialogs[dialog.dialog_id] = dialog if dialog.has_responses() and self.auto_respond: def auto_respond_callback(_): dialog.do_auto_respond(auto_response=auto_response) del self._auto_respond_alarm_handles[dialog.dialog_id] self._auto_respond_alarm_handles[dialog.dialog_id] = alarms.add_alarm(self, TimeSpan.ZERO, auto_respond_callback) return dialog_msg = dialog.build_msg(**kwargs) if phone_ring_type != PhoneRingType.NO_RING: if not self._is_phone_silenced: game_clock_services = services.game_clock_service() if game_clock_services.clock_speed != ClockSpeedMode.PAUSED: game_clock_services.set_clock_speed(ClockSpeedMode.NORMAL) msg_type = Consts_pb2.MSG_UI_PHONE_RING msg_data = Dialog_pb2.UiPhoneRing() msg_data.phone_ring_type = phone_ring_type msg_data.dialog = dialog_msg if caller_id is not None: msg_data.caller_id = caller_id distributor = Distributor.instance() distributor.add_event(msg_type, msg_data) else: msg_type = dialog.DIALOG_MSG_TYPE msg_data = dialog_msg dialog.distribute_dialog(msg_type, msg_data, immediate=immediate)
def build_msg(self, **kwargs): message = super().build_msg(**kwargs) message.dialog_type = Dialog_pb2.UiDialogMessage.MULTI_PICKER if self.text_input is not None: text_input_overrides = {} (text_name, text) = self.existing_text text_input_overrides = {} if text: text_input_overrides[text_name] = lambda *_, **__: LocalizationHelperTuning.get_raw_text(text) self.text_input.build_msg(self, message, name=text_name, text_input_overrides=text_input_overrides if text_input_overrides else None) context = InteractionContext(self._owner(), InteractionSource.SCRIPT, Priority.Low) multi_picker_msg = Dialog_pb2.UiDialogMultiPicker() for picker_data in self.pickers: aop = AffordanceObjectPair(picker_data.picker_interaction, None, picker_data.picker_interaction, None) result = aop.interaction_factory(context) if not result: continue interaction = result.interaction picker_tuning = picker_data.picker_interaction.picker_dialog if picker_tuning.title is None: title = lambda *_, **__: interaction.get_name(apply_name_modifiers=False) else: title = self.picker_dialog.title dialog = picker_tuning(self._owner(), title=title, resolver=interaction.get_resolver(context=context)) interaction._setup_dialog(dialog) dialog.add_listener(interaction._on_picker_selected) self._picker_dialogs[dialog.dialog_id] = dialog new_message = dialog.build_msg() multi_picker_item = multi_picker_msg.multi_picker_items.add() multi_picker_item.picker_data = new_message.picker_data multi_picker_item.picker_id = new_message.dialog_id multi_picker_item.disabled_tooltip = picker_data.disabled_tooltip message.multi_picker_data = multi_picker_msg return message
def ui_dialog_multi_picker_result(dialog_id: int, multi_picker_proto: str, _connection=None): response_proto = Dialog_pb2.MultiPickerResponse() text_format.Merge(multi_picker_proto, response_proto) ui_dialog_service = services.ui_dialog_service() if ui_dialog_service is not None: dialog = ui_dialog_service.get_dialog(dialog_id) if dialog is not None: dialog.multi_picker_result(response_proto)
def build_msg(self, row_data=[], additional_tokens=(), **kwargs): msg = super().build_msg(additional_tokens=additional_tokens, **kwargs) msg.dialog_type = Dialog_pb2.UiDialogMessage.INFO_IN_COLUMNS sim_info = self.owner.sim_info msg.override_sim_icon_id = self.owner.id if self.owner is not None else 0 if sim_info is None: logger.error('Sim Info was None for {}', self._target_sim_id) return msg info_columns_msg = Dialog_pb2.UiDialogInfoInColumns() for column_header in self.column_headers: info_columns_msg.column_headers.append(column_header(sim_info)) for row in row_data: row_data_msg = Dialog_pb2.UiDialogRowData() for (icon, icon_name, icon_description) in row: icon_data = IconInfoData(icon_resource=icon) icon_info_msg = create_icon_info_msg(icon_data, name=icon_name, desc=icon_description) row_data_msg.column_info.append(icon_info_msg) info_columns_msg.rows.append(row_data_msg) msg.info_in_columns_data = info_columns_msg return msg
def build_msg(self, additional_tokens=(), trait_overrides_for_baby=None, gender_overrides_for_baby=None, **kwargs): msg = Dialog_pb2.SimPersonalityAssignmentDialog() msg.sim_id = self._assignment_sim_info.id dialog_msg = super().build_msg(additional_tokens=additional_tokens, **kwargs) msg.dialog = dialog_msg msg.secondary_title = self._build_localized_string_msg(self.secondary_title, *additional_tokens) msg.age_description = self._build_localized_string_msg(self.age_description, *additional_tokens) if self.naming_title_text is not None: msg.naming_title_text = self._build_localized_string_msg(self.naming_title_text, *additional_tokens) if gender_overrides_for_baby is None: gender = self._assignment_sim_info.gender else: gender = gender_overrides_for_baby msg.is_female = gender == Gender.FEMALE if self.aspirations_and_trait_assignment is not None: msg.aspirations_and_trait_assignment_text = self._build_localized_string_msg(self.aspirations_and_trait_assignment, *additional_tokens) if trait_overrides_for_baby is None: empty_slots = self._assignment_sim_info.trait_tracker.empty_slot_number current_personality_traits = self._assignment_sim_info.trait_tracker.personality_traits else: empty_slots = 0 current_personality_traits = trait_overrides_for_baby msg.available_trait_slots = empty_slots for current_personality_trait in current_personality_traits: msg.current_personality_trait_ids.append(current_personality_trait.guid64) msg.available_trait_slots = empty_slots if empty_slots != 0: for trait in services.trait_manager().types.values(): if not trait.is_personality_trait: pass if not trait.test_sim_info(self._assignment_sim_info): pass for current_personality_trait in current_personality_traits: while trait.guid64 == current_personality_trait.guid64 or trait.is_conflicting(current_personality_trait): break msg.available_personality_trait_ids.append(trait.guid64) if trait_overrides_for_baby is None and (self._assignment_sim_info.is_child or self._assignment_sim_info.is_teen): aspiration_track_manager = services.get_instance_manager(sims4.resources.Types.ASPIRATION_TRACK) while True: for aspiration_track in aspiration_track_manager.types.values(): if aspiration_track.is_child_aspiration_track: if self._assignment_sim_info.is_child: msg.available_aspiration_ids.append(aspiration_track.guid64) while self._assignment_sim_info.is_teen: msg.available_aspiration_ids.append(aspiration_track.guid64) else: while self._assignment_sim_info.is_teen: msg.available_aspiration_ids.append(aspiration_track.guid64) return msg
def build_msg (self, additional_tokens = (), icon_override = DEFAULT, secondary_icon_override = DEFAULT, text_override = DEFAULT, **kwargs): msg = Dialog_pb2.UiDialogMessage() msg.dialog_id = self.dialog_id msg.owner_id = self.owner.id if self.owner is not None else 0 msg.dialog_type = Dialog_pb2.UiDialogMessage.DEFAULT msg.dialog_style = self.dialog_style msg.dialog_bg_style = self.dialog_bg_style if self._target_sim_id is not None: msg.target_id = self._target_sim_id if self.title is not None: msg.title = self._build_localized_string_msg(self.title, *additional_tokens) if text_override is DEFAULT: msg.text = self._build_localized_string_msg(self.text, *additional_tokens) else: msg.text = self._build_localized_string_msg(text_override, *additional_tokens) if self.timeout_duration is not None: msg.timeout_duration = self.timeout_duration if icon_override is DEFAULT: if self.icon is not None: icon_info = self.icon(self._resolver) key = icon_info[0] if key is not None: msg.icon.type = key.type msg.icon.group = key.group msg.icon.instance = key.instance build_icon_info_msg(icon_info, None, msg.icon_info) elif icon_override is not None: build_icon_info_msg(icon_override, None, msg.icon_info) if secondary_icon_override is DEFAULT: if self.secondary_icon is not None: icon_info = self.secondary_icon(self._resolver) build_icon_info_msg(icon_info, None, msg.secondary_icon_info) elif secondary_icon_override is not None: build_icon_info_msg(secondary_icon_override, None, msg.secondary_icon_info) if self.icon_override_participant is not None: msg.override_sim_icon_id = self._resolver.get_participants(self.icon_override_participant)[0].id msg.dialog_options = self.dialog_options msg.anonymous_target_sim = self.anonymous_target_sim responses = [] responses.extend(self._get_responses_gen()) responses.sort(key = lambda response: response.sort_order) for response in responses: response_msg = msg.choices.add() self._build_response_arg(response, response_msg, additional_tokens = additional_tokens, **kwargs) if self.additional_texts: for additional_text in self.additional_texts: msg.additional_texts.append(self._build_localized_string_msg(additional_text, *additional_tokens)) return msg
def show_dialog(cls, first_time_buyer=False): business_managers = services.business_service( ).get_business_managers_for_household() if not business_managers: logger.error( 'Trying to show the balance transfer dialog but failed to find any owned businesses for the active household.' ) return False active_household = services.active_household() current_zone_id = services.current_zone_id() current_business_manager = business_managers.get(current_zone_id, None) balance_transfer_msg = Dialog_pb2.BalanceTransferDialog() balance_transfer_msg.transfer_amount = min( active_household.funds.money, current_business_manager.tuning_data. initial_funds_transfer_amount) if first_time_buyer else 0 if first_time_buyer or current_business_manager is None: cls._add_household(balance_transfer_msg, active_household) cls._try_add_current_business_lot(balance_transfer_msg, business_managers, current_zone_id) else: cls._try_add_current_business_lot(balance_transfer_msg, business_managers, current_zone_id) cls._add_household(balance_transfer_msg, active_household) for (zone_id, business_manager) in business_managers.items(): if zone_id == current_zone_id: continue zone_data = services.get_persistence_service().get_zone_proto_buff( zone_id) if zone_data is None: logger.error( "Business tracker thinks a zone exists that doesn't. Zone id:{}", zone_id) else: with ProtocolBufferRollback( balance_transfer_msg.lot_data) as lot_data: lot_data.lot_name = LocalizationHelperTuning.get_raw_text( zone_data.name) lot_data.zone_id = zone_id lot_data.balance = business_manager.funds.money transfer_op = GenericProtocolBufferOp( DistributorOps_pb2.Operation.RETAIL_BALANCE_TRANSFER_DIALOG, balance_transfer_msg) Distributor.instance().add_op_with_no_owner(transfer_op)
def build_msg(self, additional_tokens=(), icon_override=DEFAULT, secondary_icon_override=DEFAULT, **kwargs): msg = Dialog_pb2.UiDialogMessage() msg.dialog_id = self.dialog_id msg.owner_id = self.owner.id msg.dialog_type = Dialog_pb2.UiDialogMessage.DEFAULT if self.title is not None: msg.title = self._build_localized_string_msg( self.title, *additional_tokens) msg.text = self._build_localized_string_msg(self.text, *additional_tokens) if icon_override is DEFAULT: if self.icon is not None: icon_info = self.icon(self._resolver) key = icon_info[0] if key is not None: msg.icon.type = key.type msg.icon.group = key.group msg.icon.instance = key.instance build_icon_info_msg(icon_info, None, msg.icon_info) elif icon_override is not None: build_icon_info_msg(icon_override, None, msg.icon_info) if secondary_icon_override is DEFAULT: if self.secondary_icon is not None: icon_info = self.secondary_icon(self._resolver) build_icon_info_msg(icon_info, None, msg.secondary_icon_info) elif secondary_icon_override is not None: build_icon_info_msg(secondary_icon_override, None, msg.secondary_icon_info) msg.dialog_options = self.dialog_options responses = [] responses.extend(self._get_responses_gen()) responses.sort(key=lambda response: response.sort_order) for response in responses: response_msg = msg.choices.add() self._build_response_arg(response, response_msg, additional_tokens=additional_tokens, **kwargs) return msg
def dialog_show(self, dialog, phone_ring_type, **kwargs): if not self._enabled: return self._active_dialogs[dialog.dialog_id] = dialog if dialog.has_responses() and self.auto_respond: dialog.do_auto_respond() return dialog_msg = dialog.build_msg(**kwargs) if phone_ring_type != PhoneRingType.NO_RING: if self._is_phone_silenced: return msg_type = Consts_pb2.MSG_UI_PHONE_RING msg_data = Dialog_pb2.UiPhoneRing() msg_data.phone_ring_type = phone_ring_type msg_data.dialog = dialog_msg distributor = Distributor.instance() distributor.add_event(msg_type, msg_data) else: msg_type = dialog.DIALOG_MSG_TYPE msg_data = dialog_msg dialog.distribute_dialog(msg_type, msg_data)
def build_object_picker(self): picker_data = Dialog_pb2.UiDialogPicker() picker_data.title = self._build_localized_string_msg(self.title) if self.picker_type is not None: picker_data.type = self.picker_type if self.max_selectable: if self.max_selectable.max_type == MaxSelectableType.STATIC: picker_data.max_selectable = self.max_selectable.number_selectable picker_data.multi_select = True elif self.max_selectable.max_type == MaxSelectableType.SLOT_COUNT: if self.target is not None: get_slots = self.target.get_runtime_slots_gen( slot_types={self.max_selectable.slot_type}, bone_name_hash=None) if self.max_selectable.require_empty: picker_data.max_selectable = sum(1 for slot in get_slots if slot.empty) else: picker_data.max_selectable = sum(1 for slot in get_slots if not slot.empty) picker_data.multi_select = True else: logger.error( 'attempting to use slot based picker without a target object for dialog: {}', self, owner='nbaker') picker_data.multi_select = True else: picker_data.multi_select = True else: picker_data.multi_select = True picker_data.owner_sim_id = self.owner.sim_id if self.target_sim is not None: picker_data.target_sim_id = self.target_sim.sim_id picker_data.is_sortable = self.is_sortable picker_data.hide_row_description = self.hide_row_description self._build_customize_picker(picker_data) return picker_data
def _dialog_cancel_internal(self, dialog): msg = Dialog_pb2.UiDialogCloseRequest() msg.dialog_id = dialog.dialog_id distributor = Distributor.instance() distributor.add_event(Consts_pb2.MSG_UI_DIALOG_CLOSE, msg) del self._active_dialogs[dialog.dialog_id]
def build_msg(self, additional_tokens=(), trait_overrides_for_baby=None, gender_overrides_for_baby=None, previous_skills=None, previous_trait_guid=None, from_age_up=False, life_skill_trait_ids=None, **kwargs): msg = Dialog_pb2.SimPersonalityAssignmentDialog() msg.sim_id = self._assignment_sim_info.id dialog_msg = super().build_msg(additional_tokens=additional_tokens, **kwargs) msg.dialog = dialog_msg msg.secondary_title = self._build_localized_string_msg(self.secondary_title, *additional_tokens) msg.age_description = self._build_localized_string_msg(self.text, *additional_tokens) if self.naming_title_text is not None: msg.naming_title_text = self._build_localized_string_msg(self.naming_title_text, *additional_tokens) if gender_overrides_for_baby is None: gender = self._assignment_sim_info.gender else: gender = gender_overrides_for_baby msg.is_female = gender == Gender.FEMALE if from_age_up: if self._assignment_sim_info.is_child: for trait in self.TODDLER_TO_CHILD_REWARD_TRAITS: if self._assignment_sim_info.has_trait(trait): msg.reward_trait_id = trait.guid64 break if previous_trait_guid: msg.replace_trait_id = previous_trait_guid if previous_skills is not None: for (previous_skill, previous_skill_level) in previous_skills.items(): if previous_skill.age_up_skill_transition_data.new_skill is not None: msg.current_skill_ids.append(previous_skill.age_up_skill_transition_data.new_skill.guid64) msg.previous_skill_ids.append(previous_skill.guid64) msg.previous_skill_levels.append(previous_skill_level) if self.aspirations_and_trait_assignment is not None: msg.aspirations_and_trait_assignment_text = self._build_localized_string_msg(self.aspirations_and_trait_assignment.text, *additional_tokens) if trait_overrides_for_baby is None: empty_slots = self._assignment_sim_info.trait_tracker.empty_slot_number current_personality_traits = self._assignment_sim_info.trait_tracker.personality_traits else: empty_slots = 0 current_personality_traits = trait_overrides_for_baby msg.available_trait_slots = empty_slots for current_personality_trait in current_personality_traits: msg.current_personality_trait_ids.append(current_personality_trait.guid64) invalid_traits = self.aspirations_and_trait_assignment.invalid_traits if self.dialog_style == PersonalityAssignmentDialogStyle.TRAIT_REASSIGNMENT: self._populate_valid_personality_traits(msg, invalid_traits=invalid_traits) self._populate_current_aspiration(msg) msg.available_trait_slots = self._assignment_sim_info.trait_tracker.equip_slot_number elif empty_slots != 0: self._populate_valid_personality_traits(msg, traits_to_test_for_conflict=current_personality_traits, invalid_traits=invalid_traits) if self._assignment_sim_info.is_child or self._assignment_sim_info.is_teen: aspiration_track_manager = services.get_instance_manager(sims4.resources.Types.ASPIRATION_TRACK) aspiration_tracker = self._assignment_sim_info.aspiration_tracker for aspiration_track in aspiration_track_manager.types.values(): if not aspiration_tracker.is_aspiration_track_visible(aspiration_track): continue if aspiration_track.is_child_aspiration_track: if self._assignment_sim_info.is_child: msg.available_aspiration_ids.append(aspiration_track.guid64) elif self._assignment_sim_info.is_teen: msg.available_aspiration_ids.append(aspiration_track.guid64) else: self._populate_current_aspiration(msg) if life_skill_trait_ids is not None: msg.unlocked_trait_ids.extend(life_skill_trait_ids) return msg
def send_perks_list_for_bucks_type(self, bucks_type, sort_key=None, reverse=True): bucks_msg = Dialog_pb2.GameplayPerkList() bucks_msg.bucks_type = bucks_type resolver = SingleSimResolver(self._owner) perk_messages = [] for perk in self.all_perks_of_type_gen(bucks_type): perk_message = Dialog_pb2.GameplayPerk() perk_message.id = perk.guid64 perk_message.display_name = perk.display_name() perk_message.description = self._get_description_string(perk) perk_message.icon = create_icon_info_msg( IconInfoData(icon_resource=perk.icon.key)) perk_message.cost = perk.unlock_cost if bucks_type not in self._bucks: self._bucks[bucks_type] = 0 perk_message.affordable = self._bucks[ bucks_type] >= perk.unlock_cost perk_message.ui_display_flags = perk.ui_display_flags if perk.required_unlocks is not None: locked = False for required_perk in perk.required_unlocks: if not self.is_perk_unlocked(required_perk): locked = True perk_message.required_perks.append(required_perk.guid64) perk_message.locked = locked result = perk.available_for_puchase_tests.run_tests( resolver=resolver, search_for_tooltip=True) if not result: perk_message.locked_from_tests = True if result.tooltip is not None: perk_message.disabled_tooltip = result.tooltip(self._owner) unlocked = self.is_perk_unlocked(perk) if unlocked: perk_message.purchased = unlocked timestamp = self._get_perk_unlock_timestamp(perk) if timestamp is not None: perk_message.unlock_timestamp = timestamp if not unlocked: if self.is_perk_recently_locked(perk): perk_message.recently_locked = True if unlocked: disabled_tooltip = self.get_disabled_tooltip_for_perk(perk) if disabled_tooltip is not None: perk_message.disabled_tooltip = disabled_tooltip if perk.lock_on_purchase: for perk_to_lock in perk.lock_on_purchase: perk_message.lock_on_purchase.append(perk_to_lock.guid64) if perk.next_level_perk is not None: perk_message.next_perk_id = perk.next_level_perk.guid64 if perk.conflicting_perks is not None: for conflicting_perk in perk.conflicting_perks: perk_message.conflicting_perks.append( conflicting_perk.guid64) perk_messages.append(perk_message) if sort_key is not None: perk_messages.sort(key=sort_key, reverse=reverse) bucks_msg.perk_list.extend(perk_messages) op = shared_messages.create_message_op( bucks_msg, Consts_pb2.MSG_GAMEPLAY_PERK_LIST) Distributor.instance().add_op_with_no_owner(op)
def show_retail_dialog(opt_sim: OptionalSimInfoParam = None, _connection=None): sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: return False business_manager = services.business_service( ).get_business_manager_for_zone() if business_manager is None or business_manager.business_type != BusinessType.RETAIL: return False msg = Dialog_pb2.RetailManageEmployeesDialog() msg.hiring_sim_id = sim_info.sim_id def populate_employee_msg(sim_info, employee_msg): employee_msg.sim_id = sim_info.sim_id for skill_type in business_manager.EMPLOYEE_SKILLS: with ProtocolBufferRollback( employee_msg.skill_data) as employee_skill_msg: employee_skill_msg.skill_id = skill_type.guid64 employee_skill_msg.curr_points = int( sim_info.get_stat_value(skill_type)) if business_manager.is_employee(sim_info): satisfaction_stat = sim_info.get_statistic( business_manager.EMPLOYEE_SATISFACTION_COMMODITY) statisfaction_state_index = satisfaction_stat.get_state_index() if statisfaction_state_index is not None: employee_msg.satisfaction_string = satisfaction_stat.states[ statisfaction_state_index].buff.buff_type.buff_name( sim_info) career_level = business_manager.get_employee_career_level(sim_info) employee_msg.pay = career_level.simoleons_per_hour career = business_manager.get_employee_career(sim_info) employee_msg.current_career_level = career.level employee_msg.max_career_level = len( career.current_track_tuning.career_levels) - 1 else: desired_level = business_manager.get_employee_desired_career_level( sim_info) career_level = business_manager.RETAIL_CAREER.start_track.career_levels[ desired_level] employee_msg.pay = career_level.simoleons_per_hour employee_msg.current_career_level = desired_level employee_msg.max_career_level = len( business_manager.RETAIL_CAREER.start_track.career_levels) - 1 for employee_sim_info in business_manager.get_employees_gen(): with ProtocolBufferRollback(msg.employees) as employee_msg: populate_employee_msg(employee_sim_info, employee_msg) def get_sim_filter_gsi_name(): return 'Retail Command: Create Employees for Hire' results = services.sim_filter_service().submit_matching_filter( number_of_sims_to_find=business_manager.EMPLOYEE_POOL_SIZE, sim_filter=business_manager.EMPLOYEE_POOL_FILTER, requesting_sim_info=sim_info, allow_yielding=False, gsi_source_fn=get_sim_filter_gsi_name) for result in results: with ProtocolBufferRollback(msg.available_sims) as employee_msg: populate_employee_msg(result.sim_info, employee_msg) op = shared_messages.create_message_op( msg, Consts_pb2.MSG_RETAIL_MANAGE_EMPLOYEES) Distributor.instance().add_op_with_no_owner(op)
def get_valid_situation_locations(sim_id, situation_type, *guests, _connection=None): sim = get_optional_target(sim_id, _connection) if not sim: sims4.commands.output('Invalid Sim ID: {}'.format(sim_id), _connection) return sim_info = sim.sim_info possible_zones = [] possible_zones.append(sim_info.household.home_zone_id) for guest_id in guests: guest_id = int(guest_id) guest_info = services.sim_info_manager().get(guest_id) while guest_info is not None: guest_zone_id = guest_info.household.home_zone_id if guest_zone_id is not None and guest_zone_id and guest_zone_id not in possible_zones: possible_zones.append(guest_zone_id) venue_service = services.current_zone().venue_service for venue_type in situation_type.venue_types: possible_zones.extend( venue_service.get_zones_for_venue_type(venue_type)) venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE) persistence_service = services.get_persistence_service() locations_msg = Situations_pb2.SituationLocations() cas_zones_msg = InteractionOps_pb2.CASAvailableZonesInfo() world_info_msg = cas_zones_msg.zones.add() for zone_id in possible_zones: zone_data = persistence_service.get_zone_proto_buff(zone_id) if zone_data is None: pass neighborhood_data = persistence_service.get_neighborhood_proto_buff( zone_data.neighborhood_id) if neighborhood_data is None: pass lot_data = None for lot_owner_data in neighborhood_data.lots: while zone_id == lot_owner_data.zone_instance_id: lot_data = lot_owner_data break while zone_data is not None and lot_data is not None: location_data = Dialog_pb2.LotInfoItem() location_data.zone_id = zone_data.zone_id location_data.name = zone_data.name location_data.world_id = zone_data.world_id location_data.lot_template_id = zone_data.lot_template_id location_data.lot_description_id = zone_data.lot_description_id venue_type_id = build_buy.get_current_venue(zone_id) venue_instance = venue_manager.get(venue_type_id) if venue_instance is not None: location_data.venue_type_name = venue_instance.display_name if lot_data.lot_owner: household_id = lot_data.lot_owner[0].household_id household = services.household_manager().get(household_id) if household is not None: location_data.household_name = household.name locations_msg.situation_locations.append(location_data) with ProtocolBufferRollback(world_info_msg.zones) as zone_info_msg: zone_info_msg.id = zone_data.zone_id zone_info_msg.name = zone_data.name zone_info_msg.world_id = zone_data.world_id zone_info_msg.lot_template_id = zone_data.lot_template_id zone_info_msg.lot_description_id = zone_data.lot_description_id shared_messages.add_object_message_for_sim_id( sim.id, Consts_pb2.MSG_NS_AVAILABLE_ZONES_INFO, cas_zones_msg) shared_messages.add_object_message_for_sim_id( sim.id, Consts_pb2.MSG_SITUATION_LOCATIONS, locations_msg)