本文整理汇总了Python中server_commands.argument_helpers.get_optional_target函数的典型用法代码示例。如果您正苦于以下问题:Python get_optional_target函数的具体用法?Python get_optional_target怎么用?Python get_optional_target使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_optional_target函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sims_for_job
def get_sims_for_job(session_id, sim_id, situation_type, job_type, *job_assignments, _connection=None):
sim = get_optional_target(sim_id, _connection)
situation_start_time = services.time_service().sim_now
duration = situation_type.duration
if duration > 0:
situation_end_time = situation_start_time + date_and_time.create_time_span(0, 0, duration)
else:
situation_start_time = date_and_time.INVALID_DATE_AND_TIME
situation_end_time = date_and_time.INVALID_DATE_AND_TIME
results = services.sim_filter_service().submit_filter(job_type.filter, None, requesting_sim_info=sim.sim_info, start_time=situation_start_time, end_time=situation_end_time, allow_yielding=False)
if job_type.additional_filter_for_user_selection:
sim_constraints = {result.sim_info.id for result in results}
results = services.sim_filter_service().submit_filter(job_type.additional_filter_for_user_selection, None, requesting_sim_info=sim.sim_info, start_time=situation_start_time, end_time=situation_end_time, sim_constraints=sim_constraints, allow_yielding=False)
msg = Situations_pb2.SituationJobSims()
msg.situation_session_id = session_id
msg.job_resource_id = job_type.guid
msg.requirements = job_type.requirement_text
results.sort(key=lambda x: (x.sim_info.is_npc, x.sim_info.last_name))
for result in results:
msg.sim_ids.append(result.sim_info.id)
with ProtocolBufferRollback(msg.sims) as situation_job_sim:
situation_job_sim.sim_id = result.sim_info.id
if result.sim_info.household.id == services.active_household_id():
situation_job_sim.account_id = result.sim_info.account_id
while result.conflicting_career_track_id:
situation_job_sim.career_track_id = result.conflicting_career_track_id
shared_messages.add_message_if_selectable(services.object_manager().get(sim.id), Consts_pb2.MSG_SITUATION_JOB_SIMS, msg, True)
示例2: get_valid_situation_locations
def get_valid_situation_locations(sim_id, situation_type, *guests, _connection=None):
sim = get_optional_target(sim_id, _connection)
if not sim:
sims4.commands.output('Invalid Sim ID: {}'.format(sim_id), _connection)
return
sim_info = sim.sim_info
possible_zones = []
possible_zones.append(sim_info.household.home_zone_id)
for guest_id in guests:
guest_id = int(guest_id)
guest_info = services.sim_info_manager().get(guest_id)
while guest_info is not None:
guest_zone_id = guest_info.household.home_zone_id
if guest_zone_id is not None and guest_zone_id and guest_zone_id not in possible_zones:
possible_zones.append(guest_zone_id)
venue_service = services.current_zone().venue_service
for venue_type in situation_type.venue_types:
possible_zones.extend(venue_service.get_zones_for_venue_type(venue_type))
venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE)
persistence_service = services.get_persistence_service()
locations_msg = Situations_pb2.SituationLocations()
cas_zones_msg = InteractionOps_pb2.CASAvailableZonesInfo()
world_info_msg = cas_zones_msg.zones.add()
for zone_id in possible_zones:
zone_data = persistence_service.get_zone_proto_buff(zone_id)
if zone_data is None:
pass
neighborhood_data = persistence_service.get_neighborhood_proto_buff(zone_data.neighborhood_id)
if neighborhood_data is None:
pass
lot_data = None
for lot_owner_data in neighborhood_data.lots:
while zone_id == lot_owner_data.zone_instance_id:
lot_data = lot_owner_data
break
while zone_data is not None and lot_data is not None:
location_data = Dialog_pb2.LotInfoItem()
location_data.zone_id = zone_data.zone_id
location_data.name = zone_data.name
location_data.world_id = zone_data.world_id
location_data.lot_template_id = zone_data.lot_template_id
location_data.lot_description_id = zone_data.lot_description_id
venue_type_id = build_buy.get_current_venue(zone_id)
venue_instance = venue_manager.get(venue_type_id)
if venue_instance is not None:
location_data.venue_type_name = venue_instance.display_name
if lot_data.lot_owner:
household_id = lot_data.lot_owner[0].household_id
household = services.household_manager().get(household_id)
if household is not None:
location_data.household_name = household.name
locations_msg.situation_locations.append(location_data)
with ProtocolBufferRollback(world_info_msg.zones) as zone_info_msg:
zone_info_msg.id = zone_data.zone_id
zone_info_msg.name = zone_data.name
zone_info_msg.world_id = zone_data.world_id
zone_info_msg.lot_template_id = zone_data.lot_template_id
zone_info_msg.lot_description_id = zone_data.lot_description_id
shared_messages.add_object_message_for_sim_id(sim.id, Consts_pb2.MSG_NS_AVAILABLE_ZONES_INFO, cas_zones_msg)
shared_messages.add_object_message_for_sim_id(sim.id, Consts_pb2.MSG_SITUATION_LOCATIONS, locations_msg)
示例3: test_ping_autonomy
def test_ping_autonomy(opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is None:
sims4.commands.output('No target for autonomy.run', _connection)
return
selected_interaction = sim.run_test_autonomy_ping()
sims4.commands.output('Autonomy Test Ping: {}'.format(selected_interaction), _connection)
示例4: pregnancy_clear
def pregnancy_clear(sim_id:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(sim_id, _connection)
if sim is not None:
pregnancy_tracker = sim.sim_info.pregnancy_tracker
pregnancy_tracker.clear_pregnancy()
return True
return False
示例5: make_greeted
def make_greeted(opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is None:
sims4.commands.output('Invalid sim: {} provided.'.format(opt_sim), _connection)
return
situation_manager = services.get_zone_situation_manager()
situation_manager.make_waiting_player_greeted(sim)
示例6: broadcasters_add
def broadcasters_add(broadcaster_type, broadcasting_object:OptionalTargetParam=None, _connection=None):
broadcasting_object = get_optional_target(broadcasting_object, _connection)
if broadcasting_object is None:
return False
broadcaster = broadcaster_type(broadcasting_object=broadcasting_object)
services.current_zone().broadcaster_service.add_broadcaster(broadcaster)
return True
示例7: automation_current_active_role
def automation_current_active_role(opt_target:OptionalTargetParam=None, _connection=None):
target = get_optional_target(opt_target, _connection)
if target is None:
sims4.commands.automation_output('SimRole; SimId:None', _connection)
return False
role = target.active_roles().__class__.__name__ if target.active_roles() is not None else 'None'
sims4.commands.automation_output('SimRole; SimId:{}, Role:{}'.format(target.id, role), _connection)
示例8: genalogy_print
def genalogy_print(sim_id:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(sim_id, _connection)
if sim is None:
return False
genealogy = sim.sim_info.genealogy
genealogy.log_contents()
return True
示例9: get_carried_objects
def get_carried_objects(opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is None:
sims4.commands.output('Invalid Sim id: {}'.format(opt_sim), _connection)
return False
for (hand, _, obj) in get_carried_objects_gen(sim):
sims4.commands.output('\t{}: {}'.format(hand, obj), _connection)
return True
示例10: current_active_role
def current_active_role(opt_target:OptionalTargetParam=None, _connection=None):
target = get_optional_target(opt_target, _connection)
if target is None:
return False
if target.active_roles():
sims4.commands.output('Active Roles: {}'.format(target.active_roles()), _connection)
else:
sims4.commands.output('Sim has no active role', _connection)
示例11: start_single_sim_performance_test
def start_single_sim_performance_test(opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is None:
sims4.commands.output('No target for qa.automation.start_single_sim_performance_test', _connection)
return
sim.reset(ResetReason.RESET_EXPECTED, None, 'start_single_sim_performance_test')
services.autonomy_service().start_single_sim_load_test(_connection, sim)
sim.run_full_autonomy_next_ping()
示例12: career_demote_sim
def career_demote_sim(career_type, opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is not None:
career = sim.sim_info.career_tracker.get_career_by_uid(career_type.guid64)
if career is not None:
career.demote()
return True
return False
示例13: reset_achievements
def reset_achievements(opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is not None:
account = services.account_service().get_account_by_id(sim.sim_info.account_id)
account.achievement_tracker.reset_data()
sims4.commands.output('Achievements reset complete', _connection)
else:
sims4.commands.output('Account not found, please check: |achievements.reset_data <sim id from desired account>', _connection)
示例14: pregnancy_seed
def pregnancy_seed(seed, sim_id:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(sim_id, _connection)
if sim is not None:
pregnancy_tracker = sim.sim_info.pregnancy_tracker
if pregnancy_tracker.is_pregnant:
pregnancy_tracker._seed = seed
return True
return False
示例15: show_autonomy_settings
def show_autonomy_settings(opt_sim:OptionalTargetParam=None, _connection=None):
sim = get_optional_target(opt_sim, _connection)
if sim is None:
sims4.commands.output("Couldn't find Sim.", _connection)
return
autonomy_state = _convert_state_to_string(sim.get_autonomy_state_setting())
autonomy_randomization = _convert_randomization_to_string(sim.get_autonomy_randomization_setting())
selected_sim_autonomy_enabled = services.autonomy_service()._selected_sim_autonomy_enabled
sims4.commands.output('Autonomy State: {}\nAutonomyRandomization: {}\nSelected Sim Autonomy: {}'.format(autonomy_state, autonomy_randomization, selected_sim_autonomy_enabled), _connection)