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 add_role(name:str=None, opt_target:OptionalTargetParam=None, _connection=None): target = get_optional_target(opt_target, _connection) if target is None or name is None: return False role_state_type = services.role_state_manager().get(name) if role_state_type is None: sims4.commands.output('role({0}) is not a valid role'.format(name), _connection) return False role_state = target.add_role(role_state_type) if role_state is not None: sims4.commands.output('role({0}) has been added onto sim'.format(name), _connection) else: sims4.commands.output('role({0}) has FAILED to be added onto sim'.format(name), _connection)
def remove_role(name:str=None, opt_target:OptionalTargetParam=None, _connection=None): target = get_optional_target(opt_target, _connection) if target is None or name is None: return False role_state_type = services.role_state_manager().get(name) if role_state_type is None: sims4.commands.output('role({0}) is not a valid role'.format(name), _connection) return False if target.remove_role_of_type(role_state_type): sims4.commands.output('role({0}) has been removed'.format(name), _connection) return True sims4.commands.output('role({0}) was not in sims role list'.format(name), _connection) return False