本文整理汇总了Python中services.get_instance_manager函数的典型用法代码示例。如果您正苦于以下问题:Python get_instance_manager函数的具体用法?Python get_instance_manager怎么用?Python get_instance_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_instance_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select_career
def select_career(sim_id:int=None, career_instance_id:int=None, track_id:int=None, level:int=None, company_name_hash:int=None, reason:int=CareerOps.JOIN_CAREER, _connection=None):
if sim_id is None or (career_instance_id is None or track_id is None) or level is None:
logger.error('Not all of the data needed for the careers.select command was passed.')
return False
career_manager = services.get_instance_manager(sims4.resources.Types.CAREER)
career_type = career_manager.get(career_instance_id)
if career_type is None:
logger.error('invalid career Id sent to careers.select')
return False
sim = services.object_manager().get(sim_id)
if sim_id is None:
logger.error('invalid sim Id passed to careers.select')
return False
career_track_manager = services.get_instance_manager(sims4.resources.Types.CAREER_TRACK)
career_track = career_track_manager.get(track_id)
if career_track is None:
logger.error('invalid career track Id passed to careers.select')
return False
if reason is None:
logger.error('invalid career selection reason passed to careers.select')
return False
career_tracker = sim.sim_info.career_tracker
if reason == CareerOps.JOIN_CAREER:
current_career = career_tracker.get_career_by_uid(career_instance_id)
if current_career is not None:
current_career.set_new_career_track(track_id)
else:
career_tracker.add_career(career_type(sim.sim_info, company_name=company_name_hash), show_confirmation_dialog=True)
if reason == CareerOps.QUIT_CAREER:
career_tracker.remove_career(career_instance_id)
示例2: offer_goals
def offer_goals(self, debug_goal=None, debug_target=None, request_single_goal=False, emotion_only=False):
if not self.emotion_whim_needed and self.whims_needed == 0:
return
if self._sim_info.is_npc:
return
if self._sim is None:
return
chosen_tuned_goals = {}
if self.whims_needed > 0:
normal_whimset_list = services.get_instance_manager(sims4.resources.Types.ASPIRATION).normal_whim_sets
prioritized_tuned_whim_sets = []
for whim_set in normal_whimset_list:
priority = self.get_priority(whim_set)
while priority != 0:
prioritized_tuned_whim_sets.append((priority, whim_set))
if not emotion_only:
self._select_goals(prioritized_tuned_whim_sets, chosen_tuned_goals, debug_goal, debug_target, request_single_goal)
if self.emotion_whim_needed:
emotion_whimset_list = services.get_instance_manager(sims4.resources.Types.ASPIRATION).emotion_whim_sets
prioritized_tuned_whim_sets = []
for whim_set in emotion_whimset_list:
priority = self.get_priority(whim_set)
while priority != 0 and whim_set.whimset_emotion is self._sim_mood:
prioritized_tuned_whim_sets.append((priority, whim_set))
self._select_goals(prioritized_tuned_whim_sets, chosen_tuned_goals, debug_goal, debug_target)
if self._goals_dirty:
index = 0
for tuned_goal in chosen_tuned_goals:
goal_added = False
if chosen_tuned_goals[tuned_goal].whimset_emotion is not None:
goal = tuned_goal(sim_info=self._sim_info, goal_id=self._goal_id_generator(), inherited_target_sim_info=self._whimset_target_map[chosen_tuned_goals[tuned_goal]])
self._active_whims[WhimsTracker.MAX_GOALS] = goal
goal_added = True
else:
while index < WhimsTracker.MAX_GOALS:
if self._active_whims[index] is None:
goal = tuned_goal(sim_info=self._sim_info, goal_id=self._goal_id_generator(), inherited_target_sim_info=self._whimset_target_map[chosen_tuned_goals[tuned_goal]])
self._active_whims[index] = goal
goal_added = True
break
index += 1
if goal_added:
self._realized_goals[goal] = chosen_tuned_goals[tuned_goal]
goal.register_for_on_goal_completed_callback(self._on_goal_completed)
logger.debug('Added whim for {}: {}', self._sim_info, goal, owner='jjacobson')
else:
logger.error('Trying to add a whim when the active whims are already full.', owner='jjacobson.')
with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_WHIM_EVENT, sim=self._sim_info) as hook:
hook.write_int(TELEMETRY_WHIM_EVENT_TYPE, TelemetryWhimEvents.ADDED)
hook.write_guid(TELEMETRY_WHIM_GUID, goal.guid64)
if len(self._realized_goals) > WhimsTracker.MAX_GOALS + 1:
logger.error('Too many whims active. Current Whims: {}', self._realized_goals.keys(), owner='jjacobson')
示例3: _verify_tuning_callback
def _verify_tuning_callback(cls):
if cls.use_ingredients:
for ingredient in cls.use_ingredients.ingredient_list:
while ingredient is None:
logger.error('Recipe {} has unset ingredients', cls.__name__)
if not cls.use_ingredients.ingredient_list:
logger.error('Recipe {} has an empty ingredient list and its tuned to use ingredients.', cls.__name__)
if not cls.name:
logger.error('Recipe {} does not have a name set', cls.__name__)
if not cls.phase_interaction_name:
logger.error('Recipe {} does not have a phase interaction name set', cls.__name__)
cls._validate_final_product()
services.get_instance_manager(sims4.resources.Types.RECIPE).add_on_load_complete(cls.validate_base_recipe)
示例4: start
def start(self):
self._enabled = True
for aspiration in services.get_instance_manager(sims4.resources.Types.ASPIRATION).types.values():
while not aspiration.disabled:
self.register_single_event(aspiration, TestEvent.UpdateObjectiveData)
self._handlers_to_unregister_post_load.add(aspiration)
if not aspiration.complete_only_in_sequence:
aspiration.register_callbacks()
for achievement in services.get_instance_manager(sims4.resources.Types.ACHIEVEMENT).types.values():
while not achievement.disabled:
self.register_single_event(achievement, TestEvent.UpdateObjectiveData)
self._handlers_to_unregister_post_load.add(achievement)
achievement.register_callbacks()
示例5: has_zone_for_venue_type
def has_zone_for_venue_type(self, venue_types):
venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE)
for neighborhood_proto in services.get_persistence_service().get_neighborhoods_proto_buf_gen():
for lot_owner_info in neighborhood_proto.lots:
zone_id = lot_owner_info.zone_instance_id
while zone_id is not None:
venue_type_id = build_buy.get_current_venue(zone_id)
venue_type = venue_manager.get(venue_type_id)
if venue_type and venue_type in venue_types:
return True
instance_manager = services.get_instance_manager(sims4.resources.Types.MAXIS_LOT)
for lot_instance in instance_manager.types.values():
while lot_instance.supports_any_venue_type(venue_types):
return True
return False
示例6: generate_achievement_view_data
def generate_achievement_view_data(sim_id:int=None):
sim_info = services.sim_info_manager().get(sim_id)
achievement_manager = services.get_instance_manager(sims4.resources.Types.ACHIEVEMENT)
all_achievements = []
for achievement_id in achievement_manager.types:
achievement = achievement_manager.get(achievement_id)
achievement_data = {}
achievement_data['achievement'] = str(achievement)
achievement_data['achievement_uid'] = int(achievement.guid64)
achievement_data['category'] = str(achievement.category)
achievement_data['points'] = int(achievement.point_value)
achievement_data['display_name'] = str(hex(achievement.display_name.hash))
achievement_data['description'] = str(hex(achievement.descriptive_text.hash))
achievement_data['achievement_complete'] = False
achievement_data['objectives'] = []
achievement_data['simId'] = str(sim_id)
if not sim_info.account.achievement_tracker.milestone_completed(achievement.guid64):
for objective in achievement.objectives:
objective_data = {}
objective_data['objective'] = str(objective)
if sim_info.account.achievement_tracker.objective_completed(objective.guid64):
objective_data['objective_complete'] = True
else:
objective_data['objective_complete'] = False
achievement_data['objectives'].append(objective_data)
else:
achievement_data['achievement_complete'] = True
for objective in achievement.objectives:
objective_data = {}
objective_data['objective'] = str(objective)
objective_data['objective_complete'] = True
achievement_data['objectives'].append(objective_data)
all_achievements.append(achievement_data)
return all_achievements
示例7: load
def load(self, save_data):
trait_manager = services.get_instance_manager(sims4.resources.Types.TRAIT)
self._num_traits = save_data.num_traits
for trait_inst_id in save_data.trait_ids:
trait = trait_manager.get(trait_inst_id)
while trait is not None:
self.known_traits.add(trait)
示例8: load
def load(self, crafting_process_message):
recipe_manager = services.get_instance_manager(sims4.resources.Types.RECIPE)
self.recipe = recipe_manager.get(crafting_process_message.recipe_id)
for phase in self.recipe.phases.values():
if phase.id == crafting_process_message.phase_id:
self.phase = phase
else:
while phase.id == crafting_process_message.previous_phase_id:
self._previous_phase = phase
current_ico = services.object_manager().get(crafting_process_message.current_ico)
if current_ico is None:
current_ico = services.inventory_manager().get(crafting_process_message.current_ico)
if current_ico is not None:
self._current_ico_ref = current_ico.ref()
if crafting_process_message.crafter_sim_id != 0:
self._crafter_sim_id = crafting_process_message.crafter_sim_id
self.add_order(self._crafter_sim_id, self.recipe)
if crafting_process_message.HasField('inscription'):
self.inscription = crafting_process_message.inscription
if crafting_process_message.HasField('crafted_value'):
self.crafted_value = crafting_process_message.crafted_value
statistic_component = self.get_component(objects.components.types.STATISTIC_COMPONENT)
statistic_tracker = statistic_component.get_statistic_tracker()
if statistic_tracker is not None:
statistic_tracker.load(crafting_process_message.statistic_tracker.statistics)
示例9: get_career_list
def get_career_list(self):
career_list = []
career_manager = services.get_instance_manager(sims4.resources.Types.CAREER)
for career_id in career_manager.types:
career_tuning = career_manager.get(career_id)
career_list.append(career_tuning)
return career_list
示例10: get_tunable_instance
def get_tunable_instance(resource_type, name_string_or_id, exact_match=False):
manager = services.get_instance_manager(resource_type)
cls = manager.get(name_string_or_id)
if cls is not None:
return cls
if not sims4.commands.check_permission(sims4.commands.CommandType.DebugOnly):
raise ValueError()
search_string = str(name_string_or_id).lower()
match = None
for cls in manager.types.values():
if exact_match:
if search_string == cls.__name__.lower():
return cls
if search_string == cls.__name__.lower():
return cls
while search_string in cls.__name__.lower():
if match is not None:
raise ValueError("Multiple names matched '{}': {}, {}, ...".format(search_string, match, cls))
match = cls
else:
if search_string == cls.__name__.lower():
return cls
while search_string in cls.__name__.lower():
if match is not None:
raise ValueError("Multiple names matched '{}': {}, {}, ...".format(search_string, match, cls))
match = cls
if match is None:
raise ValueError("No names matched '{}'.".format(search_string))
return match
示例11: 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)
示例12: find_household_template_that_contains_sim_filter
def find_household_template_that_contains_sim_filter(cls, sim_creations_to_match):
valid_filter_template_type = []
if cls._household_templates_override:
templates_to_iterate_over = cls._household_templates_override
else:
templates_to_iterate_over = services.get_instance_manager(sims4.resources.Types.SIM_TEMPLATE).types.values()
for filter_template_type in templates_to_iterate_over:
if filter_template_type.template_type == filters.sim_template.SimTemplateType.SIM:
pass
index_to_sim_creation = {}
for sim_creation in sim_creations_to_match:
for (index, household_member_data) in enumerate(filter_template_type.get_household_members()):
if index in index_to_sim_creation:
pass
if household_member_data.sim_template._sim_creation_info.age_variant is not None and sim_creation.age != household_member_data.sim_template._sim_creation_info.age_variant.min_age:
pass
possible_gender = household_member_data.sim_template._sim_creation_info.gender
if possible_gender is not None and possible_gender != sim_creation.gender:
pass
index_to_sim_creation[index] = sim_creation
while len(index_to_sim_creation) == len(sim_creations_to_match):
valid_filter_template_type.append((filter_template_type, index_to_sim_creation))
if valid_filter_template_type:
return random.choice(valid_filter_template_type)
return (None, None)
示例13: get_career_entry_level
def get_career_entry_level(self, career_history=None, resolver=None):
if career_history is None or self.guid64 not in career_history:
level = int(self.start_level_modifiers.get_max_modifier(resolver))
max_level = len(self.start_track.career_levels)
level = sims4.math.clamp(0, level, max_level - 1)
return (level, level + 1, None)
history = career_history[self.guid64]
new_level = history.career_level
new_user_level = history.user_level
time_left = history.time_left
current_track_uid = history.track_uid
current_track = services.get_instance_manager(sims4.resources.Types.CAREER_TRACK).get(current_track_uid)
new_level -= self.levels_lost_on_leave
new_user_level -= self.levels_lost_on_leave
current_time = services.time_service().sim_now
time_gone_from_career = current_time - time_left
days_gone_from_career = time_gone_from_career.in_days()
if self.days_to_level_loss > 0:
levels_to_lose = int(days_gone_from_career/self.days_to_level_loss)
new_level -= levels_to_lose
new_user_level -= levels_to_lose
if new_level < 0:
new_level = 0
if new_user_level < 1:
new_user_level = 1
return (new_level, new_user_level, current_track)
示例14: generate_aspiration_view_data
def generate_aspiration_view_data(sim_id:int=None):
sim_info = services.sim_info_manager().get(sim_id)
aspiration_manager = services.get_instance_manager(sims4.resources.Types.ASPIRATION)
all_aspirations = []
for aspiration_id in aspiration_manager.types:
aspiration = aspiration_manager.get(aspiration_id)
aspiration_data = {}
aspiration_data['aspiration'] = str(aspiration)
aspiration_data['aspiration_uid'] = int(aspiration.guid64)
if issubclass(aspiration, Aspiration):
aspiration_data['display_name'] = str(hex(aspiration.display_name.hash))
aspiration_data['description'] = str(hex(aspiration.descriptive_text.hash))
aspiration_data['auto_select'] = str(aspiration)
aspiration_data['aspiration_complete'] = False
aspiration_data['objectives'] = []
aspiration_data['simId'] = str(sim_id)
if not sim_info.aspiration_tracker.milestone_completed(aspiration.guid64):
for objective in aspiration.objectives:
objective_data = {}
objective_data['objective'] = str(objective)
if sim_info.aspiration_tracker.objective_completed(objective.guid64):
objective_data['objective_complete'] = True
else:
objective_data['objective_complete'] = False
aspiration_data['objectives'].append(objective_data)
else:
aspiration_data['aspiration_complete'] = True
for objective in aspiration.objectives:
objective_data = {}
objective_data['objective'] = str(objective)
objective_data['objective_complete'] = True
aspiration_data['objectives'].append(objective_data)
all_aspirations.append(aspiration_data)
return all_aspirations
示例15: tuning_reload
def tuning_reload(_connection=None):
sims4.callback_utils.invoke_callbacks(sims4.callback_utils.CallbackEvent.TUNING_CODE_RELOAD)
done = set()
dependents = set()
for manager in get_managers().values():
for changed in manager.get_changed_files():
done.add(changed)
new_dependents = manager.reload_by_key(changed)
while new_dependents is not None:
dependents.update(new_dependents)
dependents.difference_update(done)
while dependents:
next_dependent = dependents.pop()
done.add(next_dependent)
next_type = next_dependent.type
manager = services.get_instance_manager(next_type)
new_dependents = manager.reload_by_key(next_dependent)
while new_dependents is not None:
new_dependents.difference_update(done)
dependents.update(new_dependents)
continue
sims4.commands.output('Reloading definitions tags: Begin.', _connection)
services.definition_manager().refresh_build_buy_tag_cache()
sims4.commands.output('Reloading definitions tags: End.', _connection)
sims4.commands.output('Reload done', _connection)
return True