def _expand_guest_list_based_on_tuning(self):
     host_sim_id = self._guest_list.host_sim_id
     if self.resident_job(
     ) is not None and host_sim_id != 0 and self._guest_list.get_guest_info_for_sim_id(
             host_sim_id) is None:
         guest_info = SituationGuestInfo.construct_from_purpose(
             host_sim_id, self.resident_job(),
             SituationInvitationPurpose.HOSTING)
         self._guest_list.add_guest_info(guest_info)
     for job_type in self._jobs:
         if job_type is self.fan.job:
             celebrity_guest_info = next(
                 iter(
                     self._guest_list.get_guest_infos_for_job(
                         self.celebrity.job)))
             celebrity = services.sim_info_manager().get(
                 celebrity_guest_info.sim_id)
             fan_statistic = celebrity.get_statistic(
                 self.fan_count_statistic, add=False)
             if fan_statistic is None:
                 value = 0
             else:
                 value = fan_statistic.rank_level
             num_to_auto_fill = self.rank_to_fan_count.get(value, 0) - len(
                 self._guest_list.get_guest_infos_for_job(job_type))
         else:
             num_to_auto_fill = job_type.get_auto_invite() - len(
                 self._guest_list.get_guest_infos_for_job(job_type))
         for _ in range(num_to_auto_fill):
             guest_info = SituationGuestInfo.construct_from_purpose(
                 0, job_type, SituationInvitationPurpose.AUTO_FILL)
             self._guest_list.add_guest_info(guest_info)
示例#2
0
 def start_situation(interaction, situation, user_facing):
     situation_manager = services.get_zone_situation_manager()
     guest_list = situation.get_predefined_guest_list()
     if guest_list is None:
         sim = interaction.sim
         guest_list = SituationGuestList(invite_only=True, host_sim_id=sim.id)
         if situation.targeted_situation is not None:
             target_sim = interaction.get_participant(ParticipantType.PickedSim)
             if target_sim is None:
                 target_sim = interaction.get_participant(ParticipantType.TargetSim)
             target_sim_id = target_sim.id if target_sim is not None else None
             job_assignments = situation.get_prepopulated_job_for_sims(sim, target_sim_id)
             for (sim_id, job_type_id) in job_assignments:
                 job_type = services.situation_job_manager().get(job_type_id)
                 guest_info = SituationGuestInfo.construct_from_purpose(sim_id, job_type, SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
         else:
             default_job = situation.default_job()
             target_sims = interaction.get_participants(ParticipantType.PickedSim)
             if target_sims:
                 for sim_or_sim_info in target_sims:
                     guest_info = SituationGuestInfo.construct_from_purpose(sim_or_sim_info.sim_id, default_job, SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             else:
                 target_sim = interaction.get_participant(ParticipantType.TargetSim)
                 if target_sim is not None:
                     guest_info = SituationGuestInfo.construct_from_purpose(target_sim.sim_id, default_job, SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             guest_info = SituationGuestInfo.construct_from_purpose(sim.sim_id, default_job, SituationInvitationPurpose.INVITED)
             guest_list.add_guest_info(guest_info)
     zone_id = interaction.get_participant(ParticipantType.PickedZoneId) or 0
     situation_manager.create_situation(situation, guest_list=guest_list, user_facing=user_facing, zone_id=zone_id)
示例#3
0
def travel_sims_to_zone(opt_sim_id:OptionalTargetParam, zone_id:int, *traveling_sim_ids, _connection=None):
    sim_or_sim_info = get_optional_target(opt_sim_id, _connection)
    if sim_or_sim_info is None:
        if opt_sim_id:
            sim_or_sim_info = services.sim_info_manager().get(opt_sim_id)
            if sim_or_sim_info is None:
                sims4.commands.output('Invalid Sim id: {} specified for travel.travel_sims_to_zone'.format(opt_sim_id), _connection)
                return False
        else:
            sims4.commands.output('No Sim id specified for travel.travel_sims_to_zone', _connection)
            return False
    zone_proto_buff = services.get_persistence_service().get_zone_proto_buff(zone_id)
    if zone_proto_buff is None:
        sims4.commands.output('Invalid Zone Id: {}. Zone does not exist.'.format(zone_id), _connection)
        return False
    situation_manager = services.get_zone_situation_manager()
    situation = situation_manager.DEFAULT_TRAVEL_SITUATION
    guest_list = situation.get_predefined_guest_list()
    if guest_list is None:
        guest_list = SituationGuestList(invite_only=True, host_sim_id=sim_or_sim_info.id)
        default_job = situation.default_job()
        sim_info_manager = services.sim_info_manager()
        roommate_service = services.get_roommate_service()
        if roommate_service is not None:
            traveling_sim_ids = tuple(itertools.chain(traveling_sim_ids, (sim_info.sim_id for sim_info in roommate_service.get_auto_invite_sim_infos(sim_or_sim_info, situation))))
        for sim_id in traveling_sim_ids:
            sim_id = int(sim_id)
            sim_info = sim_info_manager.get(sim_id)
            if sim_info is None:
                continue
            guest_info = SituationGuestInfo.construct_from_purpose(sim_id, default_job, SituationInvitationPurpose.INVITED)
            guest_list.add_guest_info(guest_info)
        guest_info = SituationGuestInfo.construct_from_purpose(sim_or_sim_info.id, default_job, SituationInvitationPurpose.INVITED)
        guest_list.add_guest_info(guest_info)
    situation_manager.create_situation(situation, guest_list=guest_list, user_facing=False, zone_id=zone_id)
 def _create_situation(self, additional_sims_to_bring=()):
     guest_list = self._situation_to_run.get_predefined_guest_list()
     if guest_list is None:
         if self._require_predefined_guest_list:
             return
         host_sim_info = self._get_host(additional_sims_to_bring)
         if host_sim_info is None:
             return
         guest_list = SituationGuestList(invite_only=True, host_sim_id=host_sim_info.id)
     else:
         host_sim_info = self._get_host(additional_sims_to_bring)
         if host_sim_info is None:
             return
     if self._NPC_hosted_situation_player_job is not None:
         guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(self._receiver_sim_info.id, self._NPC_hosted_situation_player_job, SituationInvitationPurpose.INVITED))
     if self._NPC_host_job is not None:
         guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(host_sim_info.id, self._NPC_host_job, SituationInvitationPurpose.INVITED))
     if additional_sims_to_bring:
         additional_sims_job = self._chosen_dialog.bring_other_sims.situation_job
         for sim_info in additional_sims_to_bring:
             guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(sim_info.id, additional_sims_job, SituationInvitationPurpose.INVITED))
     if self._NPC_hosted_situation_use_player_sim_as_filter_requester:
         guest_list.filter_requesting_sim_id = self._receiver_sim_info.id
     services.get_zone_situation_manager().create_situation(self._situation_to_run, guest_list=guest_list, zone_id=self._get_zone_id(), scoring_enabled=self._NPC_hosted_situation_scoring_enabled, user_facing=self._user_facing)
     with telemetry_helper.begin_hook(telemetry_writer, TELEMETRY_HOOK_SITUATION_ACCEPTED, sim_info=self._receiver_sim_info) as hook:
         hook.write_guid(TELEMETRY_SITUATION_TYPE_ID, self._situation_to_run.guid64)
         hook.write_int(TELEMETRY_GUEST_COUNT, len(additional_sims_to_bring))
示例#5
0
 def start_situation(interaction, situation, user_facing):
     situation_manager = services.get_zone_situation_manager()
     guest_list = situation.get_predefined_guest_list()
     if guest_list is None:
         sim = interaction.sim
         guest_list = SituationGuestList(invite_only=True,
                                         host_sim_id=sim.id)
         if situation.targeted_situation is not None:
             target_sim = interaction.get_participant(
                 ParticipantType.PickedSim)
             if target_sim is None:
                 target_sim = interaction.get_participant(
                     ParticipantType.TargetSim)
             target_sim_id = target_sim.id if target_sim is not None else None
             job_assignments = situation.get_prepopulated_job_for_sims(
                 sim, target_sim_id)
             for (sim_id, job_type_id) in job_assignments:
                 job_type = services.situation_job_manager().get(
                     job_type_id)
                 guest_info = SituationGuestInfo.construct_from_purpose(
                     sim_id, job_type,
                     SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
         else:
             default_job = situation.default_job()
             target_sims = interaction.get_participants(
                 ParticipantType.PickedSim)
             if target_sims:
                 for sim_or_sim_info in target_sims:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         sim_or_sim_info.sim_id, default_job,
                         SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             else:
                 target_sim = interaction.get_participant(
                     ParticipantType.TargetSim)
                 if target_sim is not None:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         target_sim.sim_id, default_job,
                         SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             guest_info = SituationGuestInfo.construct_from_purpose(
                 sim.sim_id, default_job,
                 SituationInvitationPurpose.INVITED)
             guest_list.add_guest_info(guest_info)
     zone_id = interaction.get_participant(
         ParticipantType.PickedZoneId) or 0
     situation_manager.create_situation(situation,
                                        guest_list=guest_list,
                                        user_facing=user_facing,
                                        zone_id=zone_id)
示例#6
0
 def _run_interaction_gen(self, timeline):
     logger.assert_raise(
         self.situation is not None,
         'No situation tuned on RunSituationSuperInteraction: {}'.format(
             self),
         owner='rez')
     situation_manager = services.get_zone_situation_manager()
     host_sim_id = 0
     if self.host_sim is not None:
         host_sim = self.get_participant(self.host_sim)
         if host_sim is not None:
             host_sim_id = host_sim.sim_id
     guest_list = SituationGuestList(invite_only=self.invite_only,
                                     host_sim_id=host_sim_id)
     if self.job_mapping:
         for (participant_type, job) in self.job_mapping.items():
             sim = self.get_participant(participant_type)
             if sim is not None:
                 if sim.is_sim:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         sim.sim_id, job,
                         SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
     user_facing = False
     scoring_enabled = True
     if self.ui_options is not None:
         user_facing = True
         scoring_enabled = self.ui_options.scoring_enabled
     situation_manager.create_situation(self.situation,
                                        guest_list=guest_list,
                                        user_facing=user_facing,
                                        interaction=self,
                                        scoring_enabled=scoring_enabled)
     return event_testing.results.ExecuteResult.NONE
     yield
示例#7
0
 def _start_scorable_situation_from_tuning(self):
     if self._scorable_situation_id is not None:
         return
     logger.assert_raise(
         self._career_events,
         'Spinning up career event manger with no career events. Manager: {}',
         self)
     career_event = self._career_events[0]
     if career_event.scorable_situation is None:
         return
     situation = career_event.scorable_situation.situation
     if situation is None:
         return
     guest_info = SituationGuestInfo.construct_from_purpose(
         self._career.sim_info.sim_id, situation.default_job(),
         SituationInvitationPurpose.CAREER)
     guest_list = SituationGuestList(
         invite_only=True,
         filter_requesting_sim_id=self._career.sim_info.sim_id)
     guest_list.add_guest_info(guest_info)
     situation_manager = services.get_zone_situation_manager()
     duration = self._career.time_until_end_of_work().in_minutes()
     self._scorable_situation_id = situation_manager.create_situation(
         situation, guest_list=guest_list, duration_override=duration)
     self._scorable_situation_setup()
 def _send_service_npc(self, scheduler, alarm_data, situation_creation_params):
     household = situation_creation_params.hiring_household
     service_npc_type = situation_creation_params.service_npc_type
     if not self._auto_scheduled_services_enabled and service_npc_type.auto_schedule_on_client_connect():
         return
     service_record = household.get_service_npc_record(service_npc_type.guid64)
     preferred_sim_id = service_record.get_preferred_sim_id()
     situation_type = service_npc_type.situation
     user_specified_data_id = situation_creation_params.user_specified_data_id
     now = services.time_service().sim_now
     if service_record.time_last_started_service is not None and alarm_data.start_time is not None:
         alarm_start_time_absolute = date_and_time_from_week_time(now.week(), alarm_data.start_time)
         if service_record.time_last_started_service >= alarm_start_time_absolute:
             return
     service_record.time_last_started_service = now
     service_record.time_last_finished_service = None
     duration = alarm_data.end_time - now.time_since_beginning_of_week()
     min_duration = service_npc_type.min_duration_left_for_arrival_on_lot()
     if duration < min_duration:
         service_npc_type.fake_perform(household)
         return
     min_duration = service_npc_type.min_work_duration()
     max_duration = service_npc_type.max_work_duration()
     duration = clamp(min_duration, duration.in_minutes(), max_duration)
     guest_list = SituationGuestList(True)
     if preferred_sim_id is not None:
         guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(preferred_sim_id, situation_type.default_job(), SituationInvitationPurpose.PREFERRED))
     situation_creation_params_writer = PropertyStreamWriter()
     situation_creation_params_writer.write_uint64('household_id', household.id)
     situation_creation_params_writer.write_uint64('service_npc_type_id', service_npc_type.guid64)
     if user_specified_data_id is not None:
         situation_creation_params_writer.write_uint64('user_specified_data_id', user_specified_data_id)
     situation_creation_params_writer.write_bool('is_recurring', situation_creation_params.is_recurring)
     self._situation_id = services.get_zone_situation_manager().create_situation(situation_type, guest_list, user_facing=False, duration_override=duration, custom_init_writer=situation_creation_params_writer)
 def _run_situation(self):
     host_sim_id = 0
     host_sim_info = None
     if self.host_sim_participant is not None:
         host_sim_info = self._get_resolver().get_participant(
             self.host_sim_participant)
         host_sim_id = host_sim_info.id
     guest_list = self.situation_to_run.get_predefined_guest_list()
     if guest_list is None:
         guest_list = SituationGuestList(invite_only=True,
                                         host_sim_id=host_sim_id)
     if self._sender_sim_info is not None and self.sender_sim_info_job is not None:
         guest_list.add_guest_info(
             SituationGuestInfo.construct_from_purpose(
                 self._sender_sim_info.id, self.sender_sim_info_job,
                 SituationInvitationPurpose.INVITED))
     if host_sim_info is not None and self.host_sim_info_job is not None:
         guest_list.add_guest_info(
             SituationGuestInfo.construct_from_purpose(
                 host_sim_info.id, self.host_sim_info_job,
                 SituationInvitationPurpose.HOSTING))
     zone_id = 0
     if self.lot is not None:
         lot_id = get_lot_id_from_instance_id(self.lot)
         zone_id = services.get_persistence_service(
         ).resolve_lot_id_into_zone_id(lot_id, ignore_neighborhood_id=True)
     situation_id = services.get_zone_situation_manager().create_situation(
         self.situation_to_run,
         guest_list=guest_list,
         spawn_sims_during_zone_spin_up=self.spawn_sims_during_zone_spin_up,
         user_facing=self.user_facing,
         zone_id=zone_id)
     if self.household_milestone and situation_id:
         active_household_milestone_tracker = services.active_household(
         ).household_milestone_tracker
         active_household_milestone_tracker.reset_milestone(
             self.household_milestone)
     if self.notification is not None:
         target_sim_id = self._sender_sim_info.id if self._sender_sim_info is not None else None
         dialog = self.notification(self._receiver_sim_info,
                                    DoubleSimResolver(
                                        self._sender_sim_info,
                                        self._receiver_sim_info),
                                    target_sim_id=target_sim_id)
         dialog.show_dialog()
     return True
 def create_arrival_situation_for_sim(self, sim_info, situation_type=DEFAULT, during_spin_up=False):
     if situation_type is DEFAULT:
         situation_type = self.user_sim_arrival_situation
     situation_manager = services.get_zone_situation_manager()
     if during_spin_up and self._sim_info_already_in_arrival_situation(sim_info, situation_manager):
         return
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(sim_info.id, situation_type.default_job(), SituationInvitationPurpose.INVITED)
     guest_list.add_guest_info(guest_info)
     self.create_arrival_situation(situation_type, guest_list, situation_manager)
示例#11
0
 def _create_fire_situation_on_sim(self, sim, situation_manager=None):
     if sim.id in self._situation_ids:
         return
     if situation_manager is None:
         situation_manager = services.current_zone().situation_manager
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(sim.sim_id, self.FIRE_JOB, SituationInvitationPurpose.INVITED)
     guest_list.add_guest_info(guest_info)
     situation_id = situation_manager.create_situation(self.FIRE_SITUATION, guest_list=guest_list, user_facing=False)
     self._situation_ids[sim.id] = situation_id
 def _generate_situation_guest_list(self, preferred_sim_id,
                                    service_npc_type, hiring_household):
     guest_list = SituationGuestList(invite_only=True)
     blacklist_sim_ids = hiring_household.get_all_fired_service_npc_ids()
     roommate_service = services.get_roommate_service()
     if roommate_service is not None:
         blacklist_sim_ids.update(roommate_service.get_roommate_ids())
     if preferred_sim_id is not None:
         guest_info = SituationGuestInfo.construct_from_purpose(
             preferred_sim_id, service_npc_type.situation.default_job(),
             SituationInvitationPurpose.PREFERRED)
         guest_info.expectation_preference = True
         guest_list.add_guest_info(guest_info)
         return guest_list
     if service_npc_type.exclusive_to_household:
         household_manager = services.household_manager()
         if household_manager is None:
             logger.error(
                 'Household manager is None when service npc is being scheduled for service type {}',
                 service_npc_type)
             return guest_list
         for household in household_manager.values():
             if household.id == hiring_household:
                 continue
             blacklist_sim_ids.update(
                 household.get_preferred_service_npcs())
     worker_filter = service_npc_type.situation.default_job().filter
     filter_results = services.sim_filter_service().submit_matching_filter(
         sim_filter=worker_filter,
         allow_yielding=False,
         blacklist_sim_ids=blacklist_sim_ids,
         gsi_source_fn=self.get_sim_filter_gsi_name)
     if not filter_results:
         return guest_list
     for result in filter_results:
         guest_info = SituationGuestInfo.construct_from_purpose(
             result.sim_info.sim_id,
             service_npc_type.situation.default_job(),
             SituationInvitationPurpose.PREFERRED)
         guest_info.expectation_preference = True
         guest_list.add_guest_info(guest_info)
     return guest_list
示例#13
0
 def _start_special_event(dialog):
     guest_list = None
     if dialog.accepted:
         start_user_facing = True
         guest_list = SituationGuestList()
         guest_info = SituationGuestInfo.construct_from_purpose(invited_sim.id, situation.venue_situation_player_job, SituationInvitationPurpose.INVITED)
         guest_list.add_guest_info(guest_info)
     else:
         start_user_facing = False
     situation_id = situation_manager.create_situation(situation, guest_list=guest_list, user_facing=start_user_facing)
     self._active_special_event_id = situation_id
 def _on_set_sim_job(self, sim, job_type):
     super()._on_set_sim_job(sim, job_type)
     situation_manager = services.get_zone_situation_manager()
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(
         sim.sim_info.id, self.party_goer_situation.default_job(),
         SituationInvitationPurpose.INVITED)
     guest_list.add_guest_info(guest_info)
     situation_manager.create_situation(self.party_goer_situation,
                                        guest_list=guest_list,
                                        user_facing=False)
 def get_all_sim_arrival_guest_list(self, situation_manager, during_spin_up=False):
     sim_infos = [sim_info for sim_info in self.get_user_controlled_sim_infos()]
     if self.place_travel_companion_in_same_arrival_situation:
         sim_infos.extend(self._traveled_sim_infos)
     guest_list = SituationGuestList(invite_only=True)
     for sim_info in sim_infos:
         if during_spin_up and self._sim_info_already_in_arrival_situation(sim_info, situation_manager):
             continue
         guest_info = SituationGuestInfo.construct_from_purpose(sim_info.id, self.user_sim_arrival_situation.default_job(), SituationInvitationPurpose.INVITED)
         guest_list.add_guest_info(guest_info)
     return guest_list
 def start_career_situation(self):
     if self._career_situation is not None:
         guest_info = SituationGuestInfo.construct_from_purpose(self._sim_info.sim_id, self._career_situation.job, SituationInvitationPurpose.CAREER)
         guest_list = SituationGuestList()
         guest_list.add_guest_info(guest_info)
         situation_manager = services.get_zone_situation_manager()
         situation = self._career_situation.situation
         if not situation.has_venue_location():
             logger.error("Tried starting a career event, career:{}  level:{}, and couldn't find a valid venue. There should ALWAYS be a Maxis Lot tuned for every venue type. - trevorlindsey", self, self.level)
             return False
         zone_id = situation.get_venue_location()
         self._career_situation_id = situation_manager.create_situation(self._career_situation.situation, guest_list=guest_list, zone_id=zone_id)
示例#17
0
 def _expand_guest_list_based_on_tuning(self):
     zone_data = services.get_persistence_service().get_zone_proto_buff(services.current_zone_id())
     lot_trait_manager = services.get_instance_manager(sims4.resources.Types.ZONE_MODIFIER)
     for lot_trait_id in zone_data.lot_traits:
         lot_trait = lot_trait_manager.get(lot_trait_id)
         if lot_trait in self.auto_invite_disabled_traits:
             return
     num_to_auto_fill = self.min_number_of_guests - len(self._guest_list.get_guest_infos_for_job(self.guest_job))
     if num_to_auto_fill > 0:
         for _ in range(num_to_auto_fill):
             guest_info = SituationGuestInfo.construct_from_purpose(0, self.island_guest_job, SituationInvitationPurpose.AUTO_FILL)
             self._guest_list.add_guest_info(guest_info)
 def _create_NPC_hosted_situation(dialog):
     if not dialog.accepted:
         with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_SITUATION_REJECTED, sim=player_sim) as hook:
             hook.write_guid('type', chosen_situation.guid64)
         return
     guest_list = SituationGuestList(host_sim_id=NPC_sim_id)
     if chosen_situation.NPC_hosted_situation_use_player_sim_as_filter_requester:
         guest_list.filter_requesting_sim_id = player_sim.id
     guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(player_sim.id, chosen_situation.NPC_hosted_situation_player_job, SituationInvitationPurpose.INVITED))
     chosen_zone_id = chosen_situation.get_venue_location()
     services.get_zone_situation_manager().create_situation(chosen_situation, guest_list=guest_list, zone_id=chosen_zone_id)
     self.add_cooldown(self._cooldown)
     with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_SITUATION_ACCEPTED, sim=player_sim) as hook:
         hook.write_guid('type', chosen_situation.guid64)
示例#19
0
 def _add_host_toddler_to_guest_list(self, seed):
     host_sim = seed.guest_list.host_sim
     if host_sim is None:
         return
     if host_sim.sim_info.lives_here:
         for sim_info in host_sim.household.sim_info_gen():
             if sim_info.is_toddler:
                 if seed.guest_list.get_guest_info_for_sim(
                         sim_info) is None:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         sim_info.sim_id,
                         self.host_toddler_job_and_role_state.job,
                         SituationInvitationPurpose.HOSTING)
                     seed.guest_list.add_guest_info(guest_info)
def force_career_event(career_situation_type, opt_sim:OptionalTargetParam=None, _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if not sim:
        sims4.commands.output('Invalid Sim ID: {}'.format(opt_sim), _connection)
        return
    guest_info = SituationGuestInfo.construct_from_purpose(sim.id, career_situation_type.job, SituationInvitationPurpose.CAREER)
    guest_list = SituationGuestList()
    guest_list.add_guest_info(guest_info)
    situation_manager = services.get_zone_situation_manager()
    situation = career_situation_type.situation
    if not situation.has_venue_location():
        logger.error("Tried forcing a career event:{} and couldn't find a valid venue.", career_situation_type)
        return False
    zone_id = situation.get_venue_location()
    situation_manager.create_situation(situation, guest_list=guest_list, zone_id=zone_id)
示例#21
0
 def _run_interaction_gen(self, timeline):
     logger.assert_raise(self.situation is not None, 'No situation tuned on RunSituationSuperInteraction: {}'.format(self), owner='rez')
     situation_manager = services.get_zone_situation_manager()
     host_sim_id = 0
     host_sim = self.get_participant(self.host_sim)
     if host_sim is not None:
         host_sim_id = host_sim.sim_id
     guest_list = SituationGuestList(host_sim_id=host_sim_id)
     if self.job_mapping:
         for (participant_type, job) in self.job_mapping.items():
             sim = self.get_participant(participant_type)
             while sim is not None and sim.is_sim:
                 guest_info = SituationGuestInfo.construct_from_purpose(sim.sim_id, job, SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
     situation_manager.create_situation(self.situation, guest_list=guest_list, user_facing=False)
     return event_testing.results.ExecuteResult.NONE
示例#22
0
 def _start_special_event(dialog):
     guest_list = None
     if dialog.accepted:
         start_user_facing = True
         guest_list = SituationGuestList()
         guest_info = SituationGuestInfo.construct_from_purpose(
             invited_sim.id, situation.venue_situation_player_job,
             SituationInvitationPurpose.INVITED)
         guest_list.add_guest_info(guest_info)
     else:
         start_user_facing = False
     situation_id = situation_manager.create_situation(
         situation,
         guest_list=guest_list,
         user_facing=start_user_facing)
     self._active_special_event_id = situation_id
def create_situation_with_guest_list(situation_type, scoring_enabled, zone_id:int=0, *args, _connection=None):
    if len(args) % 3 != 0:
        sims4.commands.output('Invalid guest list, its length must be a multiple of 3', _connection)
        return False
    situation_manager = services.get_zone_situation_manager()
    client = services.client_manager().get(_connection)
    if client.active_sim is not None:
        host_sim_id = client.active_sim.id
        client.active_sim.household.set_situation_scoring(scoring_enabled)
    else:
        host_sim_id = 0
    guest_list = SituationGuestList(situation_type.force_invite_only, host_sim_id)
    guest_list_is_good = True
    for (job_name_or_key, sim_id_or_name, purpose_name) in zip(args[0::3], args[1::3], args[2::3]):
        job_type = services.situation_job_manager().get(job_name_or_key)
        if job_type is None:
            sims4.commands.output('Invalid job name or key: {}'.format(job_name_or_key), _connection)
            guest_list_is_good = False
        try:
            purpose = SituationInvitationPurpose(purpose_name)
        except ValueError:
            sims4.commands.output('Invalid Purpose: {}. Use INVITED, HIRED, or PREFERRED'.format(purpose_name), _connection)
            guest_list_is_good = False
            continue
        try:
            sim_id = int(sim_id_or_name)
        except (ValueError, TypeError):
            sims4.commands.output('Incorrectly formatted sim_id {}'.format(sim_id_or_name), _connection)
            guest_list_is_good = False
            continue
        guest_info = SituationGuestInfo.construct_from_purpose(sim_id, job_type, purpose)
        guest_list.add_guest_info(guest_info)
    if not guest_list_is_good:
        sims4.commands.output('FAILURE: bad guest list {}.'.format(situation_type), _connection)
        return False
    situation_id = situation_manager.create_situation(situation_type, guest_list=guest_list, zone_id=zone_id, scoring_enabled=scoring_enabled)
    if situation_id is not None:
        sims4.commands.output('Successfully created situation: {}.'.format(situation_id), _connection)
    else:
        sims4.commands.output('Insufficient funds to create situation', _connection)
    return True
示例#24
0
 def _add_guest_parent_to_guest_list(cls, guest_list):
     m = services.sim_info_manager()
     households = {
         m.get(sim.sim_id).household
         for sim in guest_list.get_guest_infos_for_job(
             cls.guest_toddler_job_and_role_state.job)
     }
     for household in households:
         for sim_info in household.sim_info_gen():
             if sim_info.is_young_adult_or_older:
                 guest_info = SituationGuestInfo.construct_from_purpose(
                     sim_info.sim_id,
                     cls.guest_parent_job_and_role_state.job,
                     SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
                 break
         else:
             logger.error(
                 'Failed to find young adult or older Sim in household {}.',
                 household,
                 owner='mkartika')
示例#25
0
 def _start_employee_situation(self, employee_sim_id, employee_data,
                               situation_manager):
     employee_type = employee_data.employee_type
     employee_situation_data = self.employee_situation_data[employee_type]
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(
         employee_sim_id, employee_situation_data.situation_job,
         SituationInvitationPurpose.CAREER)
     guest_info.expectation_preference = True
     guest_list.add_guest_info(guest_info)
     try:
         creation_source = self.instance_name
     except:
         creation_source = str(self)
     situation_id = situation_manager.create_situation(
         self._get_employee_situation_for_employee_type(employee_type),
         guest_list=guest_list,
         spawn_sims_during_zone_spin_up=True,
         user_facing=False,
         creation_source=creation_source)
     self._employee_situation_ids[employee_type].add(situation_id)
def force_career_event(career_situation_type,
                       opt_sim: OptionalTargetParam = None,
                       _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if not sim:
        sims4.commands.output('Invalid Sim ID: {}'.format(opt_sim),
                              _connection)
        return
    guest_info = SituationGuestInfo.construct_from_purpose(
        sim.id, career_situation_type.job, SituationInvitationPurpose.CAREER)
    guest_list = SituationGuestList()
    guest_list.add_guest_info(guest_info)
    situation_manager = services.get_zone_situation_manager()
    situation = career_situation_type.situation
    if not situation.has_venue_location():
        logger.error(
            "Tried forcing a career event:{} and couldn't find a valid venue.",
            career_situation_type)
        return False
    zone_id = situation.get_venue_location()
    situation_manager.create_situation(situation,
                                       guest_list=guest_list,
                                       zone_id=zone_id)
示例#27
0
 def create_guest_info(sim_id, job_type):
     if situation_guest_info is None:
         return SituationGuestInfo.construct_from_purpose(
             sim_id, job_type, SituationInvitationPurpose.INVITED)
     return situation_guest_info(sim_id, job_type)
def create_situation_with_guest_list(situation_type,
                                     scoring_enabled,
                                     zone_id: int = 0,
                                     *args,
                                     _connection=None):
    if len(args) % 3 != 0:
        sims4.commands.output(
            'Invalid guest list, its length must be a multiple of 3',
            _connection)
        return False
    situation_manager = services.get_zone_situation_manager()
    client = services.client_manager().get(_connection)
    if client.active_sim is not None:
        host_sim_id = client.active_sim.id
        client.active_sim.household.set_situation_scoring(scoring_enabled)
    else:
        host_sim_id = 0
    guest_list = SituationGuestList(situation_type.force_invite_only,
                                    host_sim_id)
    guest_list_is_good = True
    for (job_name_or_key, sim_id_or_name,
         purpose_name) in zip(args[0::3], args[1::3], args[2::3]):
        job_type = services.situation_job_manager().get(job_name_or_key)
        if job_type is None:
            sims4.commands.output(
                'Invalid job name or key: {}'.format(job_name_or_key),
                _connection)
            guest_list_is_good = False
        try:
            purpose = SituationInvitationPurpose(purpose_name)
        except ValueError:
            sims4.commands.output(
                'Invalid Purpose: {}. Use INVITED, HIRED, or PREFERRED'.format(
                    purpose_name), _connection)
            guest_list_is_good = False
            continue
        try:
            sim_id = int(sim_id_or_name)
        except (ValueError, TypeError):
            sims4.commands.output(
                'Incorrectly formatted sim_id {}'.format(sim_id_or_name),
                _connection)
            guest_list_is_good = False
            continue
        guest_info = SituationGuestInfo.construct_from_purpose(
            sim_id, job_type, purpose)
        guest_list.add_guest_info(guest_info)
    if not guest_list_is_good:
        sims4.commands.output(
            'FAILURE: bad guest list {}.'.format(situation_type), _connection)
        return False
    situation_id = situation_manager.create_situation(
        situation_type,
        guest_list=guest_list,
        zone_id=zone_id,
        scoring_enabled=scoring_enabled)
    if situation_id is not None:
        sims4.commands.output(
            'Successfully created situation: {}.'.format(situation_id),
            _connection)
    else:
        sims4.commands.output('Insufficient funds to create situation',
                              _connection)
    return True