Esempio n. 1
0
 def _spawn_lot_owner_household(self, zone_owner_household,
                                zone_household_is_active_household):
     current_time = services.time_service().sim_now
     any_household_members_spawned = False
     for sim_info in zone_owner_household.sim_info_gen():
         result = self._should_spawn_lot_owner_sim(
             sim_info, zone_household_is_active_household)
         logger.debug('Should spawn household sim:{} {}',
                      sim_info,
                      bool(result),
                      owner='sscholl')
         if result:
             any_household_members_spawned |= self._spawn_sim(
                 sim_info, startup_location=result.startup_location)
         elif sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
             any_household_members_spawned = True
         else:
             while not sim_info.is_instanced(
                     allow_hidden_flags=ALL_HIDDEN_REASONS) and (
                         not sim_info.is_dead
                         and sim_info.game_time_bring_home
                         is not None) and self._bring_sims_home:
                 time_to_expire = DateAndTime(sim_info.game_time_bring_home)
                 if current_time < time_to_expire:
                     time_till_spawn = time_to_expire - current_time
                     self._return_sim_to_home_lot_alarm_handles.add(
                         alarms.add_alarm(sim_info, time_till_spawn,
                                          self.return_sim_to_home_lot))
     return any_household_members_spawned
Esempio n. 2
0
 def _should_spawn_lot_owner_sim(self, sim_info,
                                 zone_household_is_active_household):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return ShouldSpawnResult(False)
     current_zone = services.current_zone()
     save_game_data = services.get_persistence_service(
     ).get_save_game_data_proto()
     if zone_household_is_active_household and (
             current_zone.is_first_visit_to_zone
             or save_game_data.save_slot.active_household_id !=
             sim_info.household_id):
         return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
     if current_zone.lot_owner_household_changed_between_save_and_load():
         return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
     if self._should_bring_home_to_current_lot(sim_info):
         return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
     if sim_info in self._sim_infos_saved_in_zone:
         hint = ShouldSpawnResult.CURRENT_POSITION
         if sim_info.serialization_option == sims.sim_info_types.SimSerializationOption.UNDECLARED:
             hint = ShouldSpawnResult.SPAWNER_POSITION
         return ShouldSpawnResult(True, hint)
     if sim_info in self._sim_infos_saved_in_open_street:
         if current_zone.time_has_passed_in_world_since_open_street_save():
             return ShouldSpawnResult(True,
                                      ShouldSpawnResult.SPAWNER_POSITION)
         return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     return ShouldSpawnResult(False)
 def _on_spawn_sim_for_zone_spin_up_completed(self, client):
     for sim_info in self.values():
         if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS) or sim_info.is_selectable:
             sim_info.commodity_tracker.start_low_level_simulation()
         sim_info.set_default_data()
         while sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS) and not sim_info.is_npc:
             sim_info.aspiration_tracker.refresh_progress(sim_info)
     client.refresh_achievement_data()
     services.get_event_manager().unregister_unused_handlers()
     for sim_info in client.selectable_sims:
         while sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
             sim_info.aspiration_tracker.initialize_aspiration()
             sim_info.career_tracker.activate_career_aspirations()
     self._set_default_genealogy()
     for sim_info in self.values():
         sim_info.relationship_tracker.send_relationship_info()
Esempio n. 4
0
 def _should_spawn_zone_saved_sim(self, sim_info):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return ShouldSpawnResult(False)
     current_zone = services.current_zone()
     situation_manager = services.get_zone_situation_manager()
     if sim_info.lives_here:
         return ShouldSpawnResult(False)
     if self._handle_send_home_based_on_time(sim_info):
         return ShouldSpawnResult(False)
     if sim_info.is_selectable:
         return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     if current_zone.lot_owner_household_changed_between_save_and_load(
     ) or current_zone.venue_type_changed_between_save_and_load():
         sim_info.inject_into_inactive_zone(sim_info.household.home_zone_id)
         return ShouldSpawnResult(False)
     if current_zone.active_household_changed_between_save_and_load(
     ) or current_zone.game_clock.time_has_passed_in_world_since_zone_save(
     ):
         if services.current_zone(
         ).venue_service.venue.requires_visitation_rights:
             if situation_manager.get_npc_greeted_status_during_zone_fixup(
                     sim_info) != GreetedStatus.GREETED:
                 sim_info.inject_into_inactive_zone(
                     sim_info.household.home_zone_id)
                 return ShouldSpawnResult(False)
             return ShouldSpawnResult(True,
                                      ShouldSpawnResult.CURRENT_POSITION)
         else:
             return ShouldSpawnResult(True,
                                      ShouldSpawnResult.CURRENT_POSITION)
     return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
Esempio n. 5
0
 def visit(sim_info, depth):
     if sim_info not in closed_list:
         closed_list.add(sim_info)
         heapq.heappush(open_list, (depth, sim_info.id))
         if depth > 0:
             if sim_info.household_id != active_household_id and not sim_info.is_instanced(
                     allow_hidden_flags=ALL_HIDDEN_REASONS):
                 prune_list.add(sim_info)
 def _spawn_lot_owner_household(self, zone_owner_household, zone_household_is_active_household):
     current_time = services.time_service().sim_now
     any_household_members_spawned = False
     for sim_info in zone_owner_household.sim_info_gen():
         result = self._should_spawn_lot_owner_sim(sim_info, zone_household_is_active_household)
         logger.debug('Should spawn household sim:{} {}', sim_info, bool(result), owner='sscholl')
         if result:
             any_household_members_spawned |= self._spawn_sim(sim_info, startup_location=result.startup_location)
         elif sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
             any_household_members_spawned = True
         else:
             while not sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS) and (not sim_info.is_dead and sim_info.game_time_bring_home is not None) and self._bring_sims_home:
                 time_to_expire = DateAndTime(sim_info.game_time_bring_home)
                 if current_time < time_to_expire:
                     time_till_spawn = time_to_expire - current_time
                     self._return_sim_to_home_lot_alarm_handles.add(alarms.add_alarm(sim_info, time_till_spawn, self.return_sim_to_home_lot))
     return any_household_members_spawned
Esempio n. 7
0
 def get_sims_at_home(self):
     at_home_sim_ids = set()
     for sim_info in self.sim_info_gen():
         while sim_info.zone_id == self.home_zone_id and not sim_info.is_instanced(
                 allow_hidden_flags=HiddenReasonFlag.NOT_INITIALIZED
         ) and not sim_info.career_tracker.currently_during_work_hours:
             at_home_sim_ids.add(sim_info.id)
     return at_home_sim_ids
Esempio n. 8
0
 def _on_spawn_sim_for_zone_spin_up_completed(self, client):
     for sim_info in self.values():
         if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS
                                  ) or sim_info.is_selectable:
             sim_info.commodity_tracker.start_low_level_simulation()
         sim_info.set_default_data()
         while sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS
                                     ) and not sim_info.is_npc:
             sim_info.aspiration_tracker.refresh_progress(sim_info)
     client.refresh_achievement_data()
     services.get_event_manager().unregister_unused_handlers()
     for sim_info in client.selectable_sims:
         while sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
             sim_info.aspiration_tracker.initialize_aspiration()
             sim_info.career_tracker.activate_career_aspirations()
     self._set_default_genealogy()
     for sim_info in self.values():
         sim_info.relationship_tracker.send_relationship_info()
 def _spawn_sim(self, sim_info, startup_location=DEFAULT):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return True
     if sim_info.is_baby:
         spawn_result = sims.baby.on_sim_spawn(sim_info)
     else:
         if startup_location is DEFAULT:
             startup_location = sim_info.startup_sim_location
         spawn_result = sims.sim_spawner.SimSpawner.spawn_sim(sim_info, sim_location=startup_location, from_load=True)
     return spawn_result
 def return_sim_to_home_lot(self, alarm_handle):
     self._return_sim_to_home_lot_alarm_handles.discard(alarm_handle)
     sim_info = alarm_handle.owner
     if sim_info is None or sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS) or sim_info.is_dead:
         return
     success = sims.sim_spawner.SimSpawner.spawn_sim(sim_info)
     if success:
         client = services.client_manager().get_client_by_household_id(sim_info.household_id)
         if client is not None:
             client.add_selectable_sim_info(sim_info)
Esempio n. 11
0
 def _spawn_sim(self, sim_info, startup_location=DEFAULT):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return True
     if sim_info.is_baby:
         spawn_result = sims.baby.on_sim_spawn(sim_info)
     else:
         if startup_location is DEFAULT:
             startup_location = sim_info.startup_sim_location
         spawn_result = sims.sim_spawner.SimSpawner.spawn_sim(
             sim_info, sim_location=startup_location, from_load=True)
     return spawn_result
Esempio n. 12
0
 def return_sim_to_home_lot(self, alarm_handle):
     self._return_sim_to_home_lot_alarm_handles.discard(alarm_handle)
     sim_info = alarm_handle.owner
     if sim_info is None or sim_info.is_instanced(
             allow_hidden_flags=ALL_HIDDEN_REASONS) or sim_info.is_dead:
         return
     success = sims.sim_spawner.SimSpawner.spawn_sim(sim_info)
     if success:
         client = services.client_manager().get_client_by_household_id(
             sim_info.household_id)
         if client is not None:
             client.add_selectable_sim_info(sim_info)
Esempio n. 13
0
 def _should_spawn_open_street_saved_sim(self, sim_info):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return ShouldSpawnResult(False)
     current_zone = services.current_zone()
     if sim_info.lives_here:
         return ShouldSpawnResult(False)
     if self._handle_send_home_based_on_time(sim_info):
         return ShouldSpawnResult(False)
     if sim_info.is_selectable:
         return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     if current_zone.time_has_passed_in_world_since_open_street_save():
         sim_info.inject_into_inactive_zone(sim_info.household.home_zone_id)
         return ShouldSpawnResult(False)
     return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
 def _should_spawn_open_street_saved_sim(self, sim_info):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return ShouldSpawnResult(False)
     current_zone = services.current_zone()
     if sim_info.lives_here:
         return ShouldSpawnResult(False)
     if self._handle_send_home_based_on_time(sim_info):
         return ShouldSpawnResult(False)
     if sim_info.is_selectable:
         return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     if current_zone.time_has_passed_in_world_since_open_street_save():
         sim_info.inject_into_inactive_zone(sim_info.household.home_zone_id)
         return ShouldSpawnResult(False)
     return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
 def _should_spawn_lot_owner_sim(self, sim_info, zone_household_is_active_household):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return ShouldSpawnResult(False)
     current_zone = services.current_zone()
     save_game_data = services.get_persistence_service().get_save_game_data_proto()
     if zone_household_is_active_household and (current_zone.is_first_visit_to_zone or save_game_data.save_slot.active_household_id != sim_info.household_id):
         return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
     if current_zone.lot_owner_household_changed_between_save_and_load():
         return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
     if self._should_bring_home_to_current_lot(sim_info):
         return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
     if sim_info in self._sim_infos_saved_in_zone:
         hint = ShouldSpawnResult.CURRENT_POSITION
         if sim_info.serialization_option == sims.sim_info_types.SimSerializationOption.UNDECLARED:
             hint = ShouldSpawnResult.SPAWNER_POSITION
         return ShouldSpawnResult(True, hint)
     if sim_info in self._sim_infos_saved_in_open_street:
         if current_zone.time_has_passed_in_world_since_open_street_save():
             return ShouldSpawnResult(True, ShouldSpawnResult.SPAWNER_POSITION)
         return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     return ShouldSpawnResult(False)
 def _should_spawn_zone_saved_sim(self, sim_info):
     if sim_info.is_instanced(allow_hidden_flags=ALL_HIDDEN_REASONS):
         return ShouldSpawnResult(False)
     current_zone = services.current_zone()
     situation_manager = services.get_zone_situation_manager()
     if sim_info.lives_here:
         return ShouldSpawnResult(False)
     if self._handle_send_home_based_on_time(sim_info):
         return ShouldSpawnResult(False)
     if sim_info.is_selectable:
         return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     if current_zone.lot_owner_household_changed_between_save_and_load() or current_zone.venue_type_changed_between_save_and_load():
         sim_info.inject_into_inactive_zone(sim_info.household.home_zone_id)
         return ShouldSpawnResult(False)
     if current_zone.active_household_changed_between_save_and_load() or current_zone.game_clock.time_has_passed_in_world_since_zone_save():
         if services.current_zone().venue_service.venue.requires_visitation_rights:
             if situation_manager.get_npc_greeted_status_during_zone_fixup(sim_info) != GreetedStatus.GREETED:
                 sim_info.inject_into_inactive_zone(sim_info.household.home_zone_id)
                 return ShouldSpawnResult(False)
             return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
         else:
             return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
     return ShouldSpawnResult(True, ShouldSpawnResult.CURRENT_POSITION)
Esempio n. 17
0
 def instanced_sims_gen(self, allow_hidden_flags=0):
     for sim_info in self._sim_infos:
         while sim_info.is_instanced(allow_hidden_flags=allow_hidden_flags):
             yield sim_info.get_sim_instance(
                 allow_hidden_flags=allow_hidden_flags)