def __init__(self, **kwargs): super().__init__( situation=TunableReference( description= '\n The Situation to start when this Interaction runs.\n ', manager=services.situation_manager()), user_facing=Tunable( description= '\n If checked, then the situation will be user facing (have goals, \n and scoring).\n \n If not checked, then situation will not be user facing.\n \n This setting does not override the user option to make all\n situations non-scoring.\n \n Example: \n Date -> Checked\n Invite To -> Not Checked\n ', tunable_type=bool, default=True), description='Start a Situation as part of this Interaction.')
class StreetCreateSituationEffect(StreetEffect): INSTANCE_TUNABLES = { 'situation': TunableReference( description='\n The situation to start.\n ', manager=services.situation_manager()) } def enact(self): situation_manager = services.get_zone_situation_manager() situation_manager.create_situation(self.situation, user_facing=False) def repeal(self): pass
def get_situation_data(session_id: int = 0, sim_id: OptionalTargetParam = None, *situation_ids, _connection=None): sim = get_optional_target(sim_id, _connection) instance_manager = services.situation_manager() situation_batch_msg = Situations_pb2.SituationDataBatch() situation_batch_msg.situation_session_id = session_id for situation_id in situation_ids: with ProtocolBufferRollback( situation_batch_msg.situations) as situation_data: instance = instance_manager.get(situation_id) while instance is not None: shared_messages.build_icon_info_msg((instance._icon, None), instance._display_name, situation_data.icon_info) situation_data.icon_info.desc = instance.situation_description situation_data.cost = instance._cost situation_data.max_participants = instance.max_participants for medal in SituationMedal: with ProtocolBufferRollback( situation_data.rewards) as reward_msg: level = instance.get_level_data(medal) reward_msg.level = int(medal) while level is not None and level.reward is not None: reward_msg.display_name.extend( [level.reward.reward_description]) jobs = list(instance.get_tuned_jobs()) jobs.sort(key=lambda job: job.guid64) if instance.job_display_ordering is not None: for ordered_job in reversed(instance.job_display_ordering): while ordered_job in jobs: jobs.remove(ordered_job) jobs.insert(0, ordered_job) for job in jobs: while job.sim_count.upper_bound > 0: with ProtocolBufferRollback( situation_data.jobs) as job_msg: job_msg.job_resource_id = job.guid64 shared_messages.build_icon_info_msg( (job.icon, None), job.display_name, job_msg.icon_info) job_msg.icon_info.desc = job.job_description job_msg.is_hireable = job.can_be_hired job_msg.min_required = job.sim_count.lower_bound job_msg.max_allowed = job.sim_count.upper_bound job_msg.hire_cost = job.hire_cost shared_messages.add_message_if_selectable( sim, Consts_pb2.MSG_SITUATION_DATA_BATCH, situation_batch_msg, True)
class ButlerSituationStateChange(BaseLootOperation): FACTORY_TUNABLES = { 'butler_situation': TunablePackSafeReference( description= "\n The Situation who's state will change.\n ", manager=services.situation_manager()), 'operation': TunableVariant( description= '\n Enable or disable operation for tuned tone.\n ', locked_args={ 'enable': True, 'disable': False }, default='enable'), 'situation_state': TunableEnumEntry( description= '\n Situation state for the butler that should be enabled or disabled\n depending on the operation.\n ', tunable_type=ButlerSituationStates, default=ButlerSituationStates.DEFAULT, invalid_enums=(ButlerSituationStates.DEFAULT, )) } def __init__(self, *args, butler_situation, operation, situation_state, **kwargs): super().__init__(*args, **kwargs) self._butler_situation = butler_situation self._operation = operation self._situation_state = situation_state def _apply_to_subject_and_target(self, subject, target, resolver): if subject is None: return situation_manager = services.get_zone_situation_manager() butler_situation = situation_manager.get_situation_by_type( self._butler_situation) if butler_situation is None: logger.error( 'Sim {} trying to switch situation state {} while not running the butler situation', subject, self._situation_state) return if self._operation: butler_situation.enable_situation_state(self._situation_state) else: butler_situation.disable_situation_state(self._situation_state)
class JoinSituationElement(XevtTriggeredElement): FACTORY_TUNABLES = { 'situation_type': TunableReference( description='\n The situation to join.\n ', manager=services.situation_manager()), 'situation_job': OptionalTunable( description= '\n The situation job that sim will get to while join the situation.\n ', tunable=TunableReference(manager=services.situation_job_manager()), disabled_name='use_default_job', enabled_name='specify_job', disabled_value=DEFAULT), 'subject': TunableEnumFlags( description= '\n The participant of who will join the situation.\n ', enum_type=ParticipantType, default=ParticipantType.Actor) } def _do_behavior(self, *args, **kwargs): situation_manager = services.get_zone_situation_manager() situation = situation_manager.get_situation_by_type( self.situation_type) if situation is None: logger.error( 'Fail to join situation since cannot find running situation {} for interaction {}', self.situation_type, self.interaction, owner='cjiang') return False subject = self.interaction.get_participant(self.subject) if subject is None or not subject.is_sim: logger.error( 'Fail to join situation since subject {} is not sim for interaction {}', self.subject, self.interaction, owner='cjiang') return False situation.invite_sim_to_job(subject, job=self.situation_job) return True
def deserialize_from_proto(cls, seed_proto): situation_type = services.situation_manager().get(seed_proto.situation_type_id) if situation_type is None: return guest_list = SituationGuestList(seed_proto.invite_only, seed_proto.host_sim_id, seed_proto.filter_requesting_sim_id) for assignment in seed_proto.assignments: job_type = services.situation_job_manager().get(assignment.job_type_id) if job_type is None: continue role_state_type = services.role_state_manager().get(assignment.role_state_type_id) guest_info = SituationGuestInfo(assignment.sim_id, job_type, RequestSpawningOption(assignment.spawning_option), BouncerRequestPriority(assignment.request_priority), assignment.expectation_preference, assignment.accept_alternate_sim, SituationCommonBlacklistCategory(assignment.common_blacklist_categories), elevated_importance_override=assignment.elevated_importance_override, reservation=assignment.reservation) guest_info._set_persisted_role_state_type(role_state_type) guest_list.add_guest_info(guest_info) if seed_proto.HasField('duration'): duration = seed_proto.duration else: duration = None seed = SituationSeed(situation_type, seed_proto.seed_purpose, seed_proto.situation_id, guest_list, seed_proto.user_facing, duration, seed_proto.zone_id, date_and_time.DateAndTime(seed_proto.start_time), seed_proto.scoring_enabled, main_goal_visiblity=seed_proto.main_goal_visibility, linked_sim_id=seed_proto.linked_sim_id) seed._score = seed_proto.score if seed_proto.HasField('create_time'): seed._travel_time = DateAndTime(seed_proto.create_time) for job_data in seed_proto.jobs_and_role_states: job_type = services.situation_job_manager().get(job_data.job_type_id) if job_type is None: continue role_state_type = services.role_state_manager().get(job_data.role_state_type_id) if role_state_type is None: continue emotional_loot_actions_type = None if job_data.HasField('emotional_loot_actions_type_id'): emotional_loot_actions_type = services.action_manager().get(job_data.emotional_loot_actions_type_id) seed.add_job_data(job_type, role_state_type, emotional_loot_actions_type) if seed_proto.HasField('simple_data'): seed.add_situation_simple_data(seed_proto.simple_data.phase_index, seed_proto.simple_data.remaining_phase_time) elif seed_proto.HasField('complex_data'): complex_data = seed_proto.complex_data situation_custom_data = complex_data.situation_custom_data if complex_data.HasField('situation_custom_data') else None state_custom_data = complex_data.state_custom_data if complex_data.HasField('state_custom_data') else None seed.setup_for_complex_load(situation_custom_data, state_custom_data) if seed_proto.HasField('goal_tracker_data'): seed._goal_tracker = GoalTrackerSeedling.deserialize_from_proto(seed_proto.goal_tracker_data) return seed
def __init__(self, **kwargs): super().__init__( description= '\n Triggers the Situation Creation UI.\n ', targeted_situation_participant=OptionalTunable( description= '\n Tuning to make this situation creature UI to use the targeted\n situation UI instead of the regular situation creation UI.\n ', tunable=TunableEnumEntry( description= '\n The target participant for this Situation.\n ', tunable_type=ParticipantType, default=ParticipantType.TargetSim)), situations_available=OptionalTunable( description= "\n An optional list of situations to filter with. This way, we can\n pop up the plan an event flow, but restrict the situations that\n are available. They still have to test for availability, but we\n won't show others if one or more of these succeed.\n \n If the list contains any situations, other situations will not\n show up if any in the list pass their tests. If the list is\n empty or this field is disabled, then any situations that pass\n their tests will be available.\n ", tunable=TunableList( description= '\n A list of Situations to restrict the Plan an Event flow.\n ', tunable=TunableReference( description= '\n An available Situation in the Plan an Event flow.\n ', manager=services.situation_manager()))))
def get_situation_data(session_id:int=0, sim_id:OptionalTargetParam=None, *situation_ids, _connection=None): sim = get_optional_target(sim_id, _connection) instance_manager = services.situation_manager() situation_batch_msg = Situations_pb2.SituationDataBatch() situation_batch_msg.situation_session_id = session_id for situation_id in situation_ids: with ProtocolBufferRollback(situation_batch_msg.situations) as situation_data: instance = instance_manager.get(situation_id) while instance is not None: shared_messages.build_icon_info_msg((instance._icon, None), instance._display_name, situation_data.icon_info) situation_data.icon_info.desc = instance.situation_description situation_data.cost = instance._cost situation_data.max_participants = instance.max_participants for medal in SituationMedal: with ProtocolBufferRollback(situation_data.rewards) as reward_msg: level = instance.get_level_data(medal) reward_msg.level = int(medal) while level is not None and level.reward is not None: reward_msg.display_name.extend([level.reward.reward_description]) jobs = list(instance.get_tuned_jobs()) jobs.sort(key=lambda job: job.guid64) if instance.job_display_ordering is not None: for ordered_job in reversed(instance.job_display_ordering): while ordered_job in jobs: jobs.remove(ordered_job) jobs.insert(0, ordered_job) for job in jobs: while job.sim_count.upper_bound > 0: with ProtocolBufferRollback(situation_data.jobs) as job_msg: job_msg.job_resource_id = job.guid64 shared_messages.build_icon_info_msg((job.icon, None), job.display_name, job_msg.icon_info) job_msg.icon_info.desc = job.job_description job_msg.is_hireable = job.can_be_hired job_msg.min_required = job.sim_count.lower_bound job_msg.max_allowed = job.sim_count.upper_bound job_msg.hire_cost = job.hire_cost shared_messages.add_message_if_selectable(sim, Consts_pb2.MSG_SITUATION_DATA_BATCH, situation_batch_msg, True)
def __init__(self, **kwargs): super().__init__( situation=TunableReference( description= '\n The Situation to start when this Interaction runs.\n ', manager=services.situation_manager()), user_facing=Tunable( description= '\n If checked, then the situation will be user facing (have goals, \n and scoring).\n \n If not checked, then situation will not be user facing.\n \n This setting does not override the user option to make all\n situations non-scoring.\n \n Example: \n Date -> Checked\n Invite To -> Not Checked\n ', tunable_type=bool, default=True), linked_sim_participant=OptionalTunable( description= '\n If enabled, this situation will be linked to the specified Sim.\n ', tunable=TunableEnumEntry(tunable_type=ParticipantType, default=ParticipantType.Actor)), invite_participants=TunableMapping( description= "\n The map to invite certain participants into the situation as\n specified job if assigned. Otherwise will invite them as\n situation's default job.\n ", key_type=TunableEnumEntry( description= '\n The participant of who will join the situation.\n ', tunable_type=ParticipantType, default=ParticipantType.Actor), key_name='participants_to_invite', value_type=OptionalTunable(tunable=TunableList( description= '\n A list of situation jobs that can be specified. If a\n single job is specified then all Sims will be given\n that job. Otherwise we will loop through all of the\n Sims invited and give them jobs in list order. The\n list will begin to be repeated if we run out of jobs.\n \n NOTE: We cannot guarantee the order of the Sims being\n passed in most of the time. Use this if you want a\n distribution of different jobs, but without a guarantee\n that Sims will be assigned to each one.\n ', tunable=TunableReference( manager=services.situation_job_manager())), disabled_name='use_default_job', enabled_name='specify_job'), value_name='invite_to_job'), invite_actor=Tunable( description= '\n If checked, then the actor of this interaction will be invited\n in the default job. This is the common case.\n \n If not checked, then the actor will not be invited. The Tell\n A Ghost Story interaction spawning a Ghost walkby is an example.\n \n If your situation takes care of all the sims that should be in\n the default job itself (such as auto-invite) it will probably\n not work if this is checked.\n ', tunable_type=bool, default=True), actor_init_job=OptionalTunable( description= '\n The Situation job actor would be assigned while join the situation.\n ', tunable=TunableReference( manager=services.situation_job_manager()), disabled_name='use_default_job', enabled_name='specify_job'), invite_picked_sims=Tunable( description= '\n If checked then any picked sims of this interaction will be\n invited to the default job. This is the common case.\n \n If not checked, then any picked sims will not be invited. The\n Tell A Ghost Story interaction spawning a Ghost walkby is an\n example.\n \n If your situation takes care of all the sims that should be in\n the default job itself (such as auto-invite) it will probably\n not work if this is checked.\n ', tunable_type=bool, default=True), invite_target_sim=Tunable( description= '\n If checked then the target sim of this interaction will be\n invited to the default job. This is the common case.\n \n If not checked, then the target sim will not be invited. The\n Tell A Ghost Story interaction spawning a Ghost walkby is an\n example.\n \n If your situation takes care of all the sims that should be in\n the default job itself (such as auto-invite) it will probably\n not work if this is checked.\n ', tunable_type=bool, default=True), target_init_job=OptionalTunable( description= '\n The Situation job target would be assigned while join the situation.\n ', tunable=TunableReference( manager=services.situation_job_manager()), disabled_name='use_default_job', enabled_name='specify_job'), invite_household_sims_on_active_lot=Tunable( description= '\n If checked then all instanced sims on the active lot will be\n invited. This is not a common case. An example of this is\n leaving the hospital after having a baby, bringing both sims\n home.\n \n If not checked, then no additional sims will be invited.\n \n If your situation takes care of all the sims that should be in\n the default job itself (such as auto-invite) it will probably\n not work if this is checked.\n ', tunable_type=bool, default=False), situation_default_target=OptionalTunable( description= '\n If enabled, the participant of the interaction will be set as\n the situation target object.\n ', tunable=TunableEnumEntry( description= "\n The participant that will be set as the situation's default target\n ", tunable_type=ParticipantType, default=ParticipantType.Object)), situation_guest_info=OptionalTunable( description= '\n By default, situation guest infos are created as an invite.\n This overrrides that behavior.\n ', tunable=SituationGuestInfoFactory()), description='Start a Situation as part of this Interaction.', **kwargs)
def __init__(self, **kwargs): super().__init__(situation=TunableReference(description='\n The Situation to start when this Interaction runs.\n ', manager=services.situation_manager()), user_facing=Tunable(description='\n If checked, then the situation will be user facing (have goals, \n and scoring).\n \n If not checked, then situation will not be user facing.\n \n This setting does not override the user option to make all\n situations non-scoring.\n \n Example: \n Date -> Checked\n Invite To -> Not Checked\n ', tunable_type=bool, default=True), description='Start a Situation as part of this Interaction.')
def __init__(self, **kwargs): super().__init__(description='\n Triggers the Situation Creation UI.\n ', targeted_situation_participant=OptionalTunable(description='\n Tuning to make this situation creature UI to use the targeted\n situation UI instead of the regular situation creation UI.\n ', tunable=TunableEnumEntry(description='\n The target participant for this Situation.\n ', tunable_type=ParticipantType, default=ParticipantType.TargetSim)), situations_available=OptionalTunable(description="\n An optional list of situations to filter with. This way, we can\n pop up the plan an event flow, but restrict the situations that\n are available. They still have to test for availability, but we\n won't show others if one or more of these succeed.\n \n If the list contains any situations, other situations will not\n show up if any in the list pass their tests. If the list is\n empty or this field is disabled, then any situations that pass\n their tests will be available.\n ", tunable=TunableList(description='\n A list of Situations to restrict the Plan an Event flow.\n ', tunable=TunableReference(description='\n An available Situation in the Plan an Event flow.\n ', manager=services.situation_manager()))))