Exemple #1
0
def create_tuningless_superinteraction(affordance):
    create_tuningless_interaction(affordance)
    lock_instance_tunables(
        affordance,
        pre_add_autonomy_commodities=None,
        pre_run_autonomy_commodities=None,
        post_guaranteed_autonomy_commodities=None,
        post_run_autonomy_commodities=None,
        super_affordance_compatibility=None,
        basic_content=None,
        outfit_change=None,
        outfit_priority=None,
        joinable=None,
        object_reservation_tests=TunableTestSet.DEFAULT_LIST,
        ignore_group_socials=False)
Exemple #2
0
def create_tuningless_interaction(affordance, **kwargs):
    locked_fields = dict(basic_reserve_object=None,
                         basic_focus=None,
                         _forwarding=None,
                         allow_from_world=True,
                         basic_extras=(),
                         _constraints=frozendict(),
                         tests=TunableTestSet.DEFAULT_LIST,
                         test_globals=TunableGlobalTestSet.DEFAULT_LIST,
                         test_autonomous=TunableTestSet.DEFAULT_LIST,
                         _static_commodities=(),
                         _false_advertisements=(),
                         _hidden_false_advertisements=(),
                         _cancelable_by_user=True,
                         visible=False,
                         simless=False,
                         allow_autonomous=False,
                         allow_user_directed=False,
                         debug=False,
                         outcome=InteractionOutcome())
    if kwargs:
        locked_fields.update(kwargs)
    lock_instance_tunables(affordance, **locked_fields)
Exemple #3
0
    def start_situation(self):
        super().start_situation()
        self._change_state(GreetedPlayerVisitingNPCState())

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._line_of_sight = None
        if self._seed.custom_init_params_reader is None and self.initiating_sim_info is not None:
            sim = self.initiating_sim_info.get_sim_instance()
            self._line_of_sight = self._line_of_sight_factory()
            position = sim.position
            position += sim.forward*self._line_of_sight_generation_distance
            self._line_of_sight.generate(position, sim.routing_surface)

    def _issue_requests(self):
        request = BouncerPlayerVisitingNPCRequestFactory(self, callback_data=_RequestUserData(role_state_type=self.greeted_player_sims.role_state), job_type=self.greeted_player_sims.situation_job, exclusivity=self.exclusivity)
        self.manager.bouncer.submit_request(request)

    def _on_add_sim_to_situation(self, sim, job_type, role_state_type_override=None):
        super()._on_add_sim_to_situation(sim, job_type, role_state_type_override=role_state_type_override)
        if self._line_of_sight is not None:
            context = InteractionContext(sim, InteractionContext.SOURCE_SCRIPT, interactions.priority.Priority.High)
            constraint_to_satisfy = STAND_CONSTRAINT.intersect(self._line_of_sight.constraint)
            sim.push_super_affordance(ForceSatisfyConstraintSuperInteraction, None, context, constraint_to_satisfy=constraint_to_satisfy, name_override='MoveInsideHouseFromGreetedSituation')

lock_instance_tunables(GreetedPlayerVisitingNPCSituation, exclusivity=situations.bouncer.bouncer_types.BouncerExclusivityCategory.VISIT, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE, duration=0, _implies_greeted_status=True)

class GreetedPlayerVisitingNPCState(situations.situation_complex.SituationState):
    __qualname__ = 'GreetedPlayerVisitingNPCState'

        logger.debug('Loading asset: {0}', cls)

class AspirationSimInfoPanel(AspirationBasic):
    __qualname__ = 'AspirationSimInfoPanel'
    INSTANCE_TUNABLES = {'display_name': sims4.localization.TunableLocalizedString(description='\n            Display name for this aspiration', export_modes=sims4.tuning.tunable_base.ExportModes.All), 'descriptive_text': sims4.localization.TunableLocalizedString(description='\n            Description for this aspiration', export_modes=sims4.tuning.tunable_base.ExportModes.All), 'category': sims4.tuning.tunable.TunableReference(description='\n            The category this aspiration track goes into when displayed in the UI.', manager=services.get_instance_manager(sims4.resources.Types.ASPIRATION_CATEGORY), export_modes=sims4.tuning.tunable_base.ExportModes.All)}

    @classmethod
    def aspiration_type(cls):
        return AspriationType.SIM_INFO_PANEL

    @classmethod
    def _verify_tuning_callback(cls):
        for objective in cls.objectives:
            pass

lock_instance_tunables(AspirationSimInfoPanel, complete_only_in_sequence=False)

class AspirationNotification(AspirationBasic):
    __qualname__ = 'AspirationNotification'
    INSTANCE_TUNABLES = {'objectives': sims4.tuning.tunable.TunableList(description='\n            A Set of objectives for completing an aspiration.', tunable=sims4.tuning.tunable.TunableReference(description='\n                One objective for an aspiration', manager=services.get_instance_manager(sims4.resources.Types.OBJECTIVE))), 'disabled': sims4.tuning.tunable.Tunable(description='\n            Checking this box will remove this Aspiration from the event system and the UI, but preserve the tuning.', tunable_type=bool, default=False), 'notification': UiDialogNotification.TunableFactory(description='\n            This text will display in a notification pop up when completed.\n            ')}

    @classmethod
    def aspiration_type(cls):
        return AspriationType.NOTIFICATION

lock_instance_tunables(AspirationNotification, complete_only_in_sequence=False)

class AspirationCareer(AspirationBasic):
    __qualname__ = 'AspirationCareer'

    def reward(self, *args, **kwargs):
            neighbors = services.sim_filter_service().submit_matching_filter(sim_filter=neighbor_filter, allow_yielding=False, blacklist_sim_ids=blacklist_sim_ids, gsi_source_fn=cls.get_sim_filter_gsi_name)
            neighbor_sim_infos_at_home = [result.sim_info for result in neighbors if result.sim_info.is_at_home]
            if len(neighbor_sim_infos_at_home) > 1 or len(neighbor_sim_infos_at_home):
                if neighbor_filter.is_aggregate_filter():
                    continue
                neighbor_sim_id = neighbor_sim_infos_at_home[0].sim_id if neighbor_sim_infos_at_home else None
                if neighbor_sim_id is not None:
                    break
        return neighbor_sim_id

    def _set_loud_neighbor_and_door(self, neighbor_sim_id):
        neighbor_sim_info = services.sim_info_manager().get(neighbor_sim_id)
        if neighbor_sim_info is None:
            self._self_destruct()
            return
        self._neighbor_sim_id = neighbor_sim_id
        door_service = services.get_door_service()
        plex_door_infos = door_service.get_plex_door_infos()
        object_manager = services.object_manager()
        for door_info in plex_door_infos:
            door = object_manager.get(door_info.door_id)
            if door is not None:
                if door.household_owner_id == neighbor_sim_info.household_id:
                    self._neighbor_door_id = door_info.door_id
                    break
        else:
            logger.error('Could not find door object that belongs to {}', neighbor_sim_info.household.name)
            self._self_destruct()

lock_instance_tunables(LoudNeighborSituation, exclusivity=BouncerExclusivityCategory.NORMAL, _implies_greeted_status=False)
                target_si = social_group.get_si_registered_for_sim(target_sim)
                if target_si is None:
                    continue
                name = self.display_name_target(target_sim, self.sim)
                target_sim.ui_manager.add_running_mixer_interaction(
                    target_si.id, self, icon_info, name)
                if gsi_handlers.interaction_archive_handlers.is_archive_enabled(
                        self):
                    gsi_handlers.interaction_archive_handlers.archive_interaction(
                        target_sim, self, 'Start')
                if self._target_sim_refs_to_remove_interaction is None:
                    self._target_sim_refs_to_remove_interaction = weakref.WeakSet(
                    )
                self._target_sim_refs_to_remove_interaction.add(target_sim)

    def _remove_interaction_from_targets(self):
        if self._target_sim_refs_to_remove_interaction:
            for target_sim in self._target_sim_refs_to_remove_interaction:
                target_sim.ui_manager.remove_from_si_state(self)
                if gsi_handlers.interaction_archive_handlers.is_archive_enabled(
                        self):
                    gsi_handlers.interaction_archive_handlers.archive_interaction(
                        target_sim, self, 'Complete')


lock_instance_tunables(MixerInteraction,
                       basic_reserve_object=None,
                       _false_advertisements=EMPTY_SET,
                       _hidden_false_advertisements=EMPTY_SET,
                       _require_current_posture=False,
                       time_overhead=10)
                for sim_info in participants:
                    while sim_info.id == self.chef_id:
                        return True
        return False

    def _was_cooking_interaction_canceled(self, event, resolver):
        if event == TestEvent.InteractionComplete and resolver(self.cook_group_meal_interaction):
            if resolver.interaction is not None and resolver.interaction.is_finishing and resolver.interaction.has_been_canceled:
                participants = resolver.get_participants(ParticipantType.Actor)
                while True:
                    for sim_info in participants:
                        while sim_info.id == self.chef_id:
                            return True
        return False

lock_instance_tunables(FamilyMealSituation, exclusivity=situations.bouncer.bouncer_types.BouncerExclusivityCategory.NORMAL, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE)

class TryingToCookState(SituationState):
    __qualname__ = 'TryingToCookState'

    def __init__(self):
        super().__init__()
        self._try_to_cook_timeout_alarm_handle = None

    def on_activate(self, reader=None):
        super().on_activate(reader)
        trying_to_cook_timeout = self.owner.trying_to_cook_timeout
        if reader is not None:
            trying_to_cook_timeout = reader.read_float('trying_to_cook_timeout', trying_to_cook_timeout)
        self._try_to_cook_timeout_alarm_handle = alarms.add_alarm(self, clock.interval_in_sim_minutes(trying_to_cook_timeout), self._try_and_cook_timeout_callback)
        self._test_event_register(TestEvent.InteractionStart)
import role
import sims4.tuning.tunable
import situations.bouncer.bouncer_types
import situations.situation_complex

class GreetedNPCVisitingNPCSituation(VisitingNPCSituation):
    __qualname__ = 'GreetedNPCVisitingNPCSituation'
    INSTANCE_TUNABLES = {'greeted_npc_sims': sims4.tuning.tunable.TunableTuple(situation_job=situations.situation_job.SituationJob.TunableReference(description='\n                    The job given to NPC sims in the visiting situation.\n                    '), role_state=role.role_state.RoleState.TunableReference(description='\n                    The role state given to NPC sims in the visiting situation.\n                    '), tuning_group=GroupNames.ROLES)}

    @staticmethod
    def _states():
        return [(1, GreetedNPCVisitingNPCState)]

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.greeted_npc_sims.situation_job, cls.greeted_npc_sims.role_state)]

    @classmethod
    def default_job(cls):
        return cls.greeted_npc_sims.situation_job

    def start_situation(self):
        super().start_situation()
        self._change_state(GreetedNPCVisitingNPCState())

lock_instance_tunables(GreetedNPCVisitingNPCSituation, exclusivity=situations.bouncer.bouncer_types.BouncerExclusivityCategory.VISIT, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE, _implies_greeted_status=True)

class GreetedNPCVisitingNPCState(situations.situation_complex.SituationState):
    __qualname__ = 'GreetedNPCVisitingNPCState'

        time_till_completion = (next_hour - self._total_time_ran)/len(self._sims_running_interaction)
        self._alarm_handle = alarms.add_alarm(self, time_till_completion, self._on_hour_reached)
        self._last_started_time = services.time_service().sim_now

    def _stop_alarm(self):
        if self._alarm_handle is not None:
            alarms.cancel_alarm(self._alarm_handle)
            self._alarm_handle = None
            self._last_started_time = None

    def _run_goal_completion_tests(self, sim_info, event, resolver):
        if not resolver(self._goal_test):
            return False
        self._stop_alarm()
        if event == event_testing.test_events.TestEvent.InteractionStart:
            self._sims_running_interaction.add(sim_info.id)
        else:
            self._sims_running_interaction.discard(sim_info.id)
        self._start_alarm()
        return False

    @property
    def completed_iterations(self):
        return int(self._total_time_ran.in_hours())

    @property
    def max_iterations(self):
        return self._goal_test.duration

lock_instance_tunables(SituationGoalInteractionTime, _iterations=1)
    def _first_same_sex_relationship_callback(self, _):
        sims.global_gender_preference_tuning.GlobalGenderPreferenceTuning.enable_autogeneration_same_sex_preference = True
        self.remove_callback(self._first_same_sex_relationship_callback_data)

services.get_instance_manager(sims4.resources.Types.STATISTIC).add_on_load_complete(RelationshipTrack.check_relationship_track_display_priorities)

class ShortTermContextRelationshipTrack(RelationshipTrack):
    __qualname__ = 'ShortTermContextRelationshipTrack'
    INSTANCE_TUNABLES = {'socialization_decay_modifier': TunableRange(description='\n            A multiplier to apply to the decay rate if the two Sims that this\n            relationship track applies to are socializing.\n            ', tunable_type=float, default=1, minimum=0)}

    @classproperty
    def is_short_term_context(cls):
        return True

    def on_add(self):
        super().on_add()
        sim = self.tracker.relationship.find_sim()
        target = self.tracker.relationship.find_target_sim()
        if sim is not None and target is not None and sim.is_in_group_with(target):
            self.apply_social_group_decay()

    def apply_social_group_decay(self):
        if self.socialization_decay_modifier != 1:
            self.add_decay_rate_modifier(self.socialization_decay_modifier)

    def remove_social_group_decay(self):
        if self.socialization_decay_modifier != 1:
            self.remove_decay_rate_modifier(self.socialization_decay_modifier)

lock_instance_tunables(ShortTermContextRelationshipTrack, visible_test_set=DEFAULT)
    @classmethod
    def default_job(cls):
        return cls.ungreeted_npc_sims.situation_job

    def start_situation(self):
        super().start_situation()
        self._change_state(UngreetedNPCVisitingNPCState())

    def _on_make_waiting_player_greeted(self, door_bell_ringing_sim):
        self._greet()

    def _on_set_sim_job(self, sim, job_type):
        super()._on_set_sim_job(sim, job_type)
        if self.manager.is_player_greeted():
            self._greet()

    def _greet(self):
        for sim in self.all_sims_in_situation_gen():
            self.manager.create_greeted_npc_visiting_npc_situation(sim.sim_info)

    def _on_sim_removed_from_situation_prematurely(self, sim):
        if self.num_of_sims > 0:
            return
        self._self_destruct()

lock_instance_tunables(UngreetedNPCVisitingNPCSituation, exclusivity=situations.bouncer.bouncer_types.BouncerExclusivityCategory.UNGREETED, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE)

class UngreetedNPCVisitingNPCState(situations.situation_complex.SituationState):
    __qualname__ = 'UngreetedNPCVisitingNPCState'

            return inst._constraint_to_satisfy
        if sim is DEFAULT:
            sim = inst.get_participant(participant_type)
        return sim.si_state.get_total_constraint(to_exclude=inst)

    def _run_interaction_gen(self, timeline):
        self.sim.on_slot = None
        result = yield super()._run_interaction_gen(timeline)
        if not result:
            return False
        if self._run_element is not None:
            result = yield element_utils.run_child(timeline, self._run_element)
            return result
        return True

lock_instance_tunables(SitOrStandSuperInteraction, _constraints=(), _constraints_actor=ParticipantType.Object)

class SatisfyConstraintSuperInteraction(SitOrStandSuperInteraction):
    __qualname__ = 'SatisfyConstraintSuperInteraction'
    INSTANCE_SUBCLASSES_ONLY = True

create_tuningless_superinteraction(SatisfyConstraintSuperInteraction)

class ForceSatisfyConstraintSuperInteraction(SatisfyConstraintSuperInteraction):
    __qualname__ = 'ForceSatisfyConstraintSuperInteraction'
    INSTANCE_SUBCLASSES_ONLY = True

    @classmethod
    def is_adjustment_interaction(cls):
        return False
            self._total_simoleons_earned = simoleons_earned

    def create_seedling(self):
        seedling = super().create_seedling()
        writer = seedling.writer
        writer.write_uint64(self.SIMOLEONS_EARNED, self._total_simoleons_earned)
        return seedling

    def decommision(self):
        services.get_event_manager().unregister(self, self._test_events)
        super().decommision()

    def _run_goal_completion_tests(self, sim_info, event, resolver):
        if not resolver(self._goal_test):
            return False
        amount_to_add = resolver.get_resolved_arg('amount')
        if self._total_simoleons_earned >= self._goal_test.amount_to_earn:
            super()._on_goal_completed()
        else:
            self._on_iteration_completed()

    @property
    def completed_iterations(self):
        return self._total_simoleons_earned

    @property
    def max_iterations(self):
        return self._goal_test.amount_to_earn

lock_instance_tunables(SituationGoalSimoleonsEarned, _iterations=1)
Exemple #14
0
    @classproperty
    def final_product_canvas_tuning(cls):
        return cls.final_product_type._components.canvas

    @classproperty
    def style_display_name(cls):
        return cls.painting_style.display_name

    @classmethod
    def pick_texture(cls, crafter) -> PaintingTexture:
        canvas_types = cls.final_product_canvas_tuning.canvas_types
        texture = cls.painting_style.pick_texture(crafter, canvas_types)
        return texture

    @classmethod
    def setup_crafted_object(cls, crafted_object, crafter, is_final_product):
        super().setup_crafted_object(crafted_object, crafter, is_final_product)
        if is_final_product:
            texture = cls.pick_texture(crafter)
            if texture is None:
                logger.error('Tuning Error: No texture found for {0}', crafted_object, owner='nbaker')
                return
            texture.apply_to_object(crafted_object)

    @classmethod
    def update_hovertip(cls, owner, crafter=None):
        crafting_component._set_simoleon_value(owner, owner.current_value)
        crafting_component._set_style_name(owner, cls.style_display_name)

lock_instance_tunables(PaintingRecipe, multi_serving_name=None, push_consume=False)
Exemple #15
0
            major_goal_msg.audio_sting.group = self.main_goal_audio_sting.group
            major_goal_msg.audio_sting.instance = self.main_goal_audio_sting.instance

    def _set_minor_goals_data(self, pet, goals_msg):
        discovered_symptoms = pet.sim_info.sickness_tracker.discovered_symptoms
        while True:
            for i in range(0 if pet.sim_info.current_sickness is None else len(
                    pet.sim_info.current_sickness.symptoms)):
                is_symptom_discovered = len(
                    discovered_symptoms
                ) > i and pet.sim_info.was_symptom_discovered(
                    discovered_symptoms[i])
                symptom_goal_name = discovered_symptoms[i].display_name(
                ) if is_symptom_discovered else self.undiscovered_symptom_text(
                )
                with ProtocolBufferRollback(goals_msg) as goal_msg:
                    goal_msg.goal_id = SICKNESS_MINOR_GOAL_IDS[i]
                    goal_msg.goal_name = symptom_goal_name
                    goal_msg.max_iterations = 1
                    goal_msg.current_iterations = 1 if is_symptom_discovered else 0
                    if self.audio_sting_on_symptom_discovery is not None:
                        goal_msg.audio_sting.type = self.audio_sting_on_symptom_discovery.type
                        goal_msg.audio_sting.group = self.audio_sting_on_symptom_discovery.group
                        goal_msg.audio_sting.instance = self.audio_sting_on_symptom_discovery.instance


lock_instance_tunables(
    VetClinicDiagnosisSituation,
    exclusivity=BouncerExclusivityCategory.NORMAL,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    duration=0)
            description=
            '\n            The job and role state for a party pooper.\n            '
        )
    }
    REMOVE_INSTANCE_TUNABLES = Situation.NON_USER_FACING_REMOVE_INSTANCE_TUNABLES

    @classmethod
    def _states(cls):
        return (SituationStateData(1,
                                   _PartyPooperState,
                                   factory=cls.party_pooper_state), )

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.party_pooper_job_and_role.job,
                 cls.party_pooper_job_and_role.role_state)]

    @classmethod
    def default_job(cls):
        return cls.party_pooper_job_and_role.situation_job

    def start_situation(self):
        super().start_situation()
        self._change_state(self.party_pooper_state())


lock_instance_tunables(
    PartyPooperSituation,
    exclusivity=BouncerExclusivityCategory.NORMAL,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    _implies_greeted_status=False)
    def __init__(self, *args, sim_info=None, **kwargs):
        super().__init__(*args, **kwargs)
        self._sim_info = sim_info

    @flexmethod
    def get_participants(cls, inst, participant_type, sim=DEFAULT, target=DEFAULT, sim_info=None, **interaction_parameters) -> set:
        result = super(ImmediateSuperInteraction, inst if inst is not None else cls).get_participants(participant_type, sim=sim, target=target, **interaction_parameters)
        result = set(result)
        if inst is not None:
            sim_info = inst._sim_info
        if participant_type & ParticipantType.Actor and sim_info is not None:
            result.add(sim_info)
        return tuple(result)

lock_instance_tunables(SimInfoInteraction, simless=True)

class BringHereInteraction(SimInfoInteraction):
    __qualname__ = 'BringHereInteraction'

    @classmethod
    def _test(cls, *args, sim_info=None, **kwargs):
        if sim_info.zone_id == services.current_zone_id():
            return TestResult(False, 'Cannot bring a sim to a zone that is already the current zone.')
        return super()._test(*args, **kwargs)

    def _run_interaction_gen(self, timeline):
        SimSpawner.spawn_sim(self._sim_info)

class SwitchToZoneInteraction(SimInfoInteraction):
    __qualname__ = 'SwitchToZoneInteraction'
Exemple #18
0
                             crafted_object,
                             owner='nbaker')
                return
            reveal_level = crafted_object.canvas_component.painting_reveal_level
            texture.apply_to_object(crafted_object)
            if reveal_level is not None:
                crafted_object.canvas_component.painting_reveal_level = reveal_level

    @classmethod
    def update_hovertip(cls, owner, crafter=None):
        owner.update_tooltip_field(TooltipFieldsComplete.simoleon_value,
                                   owner.current_value)
        owner.update_tooltip_field(TooltipFieldsComplete.style_name,
                                   cls.style_display_name)
        owner.update_object_tooltip()


lock_instance_tunables(PaintingRecipe,
                       multi_serving_name=None,
                       push_consume=False)


class PaintByReferenceRecipe(PaintingRecipe):
    @classmethod
    def _verify_tuning_callback(cls):
        cls._verify_recipe_tuning_callback()

    @classmethod
    def setup_crafted_object(cls, crafted_object, crafter, is_final_product):
        cls._setup_crafted_object(crafted_object, crafter, is_final_product)
def create_tuningless_superinteraction(affordance):
    create_tuningless_interaction(affordance)
    lock_instance_tunables(affordance, pre_add_autonomy_commodities=None, pre_run_autonomy_commodities=None, post_guaranteed_autonomy_commodities=None, post_run_autonomy_commodities=None, super_affordance_compatibility=None, basic_content=None, outfit_change=None, outfit_priority=None, joinable=None, object_reservation_tests=TunableTestSet.DEFAULT_LIST, ignore_group_socials=False)
    @classmethod
    def default_job(cls):
        pass

    @classmethod
    def _states(cls):
        return (SituationStateData(1, ArriveState, factory=cls.arrive_state),
                SituationStateData(2, TendState, factory=cls.tend_state))

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.tendor_job_and_role_state.job,
                 cls.tendor_job_and_role_state.role_state)]

    def start_situation(self):
        super().start_situation()
        self._change_state(self.arrive_state())

    def _save_custom_situation(self, writer):
        super()._save_custom_situation(writer)
        staffed_object = self.get_staffed_object()
        if staffed_object is not None:
            writer.write_uint64(OBJECT_TOKEN, staffed_object.id)


lock_instance_tunables(
    TendObjectSituation,
    exclusivity=BouncerExclusivityCategory.VENUE_EMPLOYEE,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    _implies_greeted_status=False)
def create_tuningless_interaction(affordance, **kwargs):
    locked_fields = dict(basic_reserve_object=None, basic_focus=None, allow_forward=False, allow_from_world=True, basic_extras=[], _constraints=[], tests=TunableTestSet.DEFAULT_LIST, test_globals=TunableGlobalTestSet.DEFAULT_LIST, test_autonomous=TunableTestSet.DEFAULT_LIST, _static_commodities=[], _false_advertisements=[], _hidden_false_advertisements=[], _cancelable_by_user=True, visible=False, simless=False, allow_autonomous=False, allow_user_directed=False, debug=False, outcome=InteractionOutcome())
    if kwargs:
        locked_fields.update(kwargs)
    lock_instance_tunables(affordance, **locked_fields)
                                   CooldownFestivalSituationState,
                                   factory=cls.cooldown_state))

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return list(
            cls.initial_state._tuned_values.job_and_role_changes.items())

    def start_situation(self):
        super().start_situation()
        self._change_state(self.initial_state())


lock_instance_tunables(
    GenericOneStateFestivalAttendeeSituation,
    exclusivity=BouncerExclusivityCategory.FESTIVAL_GOER,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    _implies_greeted_status=False)


class StartingTransitioningFestivalSituationState(CommonSituationState):
    def timer_expired(self):
        self._change_state(self.owner.secondary_state())


class SecondaryFestivalSituationState(CommonSituationState):
    pass


class GenericTwoStateFestivalAttendeeSituation(BaseGenericFestivalSituation):
    INSTANCE_TUNABLES = {
from sims4 import commands
from sims4.tuning.instances import lock_instance_tunables
from sims4.tuning.tunable import TunableList, TunableVariant, Tunable
from sims4.utils import classproperty
from situations.tunable import CreateSituationElement
from tag import Tag

class ImmediateSuperInteraction(SuperInteraction):
    __qualname__ = 'ImmediateSuperInteraction'
    INSTANCE_TUNABLES = {'basic_content': TunableBasicContentSet(no_content=True, default='no_content'), 'basic_extras': TunableList(description='Additional elements to run around the basic content of the interaction.', tunable=TunableVariant(state_change=TunableStateChange(), create_situation=CreateSituationElement.TunableFactory(), create_object=ObjectCreationElement.TunableFactory(), notification=NotificationElement.TunableFactory(), payment=PaymentElement.TunableFactory(), destroy_object=ObjectDestructionElement.TunableFactory(), vfx=PlayVisualEffectElement.TunableFactory()))}

    @classproperty
    def immediate(cls):
        return True

lock_instance_tunables(ImmediateSuperInteraction, allow_autonomous=False, _cancelable_by_user=False, _must_run=True, visible=False, _constraints=[], basic_reserve_object=None, basic_focus=None, intensity=InteractionIntensity.Default, interaction_category_tags=frozenset([Tag.INVALID]), super_affordance_compatibility=None, animation_stat=None, _provided_posture_type=None, supported_posture_type_filter=[], force_autonomy_on_inertia=False, force_exit_on_inertia=False, pre_add_autonomy_commodities=[], pre_run_autonomy_commodities=[], post_guaranteed_autonomy_commodities=[], post_run_autonomy_commodities=SimpleNamespace(requests=[], fallback_notification=None), opportunity_cost_multiplier=1, autonomy_can_overwrite_similar_affordance=False, subaction_selection_weight=1, relationship_scoring=False, _party_size_weight_tuning=[], joinable=[], rallyable=None, autonomy_preference=None, outfit_priority=None, outfit_change=None, object_reservation_tests=[], cancel_replacement_affordances=None, privacy=None, provided_affordances=[], canonical_animation=None, ignore_group_socials=False)

class CommandSuperInteraction(ImmediateSuperInteraction):
    __qualname__ = 'CommandSuperInteraction'
    INSTANCE_TUNABLES = {'command': Tunable(str, None, description='The command to run.')}

    def _run_gen(self, timeline):
        if self.context.client is not None:
            if self.context.target_sim_id is not None:
                commands.execute('{} {}'.format(self.command, self.context.target_sim_id), self.context.client.id)
            else:
                commands.execute('{} {}'.format(self.command, self.target.id), self.context.client.id)
        else:
            commands.execute('{} {}'.format(self.command, self.target.id), None)
        return True
        yield None
Exemple #24
0
    def _constraint_gen(cls, *args, **kwargs):
        for constraint in super()._constraint_gen(*args, **kwargs):
            yield constraint
        yield cls.CONSTRAINT

class TerrainSuperInteraction(TerrainInteractionMixin, SuperInteraction):
    __qualname__ = 'TerrainSuperInteraction'
    INSTANCE_TUNABLES = {'basic_content': TunableBasicContentSet(no_content=True, default='no_content')}

    @classmethod
    def _constraint_gen(cls, *args, **kwargs):
        for constraint in super()._constraint_gen(*args, **kwargs):
            yield constraint
        yield services.current_zone().get_spawn_point_ignore_constraint()

lock_instance_tunables(TerrainSuperInteraction, basic_reserve_object=None, basic_focus=None)

class TerrainImmediateSuperInteraction(TerrainInteractionMixin, ImmediateSuperInteraction):
    __qualname__ = 'TerrainImmediateSuperInteraction'
    INSTANCE_SUBCLASSES_ONLY = True

class TravelSuperInteraction(TravelMixin, TerrainSuperInteraction):
    __qualname__ = 'TravelSuperInteraction'

    @classmethod
    def _test(cls, target, context, **kwargs):
        (position, _, result) = cls._get_target_position_surface_and_test_off_lot(target, context)
        if not result:
            return result
        if position is not None and not terrain.is_position_in_street(position):
            return TestResult(False, 'Cannot Travel from terrain outside of the street!')
            logger.debug('Saving sim during TravelInteraction for {}', sim_info)
            sim_info.inject_into_inactive_zone(self.to_zone_id)
            save_success = sim_info.save_sim()
            while not save_success:
                logger.error('Failure saving during TravelInteraction for {}', sim_info)
        finally:
            logger.debug('Destroying sim {}', sim_info)
            self.force_save_and_destroy_sim = False
            if on_reset:
                if self.sim is not None:
                    services.object_manager().remove(self.sim)
                notify_travel_service()
            elif self.sim is not None:
                self.sim.schedule_destroy_asap(source=self, cause='Destroying sim on travel.')

lock_instance_tunables(TravelInteraction, basic_reserve_object=None, basic_focus=None, allow_from_object_inventory=False, allow_from_sim_inventory=False, intensity=InteractionIntensity.Default, basic_liabilities=[], animation_stat=None, _provided_posture_type=None, supported_posture_type_filter=[], force_autonomy_on_inertia=False, force_exit_on_inertia=False, pre_add_autonomy_commodities=[], pre_run_autonomy_commodities=[], post_guaranteed_autonomy_commodities=[], post_run_autonomy_commodities=SimpleNamespace(requests=[], fallback_notification=None), opportunity_cost_multiplier=1, autonomy_can_overwrite_similar_affordance=False, subaction_selection_weight=1, relationship_scoring=False, _party_size_weight_tuning=[], joinable=[], rallyable=None, autonomy_preference=None, outfit_change=None, outfit_priority=None, object_reservation_tests=[], cancel_replacement_affordances=None, privacy=None, provided_affordances=[], canonical_animation=None, ignore_group_socials=False, utility_info=None, skill_loot_data=skill.EMPTY_SKILL_LOOT_DATA)

class GoToSpecificLotTravelInteraction(TravelInteraction):
    __qualname__ = 'GoToSpecificLotTravelInteraction'
    INSTANCE_TUNABLES = {'destination_lot': OptionalTunable(description="\n            If enabled, tune a specific lot description to be the destination\n            of the interaction.  Otherwise, the interaction will assume the\n            destination lot is the Sim's home lot.\n            ", tunable=TunableLotDescription(description='\n                The lot description of the destination lot.\n                '))}

    def __init__(self, aop, context, **kwargs):
        if self.destination_lot is None:
            zone_id = context.sim.household.home_zone_id
        else:
            lot_id = get_lot_id_from_instance_id(self.destination_lot)
            zone_id = services.get_persistence_service().resolve_lot_id_into_zone_id(lot_id, ignore_neighborhood_id=True)
        super().__init__(aop, context, from_zone_id=context.sim.zone_id, to_zone_id=zone_id, on_complete_callback=None, on_complete_context=None, **kwargs)

    def _run_interaction_gen(self, timeline):
        travel_info = InteractionOps_pb2.TravelSimsToZone()
Exemple #26
0
    def _pick_affordance(self, order_sim, object_info, context):
        deliver_part = None
        carry_track = object_info.carry_track
        deliver_to_bar = self.delivery_to_bar_affordance
        deliver_to_sit_drink_slot = self.delivery_to_sit_drink_slot_affordance
        if self.sim == order_sim or order_sim is None:
            return (deliver_to_bar, self.target, deliver_part, carry_track)
        order_surface_target = order_sim.posture_state.surface_target
        if order_surface_target is not None and order_surface_target.is_part:
            bar = None
            if self.target.is_part:
                bar = self.target.part_owner
            if order_surface_target.part_owner is bar:
                if order_surface_target.is_valid_for_placement(definition=object_info.definition):
                    deliver_part = order_surface_target
                    return (deliver_to_sit_drink_slot, self.target, deliver_part, carry_track)
        return (deliver_to_bar, self.target, deliver_part, carry_track)

    def _run_interaction_gen(self, timeline):
        (order_sim, recipe) = self.process.pop_order()
        object_info = recipe.final_product
        context = self.context.clone_for_continuation(self)
        (deliver_affordance, target, deliver_part, carry_track) = self._pick_affordance(order_sim, object_info, context)
        obj_info_copy = FrozenAttributeDict(object_info, carry_track=carry_track)
        new_process = self.process.copy_for_serve_drink(recipe)
        aop = AffordanceObjectPair(deliver_affordance, target, deliver_affordance, None, order_sim=order_sim, object_info=obj_info_copy, deliver_part=deliver_part, phase=self.process.phase, crafting_process=new_process)
        self._went_to_next_phase_or_finished_crafting = True
        return aop.test_and_execute(context)

lock_instance_tunables(ChooseDeliverySuperInteraction, basic_content=None)
    def _create_social_geometry(self, sim, call_on_changed=True):
        pass

    def _clear_social_geometry(self, sim, call_on_changed=True):
        pass

    def _group_geometry_changed(self):
        pass

    def _create_adjustment_alarm(self):
        pass

    def try_relocate_around_focus(self, *args, **kwargs):
        return True

lock_instance_tunables(SideGroup, adjust_sim_positions_dynamically=True, is_side_group=True)

class GameGroup(SideGroup):
    __qualname__ = 'GameGroup'
    INSTANCE_TUNABLES = {'social_anchor_object': TunableEnumEntry(description='\n            The participant type used to find an object with the game component.\n            This object will also be used as the social anchor for your social\n            group to ensure the players of the game are around the object.\n            ', tunable_type=ParticipantTypeObject, default=ParticipantTypeObject.ActorSurface)}

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry = None

    @classmethod
    def make_constraint_default(cls, *args, **kwargs):
        return Anywhere()

    @property
    def _los_constraint(self):
Exemple #28
0
        TunableBasicContentSet(one_shot=True,
                               no_content=True,
                               default='no_content')
    }

    @flexmethod
    def _constraint_gen(cls, inst, *args, **kwargs):
        for constraint in super()._constraint_gen(*args, **kwargs):
            yield constraint
        zone = services.current_zone()
        if zone is not None:
            yield zone.get_spawn_point_ignore_constraint()


lock_instance_tunables(TerrainSuperInteraction,
                       basic_reserve_object=None,
                       basic_focus=None)


class TerrainImmediateSuperInteraction(TerrainInteractionMixin,
                                       ImmediateSuperInteraction):
    INSTANCE_SUBCLASSES_ONLY = True


class TravelMixin:
    def __init__(self, *args, to_zone_id=0, **kwargs):
        super().__init__(*args, to_zone_id=to_zone_id, **kwargs)
        self.to_zone_id = to_zone_id

    @classmethod
    def travel_test(cls, context):
Exemple #29
0
lock_instance_tunables(ImmediateSuperInteraction,
                       allow_autonomous=False,
                       _cancelable_by_user=False,
                       _must_run=True,
                       visible=False,
                       _constraints=frozendict(),
                       basic_reserve_object=None,
                       basic_focus=None,
                       intensity=InteractionIntensity.Default,
                       super_affordance_compatibility=None,
                       animation_stat=None,
                       _provided_posture_type=None,
                       supported_posture_type_filter=(),
                       force_autonomy_on_inertia=False,
                       force_exit_on_inertia=False,
                       disallow_as_mixer_target=False,
                       attention_cost=0.5,
                       _false_advertisements=(),
                       _hidden_false_advertisements=(),
                       _static_commodities=(),
                       _affordance_key_override_for_autonomy=None,
                       apply_autonomous_posture_change_cost=True,
                       disable_autonomous_multitasking_if_user_directed=False,
                       test_autonomous=TunableTestSet.DEFAULT_LIST,
                       pre_add_autonomy_commodities=(),
                       pre_run_autonomy_commodities=(),
                       post_guaranteed_autonomy_commodities=(),
                       post_run_autonomy_commodities=SimpleNamespace(
                           requests=(), fallback_notification=None),
                       scoring_priority=AutonomyInteractionPriority.INVALID,
                       duplicate_affordance_group=Tag.INVALID,
                       time_overhead=1,
                       use_best_scoring_aop=True,
                       opportunity_cost_multiplier=1,
                       autonomy_can_overwrite_similar_affordance=False,
                       subaction_selection_weight=1,
                       relationship_scoring=False,
                       _party_size_weight_tuning=(),
                       joinable=(),
                       rallyable=None,
                       autonomy_preference=None,
                       outfit_priority=None,
                       outfit_change=None,
                       object_reservation_tests=(),
                       cancel_replacement_affordances=None,
                       privacy=None,
                       provided_affordances=(),
                       canonical_animation=None,
                       ignore_group_socials=False)
Exemple #30
0
    def _pre_perform(self, *args, **kwargs):
        if self.sim.household.free_slot_count == 0:
            self.cancel(FinishingType.FAILED_TESTS, cancel_reason_msg="There aren't any free household slots.")
            return
        self.add_liability(ADOPTION_LIABILTIY, AdoptionLiability())
        return super()._pre_perform(*args, **kwargs)

    def on_choice_selected(self, choice_tag, **kwargs):
        sim_id = choice_tag
        if sim_id is not None:
            self._picked_sim_id = sim_id
            self.add_liability(SIM_FILTER_GLOBAL_BLACKLIST_LIABILITY, SimFilterGlobalBlacklistLiability((sim_id,), SimFilterGlobalBlacklistReason.ADOPTION))
        self.trigger_soft_stop()

lock_instance_tunables(AdoptionPickerInteraction, pie_menu_option=None)

class AdoptionInteraction(SuperInteraction, NameOffspringSuperInteractionMixin):
    __qualname__ = 'AdoptionInteraction'
    INSTANCE_TUNABLES = {'dialog': SimPersonalityAssignmentDialog.TunableFactory(description="\n                The dialog that is displayed (and asks for the user to enter a first\n                name and last name) before assigning the sim to your household.\n                \n                An additional token is passed in: the adopted Sim's data.\n                ", text_inputs=(TEXT_INPUT_FIRST_NAME, TEXT_INPUT_LAST_NAME), locked_args={'phone_ring_type': PhoneRingType.NO_RING}), 'adoption_trait': TunableReference(description='\n                Trait that represents the sim being considered adoptable.  The\n                trait will be removed from the sim being adopted upon adoption\n                being completed.\n                ', manager=services.get_instance_manager(sims4.resources.Types.TRAIT))}

    def _pre_perform(self, *args, **kwargs):
        self.add_liability(interactions.rabbit_hole.RABBIT_HOLE_LIABILTIY, interactions.rabbit_hole.RabbitHoleLiability())
        return super()._pre_perform(*args, **kwargs)

    def _build_outcome_sequence(self, *args, **kwargs):
        sequence = super()._build_outcome_sequence(*args, **kwargs)
        return element_utils.build_critical_section(self._name_and_create_adoptee_gen, sequence)

    def _get_name_dialog(self):
        adopted_sim_info = self.get_participant(ParticipantType.PickedSim)
Exemple #31
0
                                   factory=cls.tend_state),
                SituationStateData(3,
                                   SalesTableTeardownState,
                                   factory=cls.teardown_state))

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.vendor_job_and_role_state.job,
                 cls.vendor_job_and_role_state.role_state)]

    def start_situation(self):
        super().start_situation()
        self._change_state(self.setup_state())


class SalesTableVendorSituation(SalesTableVendorSituationMixin,
                                SituationComplexCommon):
    REMOVE_INSTANCE_TUNABLES = Situation.NON_USER_FACING_REMOVE_INSTANCE_TUNABLES


lock_instance_tunables(
    SalesTableVendorSituation,
    exclusivity=BouncerExclusivityCategory.WALKBY,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    _implies_greeted_status=False)


class StaffedSalesTableVendorSituation(StaffedObjectSituationMixin,
                                       SalesTableVendorSituation):
    pass
Exemple #32
0
lock_instance_tunables(TravelInteraction,
                       basic_reserve_object=None,
                       basic_focus=None,
                       allow_from_object_inventory=False,
                       allow_from_sim_inventory=False,
                       intensity=InteractionIntensity.Default,
                       basic_liabilities=[],
                       animation_stat=None,
                       _provided_posture_type=None,
                       supported_posture_type_filter=[],
                       force_autonomy_on_inertia=False,
                       force_exit_on_inertia=False,
                       pre_add_autonomy_commodities=[],
                       pre_run_autonomy_commodities=[],
                       post_guaranteed_autonomy_commodities=[],
                       post_run_autonomy_commodities=SimpleNamespace(
                           requests=[], fallback_notification=None),
                       opportunity_cost_multiplier=1,
                       autonomy_can_overwrite_similar_affordance=False,
                       subaction_selection_weight=1,
                       relationship_scoring=False,
                       _party_size_weight_tuning=[],
                       joinable=[],
                       rallyable=None,
                       autonomy_preference=None,
                       outfit_change=None,
                       outfit_priority=None,
                       object_reservation_tests=[],
                       cancel_replacement_affordances=None,
                       privacy=None,
                       provided_affordances=[],
                       canonical_animation=None,
                       ignore_group_socials=False,
                       utility_info=None,
                       skill_loot_data=skill.EMPTY_SKILL_LOOT_DATA)
Exemple #33
0
        self.sim.routing_component.on_slot = None
        result = yield from super()._run_interaction_gen(timeline)
        if not result:
            return False
            yield
        elif self._run_element is not None:
            result = yield from element_utils.run_child(
                timeline, self._run_element)
            return result
            yield
        return True
        yield


lock_instance_tunables(SitOrStandSuperInteraction,
                       _constraints=frozendict(),
                       _constraints_actor=ParticipantType.Object)


class SatisfyConstraintSuperInteraction(SitOrStandSuperInteraction):
    INSTANCE_SUBCLASSES_ONLY = True


create_tuningless_superinteraction(SatisfyConstraintSuperInteraction)


class ForceSatisfyConstraintSuperInteraction(SatisfyConstraintSuperInteraction
                                             ):
    INSTANCE_SUBCLASSES_ONLY = True

    @classmethod
Exemple #34
0
                         **interaction_parameters) -> set:
        result = super(ImmediateSuperInteraction,
                       inst if inst is not None else cls).get_participants(
                           participant_type,
                           sim=sim,
                           target=target,
                           **interaction_parameters)
        result = set(result)
        if inst is not None:
            sim_info = inst._sim_info
        if participant_type & ParticipantType.Actor and sim_info is not None:
            result.add(sim_info)
        return tuple(result)


lock_instance_tunables(SimInfoInteraction, simless=True)


class BringHereInteraction(SimInfoInteraction):
    __qualname__ = 'BringHereInteraction'

    @classmethod
    def _test(cls, *args, sim_info=None, **kwargs):
        if sim_info.zone_id == services.current_zone_id():
            return TestResult(
                False,
                'Cannot bring a sim to a zone that is already the current zone.'
            )
        return super()._test(*args, **kwargs)

    def _run_interaction_gen(self, timeline):
lock_instance_tunables(ImmediateSuperInteraction,
                       allow_autonomous=False,
                       _cancelable_by_user=False,
                       _must_run=True,
                       visible=False,
                       _constraints=[],
                       basic_reserve_object=None,
                       basic_focus=None,
                       intensity=InteractionIntensity.Default,
                       interaction_category_tags=frozenset([Tag.INVALID]),
                       super_affordance_compatibility=None,
                       animation_stat=None,
                       _provided_posture_type=None,
                       supported_posture_type_filter=[],
                       force_autonomy_on_inertia=False,
                       force_exit_on_inertia=False,
                       pre_add_autonomy_commodities=[],
                       pre_run_autonomy_commodities=[],
                       post_guaranteed_autonomy_commodities=[],
                       post_run_autonomy_commodities=SimpleNamespace(
                           requests=[], fallback_notification=None),
                       opportunity_cost_multiplier=1,
                       autonomy_can_overwrite_similar_affordance=False,
                       subaction_selection_weight=1,
                       relationship_scoring=False,
                       _party_size_weight_tuning=[],
                       joinable=[],
                       rallyable=None,
                       autonomy_preference=None,
                       outfit_priority=None,
                       outfit_change=None,
                       object_reservation_tests=[],
                       cancel_replacement_affordances=None,
                       privacy=None,
                       provided_affordances=[],
                       canonical_animation=None,
                       ignore_group_socials=False)
            cls.gig_pay.lower_bound, pay_rate, scheduled_time, finishing_time,
            tip.tip_title(), tip.tip_text(), gig_customer)
        if not enabled and cls.disabled_tooltip is not None:
            row_tooltip = lambda *_: cls.disabled_tooltip(owner)
        elif cls.display_description is None:
            row_tooltip = None
        else:
            row_tooltip = lambda *_: cls.display_description(owner)
        customer_description = cls.odd_job_tuning.customer_description(
            gig_customer)
        row = OddJobPickerRow(customer_id=gig_customer.id,
                              customer_description=customer_description,
                              tip_title=tip.tip_title(),
                              tip_text=tip.tip_text(),
                              tip_icon=tip.tip_icon,
                              name=cls.display_name(owner),
                              icon=cls.display_icon,
                              row_description=description,
                              row_tooltip=row_tooltip,
                              is_enable=enabled)
        return row


lock_instance_tunables(RabbitholeGig,
                       gig_prep_tasks=None,
                       audio_on_prep_task_completion=None,
                       career_events=None,
                       gig_cast_rel_bit_collection_id=None,
                       gig_cast=None,
                       end_of_gig_dialog=None,
                       payout_stat_data=None)
            manager=services.get_instance_manager(
                sims4.resources.Types.ASPIRATION_CATEGORY),
            export_modes=sims4.tuning.tunable_base.ExportModes.All)
    }

    @classmethod
    def aspiration_type(cls):
        return AspriationType.SIM_INFO_PANEL

    @classmethod
    def _verify_tuning_callback(cls):
        for objective in cls.objectives:
            pass


lock_instance_tunables(AspirationSimInfoPanel, complete_only_in_sequence=False)


class AspirationNotification(AspirationBasic):
    __qualname__ = 'AspirationNotification'
    INSTANCE_TUNABLES = {
        'objectives':
        sims4.tuning.tunable.TunableList(
            description=
            '\n            A Set of objectives for completing an aspiration.',
            tunable=sims4.tuning.tunable.TunableReference(
                description='\n                One objective for an aspiration',
                manager=services.get_instance_manager(
                    sims4.resources.Types.OBJECTIVE))),
        'disabled':
        sims4.tuning.tunable.Tunable(
        return random.weighted_random_item(weighted)

    def _enable_state(self, state_type):
        if state_type in self._locked_states:
            self._locked_states.remove(state_type)

    def _disable_state(self, state_type):
        self._locked_states.add(state_type)
        if self._cur_state.state_type == state_type:
            self.try_set_next_state()

    def get_phase_state_name_for_gsi(self):
        if self._cur_state is None:
            return 'None'
        else:
            return self._cur_state.state_type.name

    def _gsi_additional_data_gen(self):
        yield ('Locked States', str(self._locked_states))

    def log_flow_entry(self, message):
        log_vet_flow_entry(repr(self.get_employee()),
                           type(self).__name__, message)


lock_instance_tunables(
    VetEmployeeSituation,
    duration=0,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    exclusivity=situations.bouncer.bouncer_types.BouncerExclusivityCategory.
    VENUE_EMPLOYEE)
    def _run_interaction_gen(self, timeline):
        self.away_action_sim_info.away_action_tracker.create_and_apply_away_action(
            self.away_action, self.away_action_target)

    @flexmethod
    def get_display_tooltip(cls, inst, away_action=None, **kwargs):
        if inst is not None:
            away_action = inst.away_action
        inst_or_cls = inst if inst is not None else cls
        if away_action is not None:
            return inst_or_cls.create_localized_string(
                away_action.pie_menu_tooltip, **kwargs)
        return inst_or_cls.get_display_tooltip(**kwargs)


lock_instance_tunables(ApplyAwayActionInteraction, simless=True)


class AwayActionSimPickerInteraction(SimPickerInteraction):
    __qualname__ = 'AwayActionSimPickerInteraction'

    def __init__(self,
                 *args,
                 away_action=None,
                 away_action_sim_info=None,
                 **kwargs):
        super().__init__(*args, **kwargs)
        self.away_action = away_action
        self.away_action_sim_info = away_action_sim_info

    @classmethod
        if success and self.ui_display_type != DramaNodeUiDisplayType.NO_UI:
            services.calendar_service().mark_on_calendar(self)
        return success

    def create_calendar_entry(self):
        calendar_entry = super().create_calendar_entry()
        calendar_entry.zone_id = self._zone_id
        build_icon_info_msg(
            IconInfoData(
                icon_resource=self._display_data.instance_display_icon),
            self._display_data.instance_display_name, calendar_entry.icon_info)
        calendar_entry.scoring_enabled = False
        return calendar_entry


lock_instance_tunables(VenueEventDramaNode, ui_display_data=None)


class OrganizationEventDramaNode(VenueEventDramaNode):
    INSTANCE_TUNABLES = {
        'fake_duration':
        TunableSimMinute(
            description=
            "\n            The amount of time in Sim minutes that is used by UI to display the\n            drama node's activity's duration.  When the event actually runs the\n            open street director determines actual end-time.\n            ",
            default=60,
            minimum=1),
        'organization':
        TunableReference(
            description=
            '\n            The organization for which this drama node is scheduling venue events.\n            ',
            manager=services.get_instance_manager(
Exemple #41
0
        self.away_action_sim_info.away_action_tracker.create_and_apply_away_action(
            self.away_action, self.away_action_target)

    @flexmethod
    def get_display_tooltip(cls, inst, away_action=None, **kwargs):
        if inst is not None:
            away_action = inst.away_action
        inst_or_cls = inst if inst is not None else cls
        if away_action is not None:
            return inst_or_cls.create_localized_string(
                away_action.pie_menu_tooltip, **kwargs)
        return inst_or_cls.get_display_tooltip(**kwargs)


lock_instance_tunables(ApplyAwayActionInteraction,
                       simless=True,
                       tests=TunableTestSet.DEFAULT_LIST)


class AwayActionSimPickerInteraction(SimPickerInteraction):
    def __init__(self,
                 *args,
                 away_action=None,
                 away_action_sim_info=None,
                 **kwargs):
        super().__init__(*args, **kwargs)
        self.away_action = away_action
        self.away_action_sim_info = away_action_sim_info

    @classmethod
    def _test(cls,
        if minutes_remaining < self.CONTINUE_SHOPPING_THRESHOLD:
            return
        if self.role_state_browse is not None:
            return _BrowseState()
        return _LoiterState()

    def _set_shop_duration(self):
        shop_time = random.randint(self.total_shop_time_min,
                                   self.total_shop_time_max)
        shop_time *= self._total_shop_time_multiplier
        self.change_duration(shop_time)


lock_instance_tunables(RetailCustomerSituation,
                       exclusivity=situations.bouncer.bouncer_types.
                       BouncerExclusivityCategory.NORMAL,
                       creation_ui_option=situations.situation_types.
                       SituationCreationUIOption.NOT_AVAILABLE,
                       duration=0)


class _GoToStoreState(SituationState):
    def on_activate(self, reader=None):
        super().on_activate(reader)
        for custom_key in self.owner.go_to_store_interaction.custom_keys_gen():
            self._test_event_register(TestEvent.InteractionComplete,
                                      custom_key)
        self.owner._set_job_role_state(self.owner.customer_job,
                                       self.owner.role_state_go_to_store)

    def handle_event(self, sim_info, event, resolver):
        if not self.owner.validate_customer(sim_info):
        neighbor = random.choice(neighbor_results)
        guest_list = SituationGuestList(
            invite_only=True,
            host_sim_id=neighbor.sim_info.sim_id,
            filter_requesting_sim_id=active_sim_info.sim_id)
        guest_list.add_guest_info(
            SituationGuestInfo(neighbor.sim_info.sim_id,
                               cls.neighbor_job_and_default_role_state.job,
                               RequestSpawningOption.DONT_CARE,
                               BouncerRequestPriority.EVENT_VIP,
                               expectation_preference=True))
        return guest_list

    def start_situation(self):
        super().start_situation()
        self._change_state(self._ring_doorbell_state())

    def _issue_requests(self):
        super()._issue_requests()
        request = SelectableSimRequestFactory(
            self,
            callback_data=_RequestUserData(),
            job_type=self.player_sim_job_and_default_role_state.job,
            exclusivity=self.exclusivity)
        self.manager.bouncer.submit_request(request)


lock_instance_tunables(
    NeighborHangoutSituation,
    exclusivity=BouncerExclusivityCategory.NORMAL,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE)
    def sim_of_interest(self, sim_info):
        if self._contestant_sim is not None and self._contestant_sim.sim_info is sim_info:
            return True
        return False

    def start_turn(self):
        self._change_state(self.take_turn_state())

    def on_turn_finished(self):
        self._change_state(self.wait_for_turn_state())
        services.venue_service().get_zone_director().select_next_contestant()


lock_instance_tunables(
    OpenMicContestant,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE,
    duration=0,
    _implies_greeted_status=False)


class PlayerSituationState(CommonInteractionCompletedSituationState):
    def _on_interaction_of_interest_complete(self, sim_info=None, **kwargs):
        if sim_info is None:
            return
        services.venue_service().get_zone_director().request_player_turn(
            sim_info)


class OpenMicPlayerControllerSituation(SituationComplexCommon):
    INSTANCE_TUNABLES = {
        'situation_state':
Exemple #45
0
class SimBackgroundSituation(situations.situation_complex.SituationComplexCommon):
    INSTANCE_TUNABLES = {'job_and_role_state': TunableSituationJobAndRoleState(description='\n            The job and role state for the sims\n            ')}
    REMOVE_INSTANCE_TUNABLES = Situation.NON_USER_FACING_REMOVE_INSTANCE_TUNABLES

    @classproperty
    def situation_serialization_option(cls):
        return SituationSerializationOption.DONT

    @classmethod
    def _states(cls):
        return (SituationStateData(1, _SimBackgroundSituationMainState),)

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.job_and_role_state.job, cls.job_and_role_state.role_state)]

    @classmethod
    def default_job(cls):
        pass

    def start_situation(self):
        super().start_situation()
        self._change_state(_SimBackgroundSituationMainState())

    def _issue_requests(self):
        request = BouncerRequestFactory(self, callback_data=_RequestUserData(role_state_type=self.job_and_role_state.role_state), job_type=self.job_and_role_state.job, request_priority=BouncerRequestPriority.BACKGROUND_LOW, user_facing=False, exclusivity=self.exclusivity)
        self.manager.bouncer.submit_request(request)

lock_instance_tunables(SimBackgroundSituation, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE, _implies_greeted_status=False)
        if result:
            self._restore_crate()
            self._pet_crate_x = None
            self._pet_crate_y = None
            self._pet_crate_z = None
        return result

    def _restore_crate(self):
        if self._pet_crate_x is None:
            return
        obj = create_object(self.pet_crate_object_definition)
        if obj is None:
            return
        position = sims4.math.Vector3(float(self._pet_crate_x),
                                      float(self._pet_crate_y),
                                      float(self._pet_crate_z))
        starting_location = placement.create_starting_location(
            position=position)
        fgl_context = placement.create_fgl_context_for_object(
            starting_location, obj, ignored_object_ids=(obj.id, ))
        (position, orientation) = placement.find_good_location(fgl_context)
        if position is not None and orientation is not None:
            obj.move_to(translation=position, orientation=orientation)
        else:
            obj.destroy()


lock_instance_tunables(
    SituationComplexAdoptionPet,
    exclusivity=BouncerExclusivityCategory.NORMAL,
    creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE)
Exemple #47
0
        super().__init__(choice_enumeration_strategy=StatePickerEnumerationStrategy(), *args, **kwargs)

    def _run_interaction_gen(self, timeline):
        self._choice_enumeration_strategy.build_choice_list(self, self.state)
        chosen_state = self._choice_enumeration_strategy.find_best_choice(self)
        if chosen_state is None:
            logger.error('{} fail to find a valid chosen state value for state {}'.format(self.__class__.__name__, self.state))
            return False
        chosen_state.activate_channel(interaction=self, push_affordances=self.push_additional_affordances)
        return True

    @classmethod
    def _test(cls, target, context, **kwargs):
        test_result = super()._test(target, context, **kwargs)
        if not test_result:
            return test_result
        if not StatePickerEnumerationStrategy.has_valid_choice(target, context, state=cls.state):
            return TestResult(False, 'No valid choice in State Picker Enumeration Strategy.')
        return TestResult.TRUE

class WatchCurrentChannelAutonomouslySuperInteraction(SuperInteraction):
    __qualname__ = 'WatchCurrentChannelAutonomouslySuperInteraction'
    INSTANCE_TUNABLES = {'state': objects.components.state.TunableStateTypeReference(description='The state used to populate the picker.')}

    def _run_interaction_gen(self, timeline):
        current_state = self.target.get_state(self.state)
        current_state.activate_channel(interaction=self, push_affordances=True)
        return True

lock_instance_tunables(AutonomousPickerSuperInteraction, allow_user_directed=False, basic_reserve_object=None, disable_transitions=True)
        return cls.cafe_generic_job.job

    def _on_set_sim_job(self, sim, job_type):
        super()._on_set_sim_job(sim, job_type)
        self._cafe_sim = sim

    def start_situation(self):
        super().start_situation()
        self._change_state(self.pre_order_coffee_state())

    def sim_of_interest(self, sim_info):
        if self._cafe_sim is not None and self._cafe_sim.sim_info is sim_info:
            return True
        return False

lock_instance_tunables(CafeGenericCustomerSituation, exclusivity=BouncerExclusivityCategory.NORMAL, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE, duration=0, _implies_greeted_status=False)

class _CafeGenericState(SituationState):
    pass

class CafeGenericBackgroundSituation(SituationComplexCommon):
    INSTANCE_TUNABLES = {'generic_sim_job': TunableSituationJobAndRoleState(description="\n            A job and role state that essentially does nothing but filter out\n            Sims that shouldn't be placed in the generic cafe sim situation.\n            "), 'cafe_generic_customer_situation': Situation.TunableReference(description='\n            The individual, generic cafe customer situation we want to use for\n            Sims that show up at the Cafe so they can go get coffee.\n            ', class_restrictions=('CafeGenericCustomerSituation',))}
    REMOVE_INSTANCE_TUNABLES = Situation.NON_USER_FACING_REMOVE_INSTANCE_TUNABLES

    @classmethod
    def _states(cls):
        return (SituationStateData(1, _CafeGenericState),)

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.generic_sim_job.job, cls.generic_sim_job.role_state)]
    def role_affordance_target(self):
        target = services.object_manager().get(self._crafted_object_id)
        if target is None:
            target = services.current_zone().inventory_manager.get(self._crafted_object_id)
        return target

    def _get_start_work_test(self):
        if self.start_work_test_and_state is not None:
            start_work_test = self.start_work_test_and_state.enter_state_test
            if start_work_test.affordances or start_work_test.tags:
                return start_work_test

    def _get_role_state_overrides(self, sim, job_type, role_state_type, role_affordance_target):
        return (role_state_type, self.role_affordance_target)

lock_instance_tunables(ServiceNpcSituation, creation_ui_option=SituationCreationUIOption.NOT_AVAILABLE, NPC_hosted_situation_player_job=None, venue_situation_player_job=None)

class ServiceNpcBaseSituationState(SituationState):
    __qualname__ = 'ServiceNpcBaseSituationState'

    def on_activate(self, reader):
        super().on_activate(reader)
        self._test_event_register(event_testing.test_events.TestEvent.InteractionComplete)
        self._test_event_register(event_testing.test_events.TestEvent.InteractionStart)

    def handle_event(self, sim_info, event, resolver):
        pass

class ArrivingOnLotSituationState(SituationState):
    __qualname__ = 'ArrivingOnLotSituationState'