Beispiel #1
0
 def perform_test(self, tooltip):
     lot_decoration_service = services.lot_decoration_service()
     if lot_decoration_service is None:
         return TestResult(False, 'Lot decoration service not available.', tooltip=tooltip)
     custom_decorations_test = _LotDecorationHasCustomDecorationsTest(_decoration_occasion=self._decoration_occasion)
     result = custom_decorations_test.perform_test(tooltip)
     if not result:
         holiday_decorations_test = _LotDecorationDecoratableHolidayTest(_decoration_occasion=self._decoration_occasion)
         result = holiday_decorations_test.perform_test(tooltip)
     return result
Beispiel #2
0
 def perform_test(self, tooltip):
     lot_decoration_service = services.lot_decoration_service()
     if lot_decoration_service is None:
         return TestResult(False, 'Lot decoration service not available.', tooltip=tooltip)
     deco_type_id = lot_decoration_service.get_active_lot_decoration_type_id()
     if deco_type_id is None:
         return TestResult(False, 'Could not find data for lot with zone id.', services.current_zone_id(), tooltip=tooltip)
     if deco_type_id == 0:
         return TestResult(False, 'Lot is set to everyday decorations. zone_id {}', services.current_zone_id(), tooltip=tooltip)
     return TestResult.TRUE
Beispiel #3
0
 def perform_test(self, tooltip):
     lot_decoration_service = services.lot_decoration_service()
     if lot_decoration_service is None:
         return TestResult(False, 'Lot decoration service not available.', tooltip=tooltip)
     deco_type_id = self.occasion()
     if deco_type_id is None:
         if self._decoration_occasion is not None:
             return TestResult(False, 'Testing for holiday decorations when there is no current or upcoming holiday.', tooltip=tooltip)
         deco_type_id = 0
     if not lot_decoration_service.does_lot_have_custom_decorations(deco_type_id):
         return TestResult(False, 'Lot has no custom decorations for id {}.', self.occasion(), tooltip=tooltip)
     return TestResult.TRUE
Beispiel #4
0
 def clear_lot_ownership(self, zone_id):
     zone_data_proto = services.get_persistence_service(
     ).get_zone_proto_buff(zone_id)
     if zone_data_proto is not None:
         zone_data_proto.household_id = 0
         lot_decoration_service = services.lot_decoration_service()
         neighborhood_proto = services.get_persistence_service(
         ).get_neighborhood_proto_buff(zone_data_proto.neighborhood_id)
         for lot_owner_info in neighborhood_proto.lots:
             if lot_owner_info.zone_instance_id == zone_id:
                 lot_owner_info.ClearField('lot_owner')
                 if lot_decoration_service is not None:
                     lot_decoration_service.handle_lot_owner_changed(
                         zone_id, None)
                 break
 def _run_pre_holiday(self, from_load=False):
     self._state = HolidayState.PRE_DAY
     now = services.time_service().sim_now
     time_to_holiday_start = now.time_till_next_day_time(
         HolidayTuning.MAIN_HOLIDAY_START_TIME)
     self._holiday_start_time = now + time_to_holiday_start
     self._holiday_alarm = alarms.add_alarm(self, time_to_holiday_start,
                                            lambda _: self._run_holiday())
     active_household = services.active_household()
     active_household.holiday_tracker.preactivate_holiday(self.holiday_id)
     self._active_household_id = active_household.id
     lot_decoration_service = services.lot_decoration_service()
     if lot_decoration_service is not None:
         lot_decoration_service.request_holiday_decorations(
             self, from_load=from_load)
 def _run_holiday(self, from_load=False):
     self._state = HolidayState.RUNNING
     if not from_load:
         self._holiday_end_time = services.time_service(
         ).sim_now + HolidayTuning.HOLIDAY_DURATION()
         holiday_duration = HolidayTuning.HOLIDAY_DURATION()
     else:
         holiday_duration = self._holiday_end_time - services.time_service(
         ).sim_now
     self._holiday_alarm = alarms.add_alarm(self, holiday_duration,
                                            self._holiday_end_callback)
     active_household = services.active_household()
     holiday_tracker = active_household.holiday_tracker
     if holiday_tracker.is_holiday_cancelled(self.holiday_id):
         return
     holiday_tracker.activate_holiday(self.holiday_id, from_load=from_load)
     self._active_household_id = active_household.id
     lot_decoration_service = services.lot_decoration_service()
     if lot_decoration_service is not None:
         lot_decoration_service.request_holiday_decorations(
             self, from_load=from_load)
     if from_load:
         (situation_ids, sims_needing_situations
          ) = holiday_tracker.load_holiday_situations(self.holiday_id)
         self._situation_ids.extend(situation_ids)
         if not sims_needing_situations:
             self._register_situation_ended_callbacks()
             return
     else:
         sims_needing_situations = [
             sim_info for sim_info in active_household.sim_infos
             if sim_info.is_human
         ]
     holiday_service = services.holiday_service()
     holiday_goals = list(
         tradition.situation_goal
         for tradition in holiday_service.get_holiday_traditions(
             self.holiday_id))
     for sim_info in sims_needing_situations:
         situation_id = self._create_holiday_situation(
             sim_info, holiday_goals)
     self._register_situation_ended_callbacks()
 def cleanup(self, from_service_stop=False):
     if self._holiday_alarm is not None:
         self._holiday_alarm.cancel()
         self._holiday_alarm = None
     services.calendar_service().remove_on_calendar(self.uid)
     super().cleanup(from_service_stop=from_service_stop)
     if self._state == HolidayState.PRE_DAY:
         household = services.household_manager().get(
             self._active_household_id)
         if household is not None:
             household.holiday_tracker.deactivate_pre_holiday()
     elif self._state == HolidayState.RUNNING:
         household = services.household_manager().get(
             self._active_household_id)
         if household is not None and not household.holiday_tracker.is_holiday_cancelled(
                 self.holiday_id):
             household.holiday_tracker.deactivate_holiday()
     if self._state in (HolidayState.PRE_DAY, HolidayState.RUNNING,
                        HolidayState.SHUTDOWN):
         lot_decoration_service = services.lot_decoration_service()
         if lot_decoration_service is not None:
             lot_decoration_service.cancel_decoration_requests_for(self)
 def on_holiday_modified(self, holiday_id, added_traditions, removed_traditions, ordered_traditions, theme_updated):
     if self._pre_day_holiday_id == holiday_id:
         if removed_traditions:
             for tradition in tuple(self._traditions[self._pre_day_holiday_id]):
                 if type(tradition) in removed_traditions:
                     tradition.deactivate_pre_holiday()
                     self._traditions[holiday_id].remove(tradition)
         for tradition_type in added_traditions:
             tradition = tradition_type()
             self._traditions[holiday_id].append(tradition)
             tradition.activate_pre_holiday()
         else:
             self.send_active_holiday_info_message(DistributorOps_pb2.SendActiveHolidayInfo.UPDATE)
     elif self._active_holiday_id == holiday_id:
         if removed_traditions:
             for tradition in tuple(self._traditions[self._active_holiday_id]):
                 if type(tradition) in removed_traditions:
                     tradition.deactivate_holiday(from_customization=True)
                     self._traditions[holiday_id].remove(tradition)
         for tradition_type in added_traditions:
             tradition = tradition_type()
             self._traditions[holiday_id].append(tradition)
             tradition.activate_holiday(from_customization=True)
         for situation in services.get_zone_situation_manager().get_situations_by_type(HolidayTuning.HOLIDAY_SITUATION):
             situation.on_holiday_data_changed(added_traditions, removed_traditions, ordered_traditions)
         self.send_active_holiday_info_message(DistributorOps_pb2.SendActiveHolidayInfo.UPDATE)
     if theme_updated and self.get_active_or_upcoming_holiday() == holiday_id:
         lot_decoration_service = services.lot_decoration_service()
         if lot_decoration_service is not None:
             lot_decoration_service.refresh_neighborhood_decorations()
     drama_scheduler = services.drama_scheduler_service()
     calendar_service = services.calendar_service()
     for drama_node in itertools.chain(drama_scheduler.active_nodes_gen(), drama_scheduler.scheduled_nodes_gen()):
         if drama_node.drama_node_type != DramaNodeType.HOLIDAY:
             continue
         if drama_node.holiday_id != holiday_id:
             continue
         calendar_service.update_on_calendar(drama_node, advance_notice_time=HolidayTuning.HOLIDAY_DURATION())
Beispiel #9
0
 def _do_behavior(self):
     lot_decoration_service = services.lot_decoration_service()
     if lot_decoration_service is None:
         return
     self.behavior(lot_decoration_service, self.interaction).perform()
def apply_decoration(decoration:TunableInstanceParam(sims4.resources.Types.LOT_DECORATION), location:DecorationLocation, _connection=None):
    services.lot_decoration_service().apply_decoration_for_holiday(decoration, location, services.active_household().holiday_tracker.get_active_or_upcoming_holiday())
def apply_preset_to_zone(preset:TunableInstanceParam(sims4.resources.Types.LOT_DECORATION_PRESET), zone_id:int=None, _connection=None):
    if zone_id is None:
        zone_id = services.current_zone_id()
    services.lot_decoration_service().decorate_zone_for_holiday(zone_id, services.active_household().holiday_tracker.get_active_or_upcoming_holiday(), preset_override=preset)
def apply_preset_to_neighbors(preset:TunableInstanceParam(sims4.resources.Types.LOT_DECORATION_PRESET), _connection=None):
    services.lot_decoration_service().decorate_neighborhood_for_holiday(services.active_household().holiday_tracker.get_active_or_upcoming_holiday(), preset_override=preset)
def reset_lot_decorations_to_default(holiday_id:int, _connection=None):
    services.lot_decoration_service().reset_decoration_to_holiday_default(services.active_household().holiday_tracker.get_active_or_upcoming_holiday())
def remove_decoration(location:DecorationLocation, _connection=None):
    services.lot_decoration_service().remove_decoration_for_holiday(location, services.active_household().holiday_tracker.get_active_or_upcoming_holiday())
def generate_decoratable_lots_view():
    lot_decoration_service = services.lot_decoration_service()
    if lot_decoration_service is None:
        return []
    return lot_decoration_service.get_lot_decorations_gsi_data()