Ejemplo n.º 1
0
 def on_all_households_and_sim_infos_loaded(self, client):
     self._has_started_up = True
     save_slot_data = services.get_persistence_service().get_save_slot_proto_buff()
     drama_node_manager = services.get_instance_manager(sims4.resources.Types.DRAMA_NODE)
     for drama_proto in save_slot_data.gameplay_data.drama_schedule_service.drama_nodes:
         node_type = drama_node_manager.get(drama_proto.node_type)
         if node_type is None:
             continue
         drama_node_inst = node_type()
         if drama_node_inst.load(drama_proto):
             self._scheduled_nodes[drama_node_inst.uid] = drama_node_inst
         else:
             drama_node_inst.cleanup()
     for drama_proto in save_slot_data.gameplay_data.drama_schedule_service.running_nodes:
         node_type = drama_node_manager.get(drama_proto.node_type)
         if node_type is None:
             continue
         drama_node_inst = node_type()
         if drama_node_inst.load(drama_proto, schedule_alarm=False):
             self._active_nodes[drama_node_inst.uid] = drama_node_inst
             drama_node_inst.resume()
         else:
             drama_node_inst.cleanup()
     for cooldown_proto in save_slot_data.gameplay_data.drama_schedule_service.cooldown_nodes:
         node_type = drama_node_manager.get(cooldown_proto.node_type)
         if node_type is None:
             continue
         time = DateAndTime(cooldown_proto.completed_time)
         self._cooldown_nodes[node_type] = time
     for cooldown_group_proto in save_slot_data.gameplay_data.drama_schedule_service.cooldown_groups:
         time = DateAndTime(cooldown_proto.completed_time)
         self._cooldown_groups[CooldownGroup(cooldown_group_proto.group)] = time
     self._drama_nodes_on_permanent_cooldown.update(save_slot_data.gameplay_data.drama_schedule_service.drama_nodes_on_permanent_cooldown)
     self._drama_node_groups_on_permanent_cooldown.update(CooldownGroup(cooldown_group) for cooldown_group in save_slot_data.gameplay_data.drama_schedule_service.cooldown_groups_on_permanent_cooldown)
     self._startup_buckets_used = {DramaNodeScoringBucket(bucket) for bucket in save_slot_data.gameplay_data.drama_schedule_service.startup_drama_node_buckets_used}
Ejemplo n.º 2
0
 def setup(self, gameplay_zone_data=None, save_slot_data=None):
     if gameplay_zone_data is None:
         return
     world_game_time = self._initial_ticks
     if save_slot_data is not None and save_slot_data.HasField(
             'gameplay_data'):
         world_game_time = save_slot_data.gameplay_data.world_game_time
         self._zone_init_world_game_time = DateAndTime(world_game_time)
     initial_time = world_game_time
     if gameplay_zone_data.HasField('game_time'):
         saved_ticks = gameplay_zone_data.game_time
         tick_diff = world_game_time - saved_ticks
         time_diff = TimeSpan(tick_diff)
         self._time_of_last_save = DateAndTime(saved_ticks)
         if time_diff.in_minutes(
         ) < PersistenceTuning.MAX_LOT_SIMULATE_ELAPSED_TIME:
             initial_time = saved_ticks
         else:
             max_minutes = date_and_time.create_date_and_time(
                 minutes=PersistenceTuning.MAX_LOT_SIMULATE_ELAPSED_TIME)
             initial_time = world_game_time - max_minutes.absolute_ticks()
     self._initial_ticks = initial_time
     if gameplay_zone_data.HasField('clock_speed_mode'):
         self._client_connect_speed = ClockSpeedMode(
             gameplay_zone_data.clock_speed_mode)
     else:
         self._client_connect_speed = ClockSpeedMode.NORMAL
Ejemplo n.º 3
0
 def load_data(self, business_save_data, is_legacy=False):
     self._is_open = business_save_data.is_open
     self._markup_multiplier = business_save_data.markup
     self._grand_opening = business_save_data.grand_opening
     self._daily_revenue = business_save_data.daily_revenue
     self._daily_items_sold = business_save_data.daily_items_sold
     if self._is_open:
         self._open_time = DateAndTime(business_save_data.open_time)
         self._distribute_business_open_status(is_open=self._is_open, open_time=self._open_time.absolute_ticks())
     else:
         self._distribute_business_open_status(self._is_open)
     for funds_category_msg in business_save_data.funds_category_tracker_data:
         self._funds_category_tracker[funds_category_msg.funds_category] = funds_category_msg.amount
     self._funds = BusinessFunds(self._owner_household_id, business_save_data.funds, self)
     if is_legacy:
         self._employee_manager.load_legacy_data(business_save_data)
     else:
         self._buff_bucket_totals.clear()
         for buff_bucket_total_msg in business_save_data.buff_bucket_totals:
             self._buff_bucket_totals[buff_bucket_total_msg.buff_bucket] = buff_bucket_total_msg.buff_bucket_total
         self._last_off_lot_update = DateAndTime(business_save_data.last_off_lot_update)
         self._star_rating_value = business_save_data.star_rating_value
         self._buff_bucket_size = business_save_data.buff_bucket_size
         self._customer_manager.load_data(business_save_data)
         self._employee_manager.load_data(business_save_data.employee_payroll)
Ejemplo n.º 4
0
 def set_load_state_from_msg(self, effect_data):
     if effect_data is not None:
         effect_msg = GameplaySaveData_pb2.PersistableCivicPolicyStreetConditionalLayerEffectData(
         )
         effect_msg.ParseFromString(effect_data)
         if effect_msg.start_tick == self.CHANGE_PENDING_SENTINEL_VALUE:
             self._change_pending = True
             self._last_change_start_time = DateAndTime(0)
         else:
             self._last_change_start_time = DateAndTime(
                 effect_msg.start_tick)
Ejemplo n.º 5
0
 def _load_custom_data(self, reader):
     holiday_start_time_ticks = reader.read_uint64(HOLIDAY_START_TIME_TOKEN,
                                                   None)
     if holiday_start_time_ticks is not None:
         self._holiday_start_time = DateAndTime(holiday_start_time_ticks)
     holiday_end_time_ticks = reader.read_uint64(HOLIDAY_END_TIME_TOKEN,
                                                 None)
     if holiday_end_time_ticks is not None:
         self._holiday_end_time = DateAndTime(holiday_end_time_ticks)
     if self._holiday_start_time and not self._holiday_end_time and self._holiday_start_time + HolidayTuning.HOLIDAY_DURATION(
     ) < services.time_service().sim_now:
         return False
     return True
Ejemplo n.º 6
0
 def reset_data(self):
     self._completed_milestones = set()
     self._completed_objectives = set()
     self._sent_milestones = set()
     self._sent_objectives = set()
     self._data_object = EventDataObject()
     self._tracker_dirty = False
     self._dirty_objective_state = {}
     self._last_objective_state = {}
     self.sim_time_on_connect = DateAndTime(0)
     self.server_time_on_connect = DateAndTime(0)
     self.sim_time_last_update = DateAndTime(0)
     self.server_time_last_update = DateAndTime(0)
     self.latest_objective = None
Ejemplo n.º 7
0
 def load_npc_record(self, record_msg):
     self._service_id = record_msg.service_type
     self._preferred_service_sim_ids.clear()
     self._fired_service_sim_ids.clear()
     self._preferred_service_sim_ids = set(record_msg.preferred_sim_ids)
     self._fired_service_sim_ids = set(record_msg.fired_sim_ids)
     self.hired = record_msg.hired
     if record_msg.HasField('time_last_started_service'):
         self.time_last_started_service = DateAndTime(record_msg.time_last_started_service)
     self.recurring = record_msg.recurring
     if record_msg.HasField('time_last_finished_service'):
         self.time_last_finished_service = DateAndTime(record_msg.time_last_finished_service)
     if record_msg.HasField('user_specified_data_id'):
         self.user_specified_data_id = record_msg.user_specified_data_id
Ejemplo n.º 8
0
 def load_holiday_tracker(self, msg):
     if msg.HasField('cancelled_holiday_type'):
         self._cancelled_holiday = msg.cancelled_holiday_type
         self._cancelled_holiday_time = DateAndTime(msg.cancelled_holiday_time)
         if self._cancelled_holiday_time + create_time_span(days=1) < services.time_service().sim_now:
             self._cancelled_holiday = None
             self._cancelled_holiday_time = None
     if msg.HasField('situation_holiday_type'):
         self._situation_holiday_type = msg.situation_holiday_type
         self._situation_holiday_time = DateAndTime(msg.situation_holiday_time)
         for situation_seed_proto in msg.situations:
             seed = SituationSeed.deserialize_from_proto(situation_seed_proto)
             if seed is not None:
                 self._situation_seeds.append(seed)
Ejemplo n.º 9
0
 def load(self, save_data, skip_load=False):
     self._careers.clear()
     for career_save_data in save_data.careers:
         career_uid = career_save_data.career_uid
         career = services.get_instance_manager(
             sims4.resources.Types.CAREER).get(career_uid)
         while career is not None:
             career_inst = career(self._sim_info)
             career_inst._current_track = services.get_instance_manager(
                 sims4.resources.Types.CAREER_TRACK).get(
                     career_save_data.track_uid)
             career_inst._level = career_save_data.track_level
             career_inst._user_level = career_save_data.user_display_level
             career_inst._company_name = career_save_data.company_name_hash
             if skip_load:
                 career_inst._join_time = services.time_service().sim_now
             else:
                 career_inst._join_time = DateAndTime(
                     career_save_data.join_time)
                 career_inst._attended_work = career_save_data.attended_work
                 career_inst._called_in_sick = career_save_data.called_in_sick
                 career_inst._pending_promotion = career_save_data.pending_promotion
                 career_inst._career_situation_id = career_save_data.active_situation_id
                 if career_save_data.career_situation_guid != 0:
                     career_inst._career_situation = services.get_instance_manager(
                         sims4.resources.Types.CAREER_SITUATION).get(
                             career_save_data.career_situation_guid)
                 if career_save_data.HasField('current_work_start'):
                     career_inst._current_work_start = DateAndTime(
                         career_save_data.current_work_start)
                     career_inst._current_work_end = DateAndTime(
                         career_save_data.current_work_end)
                     career_inst._current_work_duration = TimeSpan(
                         career_save_data.current_work_duration)
             career_inst.career_start(is_load=True)
             self._careers[career_uid] = career_inst
     self._career_history.clear()
     for history_entry in save_data.career_history:
         if skip_load and history_entry.career_uid not in self._careers:
             pass
         self._career_history[history_entry.career_uid] = CareerHistory(
             history_entry.track_level, history_entry.user_display_level,
             DateAndTime(history_entry.time_left), history_entry.track_uid,
             history_entry.highest_level)
     self._retirement = None
     if save_data.HasField('retirement_career_uid'):
         retired_career = save_data.retirement_career_uid
         self._retirement = Retirement(self._sim_info, retired_career)
Ejemplo n.º 10
0
 def load(self, statistic_component_message):
     statistics_to_load = statistic_component_message.Extensions[
         persistence_protocols.PersistableStatisticsTracker.
         persistable_data].statistics
     if statistics_to_load:
         self.get_statistic_tracker()
         self._statistic_tracker.load(statistics_to_load)
     if self._commodity_tracker is not None:
         commodity_data = statistic_component_message.Extensions[
             persistence_protocols.PersistableCommodityTracker.
             persistable_data]
         self._commodity_tracker.load(commodity_data.commodities)
         skill_component_data = statistic_component_message.Extensions[
             persistence_protocols.PersistableSkillTracker.persistable_data]
         self._commodity_tracker.load(skill_component_data.skills)
         ranked_statistic_data = statistic_component_message.Extensions[
             persistence_protocols.PersistableRankedStatisticTracker.
             persistable_data]
         self._commodity_tracker.load(
             ranked_statistic_data.ranked_statistics)
         if not self.owner.is_sim:
             if commodity_data.time_of_last_save > 0:
                 time_of_last_save = DateAndTime(
                     commodity_data.time_of_last_save)
                 for commodity in tuple(self._commodity_tracker):
                     if commodity.needs_fixup_on_load_for_objects():
                         commodity.fixup_for_time(time_of_last_save,
                                                  self.is_locked(commodity),
                                                  decay_enabled=True)
 def on_cleanup_zone_objects(self):
     super().on_cleanup_zone_objects()
     persistence_service = services.get_persistence_service()
     plex_service = services.get_plex_service()
     plex_zone_ids = plex_service.get_plex_zones_in_group(
         services.current_zone_id())
     last_save_ticks = None
     for zone_id in plex_zone_ids:
         zone_data = persistence_service.get_zone_proto_buff(zone_id)
         gameplay_zone_data = zone_data.gameplay_zone_data
         if not gameplay_zone_data.HasField('game_time'):
             continue
         if not last_save_ticks is None:
             if last_save_ticks < gameplay_zone_data.game_time:
                 last_save_ticks = gameplay_zone_data.game_time
         last_save_ticks = gameplay_zone_data.game_time
     if last_save_ticks is not None:
         last_save_time = DateAndTime(last_save_ticks)
         next_cleanup_time = last_save_time.time_of_next_day_time(
             ApartmentZoneDirectorMixin.COMMON_AREA_CLEANUP.time_of_day)
         if next_cleanup_time < services.time_service().sim_now:
             self._run_common_area_cleanup()
     owning_household = services.owning_household_of_active_lot()
     if owning_household is not None and not owning_household.has_home_zone_been_active(
     ):
         self._run_new_tenant_cleanup()
Ejemplo n.º 12
0
 def _bring_home_resident_if_overdue(self, sim_info):
     current_zone = services.current_zone()
     if sim_info.zone_id == current_zone.id:
         return
     if sim_info.is_pet and not any(household_sim_info.is_human and (household_sim_info.is_child_or_older and sim_info.zone_id == household_sim_info.zone_id) for household_sim_info in sim_info.household.sim_info_gen()):
         self._bring_sim_home(sim_info)
         return
     current_region = current_zone.region
     sim_region = region.get_region_instance_from_zone_id(sim_info.zone_id)
     if sim_region is not None and not sim_region.is_region_compatible(current_region):
         return
     if sim_info.career_tracker is None:
         logger.error('Career Tracker for resident Sim {} is unexpectedly None.'.format(sim_info))
     else:
         career = sim_info.career_tracker.get_at_work_career()
         if career is not None and career.is_at_active_event:
             return
     if services.hidden_sim_service().is_hidden(sim_info.id):
         return
     if sim_info.zone_id == 0 or sim_info.game_time_bring_home is None:
         self._bring_sim_home(sim_info)
         return
     bring_home_time = DateAndTime(sim_info.game_time_bring_home)
     current_time = services.time_service().sim_now
     if current_time >= bring_home_time:
         self._bring_sim_home(sim_info)
     else:
         time_till_spawn = bring_home_time - current_time
         self._return_sim_to_home_lot_alarm_handles.add(alarms.add_alarm(sim_info, time_till_spawn, self._return_sim_to_current_lot))
Ejemplo n.º 13
0
 def load_zone(self):
     zone_data_proto = self._get_zone_proto()
     self.neighborhood_id = zone_data_proto.neighborhood_id
     self.open_street_id = zone_data_proto.world_id
     self.service_manager.load_all_services(zone_data=zone_data_proto)
     self._first_visit_to_zone = not protocol_buffer_utils.has_field(
         zone_data_proto.gameplay_zone_data, 'venue_type_id_on_save')
     open_street_data = services.get_persistence_service(
     ).get_open_street_proto_buff(self.open_street_id)
     if open_street_data is not None:
         self._time_of_last_open_street_save = DateAndTime(
             open_street_data.sim_time_on_save)
     spawn_points = {}
     if zone_data_proto.spawn_point_ids:
         for (index,
              spawn_point_id) in enumerate(zone_data_proto.spawn_point_ids):
             spawn_point = self._spawner_data[index]
             spawn_point.spawn_point_id = spawn_point_id
             spawn_points[spawn_point_id] = spawn_point
     else:
         for (index, spawn_point) in enumerate(self._spawner_data.values()):
             spawn_point_id = id_generator.generate_object_id()
             spawn_point.spawn_point_id = spawn_point_id
             spawn_points[spawn_point_id] = spawn_point
     self._spawner_data = spawn_points
     self.lot.load(zone_data_proto.gameplay_zone_data)
     for spawn_point in self._spawner_data.values():
         while spawn_point.has_tag(
                 SpawnPoint.
                 ARRIVAL_SPAWN_POINT_TAG) and spawn_point.lot_id == self.lot.lot_id:
             self._active_lot_arrival_spawn_point = spawn_point
     return True
Ejemplo n.º 14
0
 def load_career_history(sim_info, career_history_proto):
     career = services.get_instance_manager(
         sims4.resources.Types.CAREER).get(career_history_proto.career_uid)
     if career is None:
         return
     career_track = services.get_instance_manager(
         sims4.resources.Types.CAREER_TRACK).get(
             career_history_proto.track_uid)
     if career_track is None:
         return
     level = career_history_proto.track_level
     user_level = career_history_proto.user_display_level
     overmax_level = career_history_proto.overmax_level
     highest_level = career_history_proto.highest_level
     daily_pay = career_history_proto.daily_pay
     if daily_pay == 0:
         daily_pay = career.get_daily_pay(sim_info=sim_info,
                                          career_track=career_track,
                                          career_level=level,
                                          overmax_level=overmax_level)
     deferred_rewards = career_history_proto.player_rewards_deferred
     return CareerHistory(
         career_track=career_track,
         level=level,
         user_level=user_level,
         overmax_level=overmax_level,
         highest_level=highest_level,
         time_of_leave=DateAndTime(career_history_proto.time_left),
         daily_pay=daily_pay,
         days_worked=career_history_proto.days_worked,
         active_days_worked=career_history_proto.active_days_worked,
         player_rewards_deferred=deferred_rewards,
         schedule_shift_type=career_history_proto.schedule_shift_type)
Ejemplo n.º 15
0
 def load(self, blacklist_data_proto):
     for blacklist_data in blacklist_data_proto.tag_data:
         try:
             tag = Tag(blacklist_data.tag)
         except KeyError:
             continue
         self._blacklist_times[tag] = DateAndTime(blacklist_data.time)
Ejemplo n.º 16
0
 def load(self, data=None):
     aspiration_manager = services.get_instance_manager(
         sims4.resources.Types.ASPIRATION)
     for org_status_info in data.org_status_map:
         self._organization_status[
             org_status_info.org_id] = org_status_info.membership_status
     for org_active_tasks in data.tasks_map:
         org_id = org_active_tasks.org_id
         self._organization_active_tasks[org_id] = {}
         for timed_aspiration_data in org_active_tasks.active_tasks:
             task = aspiration_manager.get(timed_aspiration_data.aspiration)
             if task is None:
                 continue
             task_data_org_info = TaskDataOrgInfo(
                 org_id=org_id,
                 task=task,
                 completed=timed_aspiration_data.completed,
                 end_time=DateAndTime(timed_aspiration_data.end_time))
             self.add_active_task(task_data_org_info)
             if task_data_org_info.completed:
                 organization_task = AspirationOrganizationTaskData(
                     None, task, org_id=org_id)
                 self._completed_tasks.append(
                     (organization_task, timed_aspiration_data))
     self._unenrolled_org_ids.extend(data.unenrolled_org_ids)
Ejemplo n.º 17
0
 def load(self, **_):
     self._clear()
     save_slot_data_msg = services.get_persistence_service(
     ).get_save_slot_proto_buff()
     if not save_slot_data_msg.gameplay_data.HasField(
             'object_lost_and_found'):
         return
     object_lost_and_found = save_slot_data_msg.gameplay_data.object_lost_and_found
     for object_locators in object_lost_and_found.locators:
         object_data = FileSerialization_pb2.ObjectData()
         object_data.ParseFromString(object_locators.object)
         if object_data is None:
             logger.error(
                 'Trying to load a locator with no object data. \n                zone_id: {}, open_street_id: {}, sim_id: {}, household_id: {}, \n                time_before_lost: {}, time_stamp: {}',
                 object_locators.zone_id, object_locators.open_street_id,
                 object_locators.sim_id, object_locators.household_id,
                 object_locators.time_before_lost,
                 object_locators.time_stamp.absolute_ticks())
         else:
             locator = self._raw_add_object_data(
                 object_locators.zone_id, object_locators.open_street_id,
                 object_data.object_id, object_locators.sim_id,
                 object_locators.household_id,
                 object_locators.time_before_lost,
                 DateAndTime(object_locators.time_stamp))
             locator.object_data = object_data
     for clone in object_lost_and_found.clones_to_delete:
         self.add_clone_id(clone.zone_id, clone.open_street_id,
                           clone.object_id)
Ejemplo n.º 18
0
 def load_data(self, owner_proto):
     bucks_perk_manager = services.get_instance_manager(
         sims4.resources.Types.BUCKS_PERK)
     for bucks_data in owner_proto.bucks_data:
         self.try_modify_bucks(bucks_data.bucks_type,
                               bucks_data.amount,
                               distribute=False,
                               from_load=True)
         for perk_data in bucks_data.unlocked_perks:
             perk_ref = bucks_perk_manager.get(perk_data.perk)
             if perk_ref is None:
                 logger.info(
                     'Trying to load unavailable BUCKS_PERK resource: {}',
                     perk_data.perk)
             else:
                 unlocked_by = bucks_perk_manager.get(
                     perk_data.unlock_reason)
                 timestamp = DateAndTime(perk_data.timestamp)
                 self._unlocked_perks[
                     perk_ref.associated_bucks_type][perk_ref] = PerkData(
                         unlocked_by, timestamp,
                         perk_data.currently_unlocked)
                 if not perk_data.currently_unlocked:
                     continue
                 self._award_buffs(perk_ref)
                 if perk_data.time_left:
                     self._set_up_temporary_perk_timer(
                         perk_ref, perk_data.time_left)
Ejemplo n.º 19
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
Ejemplo n.º 20
0
 def _set_expected_time(self, target_hours, target_minutes, days_ahead):
     clock = services.game_clock_service()
     self._current_date_and_time = clock.now()
     clock_days = int(self._current_date_and_time.absolute_days())
     time_span = self._current_date_and_time - DateAndTime(interval_in_sim_days(clock_days).in_ticks())
     current_date_and_time_minus_days = DateAndTime(time_span.in_ticks())
     clock_hours = int(current_date_and_time_minus_days.absolute_hours())
     time_span = current_date_and_time_minus_days - DateAndTime(interval_in_sim_hours(clock_hours).in_ticks())
     current_date_and_time_minus_hours = DateAndTime(time_span.in_ticks())
     clock_minutes = int(current_date_and_time_minus_hours.absolute_minutes())
     delta_days = days_ahead
     clock_day_minutes = clock_hours*60 + clock_minutes
     target_day_minutes = target_hours*60 + target_minutes
     delta_day_minutes = target_day_minutes - clock_day_minutes
     if delta_day_minutes < 0:
         delta_day_minutes += 1440
     self._expected_data_and_time = self._current_date_and_time + interval_in_sim_days(delta_days) + interval_in_sim_minutes(delta_day_minutes)
Ejemplo n.º 21
0
 def on_all_households_and_sim_infos_loaded(self, _):
     save_slot_data = services.get_persistence_service().get_save_slot_proto_buff()
     sim_info_manager = services.sim_info_manager()
     for sim_data in save_slot_data.gameplay_data.adoption_service.adoptable_sim_data:
         sim_info = sim_info_manager.get(sim_data.adoptable_sim_id)
         if sim_info is None:
             continue
         self._creation_times[sim_data.adoptable_sim_id] = DateAndTime(sim_data.creation_time)
Ejemplo n.º 22
0
 def __init__(self, owner):
     super().__init__(owner)
     self._last_user_directed_action_time = DateAndTime(0)
     self._last_autonomous_action_time = DateAndTime(0)
     self._last_no_result_time = None
     self._autonomy_skip_sis = set()
     self._autonomy_enabled = False
     self._full_autonomy_alarm_handle = None
     self._multitasking_roll = UNSET
     self._role_tracker = RoleStateTracker(owner)
     self._full_autonomy_request = None
     self._full_autonomy_element_handle = None
     self._sleep_buff_handle = None
     self._sleep_buff_alarms = {}
     self._sleep_buff_reset = None
     self._autonomy_settings = autonomy.settings.AutonomySettings()
     self._cached_mixer_interactions = []
Ejemplo n.º 23
0
 def load_time_of_last_value_change(self, data):
     if self.delayed_decay_rate is None:
         return
     if not data.time_of_last_value_change:
         return
     owner = self.tracker.owner
     if owner.is_sim and (not owner.is_npc
                          or self.delayed_decay_rate.npc_decay):
         last_save_time = services.current_zone().time_of_last_save()
         timer_start_time = DateAndTime(data.time_of_last_value_change)
         difference = timer_start_time - last_save_time
         self._time_of_last_value_change = services.time_service(
         ).sim_now + difference
         self._start_delayed_decay_timer()
         return
     self._time_of_last_value_change = DateAndTime(
         data.time_of_last_value_change)
Ejemplo n.º 24
0
 def load(self, event_data_blob):
     mood_manager = services.get_instance_manager(
         sims4.resources.Types.MOOD)
     for mood_data in event_data_blob.mood_data.mood_data:
         mood = mood_manager.get(mood_data.mood)
         if mood is None:
             continue
         self._last_time_in_mood[mood] = DateAndTime(
             mood_data.last_time_in_mood)
Ejemplo n.º 25
0
 def __init__(self):
     self._completed_milestones = set()
     self._completed_objectives = set()
     self._reset_objectives = set()
     self._sent_milestones = set()
     self._sent_objectives = set()
     self._data_object = EventDataObject()
     self._tracker_dirty = False
     self._dirty_objective_state = {}
     self._last_objective_state = {}
     self._unlocked_hidden_aspiration_tracks = set()
     self._sent_unlocked_hidden_aspiration_tracks = set()
     self.update_alarm_handle = None
     self.sim_time_on_connect = DateAndTime(0)
     self.server_time_on_connect = DateAndTime(0)
     self.sim_time_last_update = DateAndTime(0)
     self.server_time_last_update = DateAndTime(0)
     self.latest_objective = None
     self._event_trackers = {}
Ejemplo n.º 26
0
 def _handle_send_home_based_on_time(self, sim_info):
     if sim_info.lives_here:
         return False
     if sim_info.game_time_bring_home is None:
         return False
     time_to_expire = DateAndTime(sim_info.game_time_bring_home)
     if services.time_service().sim_now >= time_to_expire:
         sim_info.inject_into_inactive_zone(sim_info.household.home_zone_id)
         return True
     return False
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     reader = self._seed.custom_init_params_reader
     if reader is not None:
         obstacles = self.get_obstacles()
         if not obstacles:
             self._self_destruct()
         self._obstacle_ids = {obstacle.id for obstacle in obstacles}
         self._course_start_time = DateAndTime(
             reader.read_uint64(OBSTACLE_COURSE_START_TIME_TOKEN,
                                services.time_service().sim_now))
         self._course_end_time = DateAndTime(
             reader.read_uint64(OBSTACLE_COURSE_END_TIME_TOKEN,
                                services.time_service().sim_now))
     else:
         self._obstacle_ids = set()
         self._course_start_time = None
         self._course_end_time = None
     self._course_progress = ObstacleCourseProgress.NOT_STARTED
 def _load_custom_zone_director(self, zone_director_proto, reader):
     if reader is not None:
         aspiration_timeouts = reader.read_uint64s(ASPIRATION_TIMEOUTS, [])
         aspiration_manager = services.get_instance_manager(
             sims4.resources.Types.ASPIRATION)
         self._aspiration_timeouts = {
             aspiration_manager.get(aspiration_id): DateAndTime(timeout)
             for (aspiration_id, timeout) in zip(aspiration_timeouts[::2],
                                                 aspiration_timeouts[1::2])
         }
     super()._load_custom_zone_director(zone_director_proto, reader)
Ejemplo n.º 29
0
 def _load_custom_data(self, reader):
     self._calculated_audition_time = DateAndTime(
         reader.read_uint64(AUDITION_TIME_TOKEN, None))
     self._calculated_gig_time = DateAndTime(
         reader.read_uint64(GIG_TIME_TOKEN, None))
     self._rabbit_hole_id = reader.read_uint64(RABBIT_HOLE_ID_TOKEN, None)
     rabbit_hole_service = services.get_rabbit_hole_service()
     if not self._rabbit_hole_id:
         rabbit_hole_service = services.get_rabbit_hole_service()
         self._rabbit_hole_id = services.get_rabbit_hole_service(
         ).get_rabbit_hole_id_by_type(self._receiver_sim_info.id,
                                      self.audition_rabbit_hole)
     if self._rabbit_hole_id and rabbit_hole_service.is_in_rabbit_hole(
             self._receiver_sim_info.id,
             rabbit_hole_id=self._rabbit_hole_id):
         rabbit_hole_service.set_rabbit_hole_expiration_callback(
             self._receiver_sim_info.id, self._rabbit_hole_id,
             self._on_sim_return)
     self._send_career_ui_update()
     return True
Ejemplo n.º 30
0
 def load_gig(self, gig_proto_buff):
     self._upcoming_gig_time = DateAndTime(gig_proto_buff.gig_time)
     if self.gig_prep_tasks:
         self.prep_time_start(self._owner,
                              self.gig_prep_tasks,
                              self.guid64,
                              self.audio_on_prep_task_completion,
                              from_load=True)
     if gig_proto_buff.HasField('customer_sim_id'):
         self._customer_id = gig_proto_buff.customer_sim_id
     if gig_proto_buff.HasField('gig_attended'):
         self._gig_attended = gig_proto_buff.gig_attended