• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python services.current_zone函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中services.current_zone函数的典型用法代码示例。如果您正苦于以下问题:Python current_zone函数的具体用法?Python current_zone怎么用?Python current_zone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了current_zone函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create_object

def create_object(definition_or_id, obj_id=0, init=None, post_add=None, loc_type=None, **kwargs):
    from objects.components.inventory_item import ItemLocation
    from objects.base_object import BaseObject
    added_to_object_manager = False
    obj = None
    if loc_type is None:
        loc_type = ItemLocation.ON_LOT
    try:
        obj = create_script_object(definition_or_id, **kwargs)
        if obj is None:
            return
        if not isinstance(obj, BaseObject):
            logger.error('Type {0} is not a valid managed object.  It is not a subclass of BaseObject.', type(obj))
            return
        if init is not None:
            init(obj)
        if loc_type == ItemLocation.FROM_WORLD_FILE:
            obj.persistence_group = PersistenceGroups.IN_OPEN_STREET
        obj.item_location = ItemLocation(loc_type) if loc_type is not None else ItemLocation.INVALID_LOCATION
        obj.id = obj_id
        if loc_type == ItemLocation.ON_LOT or loc_type == ItemLocation.FROM_WORLD_FILE or loc_type == ItemLocation.FROM_OPEN_STREET:
            obj.object_manager_for_create.add(obj)
        elif loc_type == ItemLocation.SIM_INVENTORY or loc_type == ItemLocation.OBJECT_INVENTORY:
            services.current_zone().inventory_manager.add(obj)
        else:
            logger.error('Unsupported loc_type passed to create_script_object.  We likely need to update this code path.', owner='mduke')
        added_to_object_manager = True
        if post_add is not None:
            post_add(obj)
        return obj
    finally:
        if not added_to_object_manager and obj is not None:
            import _weakrefutils
            _weakrefutils.clear_weak_refs(obj)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:34,代码来源:system.py


示例2: get_save_lot_coords_and_level

 def get_save_lot_coords_and_level(self):
     lot_coord_msg = LotCoord()
     parent = self.parent
     if parent is not None and parent.is_sim:
         parent.force_update_routing_location()
         starting_position = parent.position + parent.forward
         search_flags = CarryingObject.SNAP_TO_GOOD_LOCATION_SEARCH_FLAGS
         (trans, orient) = placement.find_good_location(placement.FindGoodLocationContext(starting_position=starting_position, starting_orientation=parent.orientation, starting_routing_surface=self.location.world_routing_surface, object_footprints=(self.footprint,), object_id=self.id, search_flags=search_flags))
         if trans is None:
             logger.warn('Unable to find good location to save object{}, which is parented to sim {} and cannot go into an inventory. Defaulting to location of sim.', self, parent)
             transform = parent.transform
         else:
             transform = sims4.math.Transform(trans, orient)
         transform = services.current_zone().lot.convert_to_lot_coordinates(transform)
     elif self.persistence_group == PersistenceGroups.OBJECT:
         transform = services.current_zone().lot.convert_to_lot_coordinates(self.transform)
     else:
         transform = self.transform
     lot_coord_msg.x = transform.translation.x
     lot_coord_msg.y = transform.translation.y
     lot_coord_msg.z = transform.translation.z
     lot_coord_msg.rot_x = transform.orientation.x
     lot_coord_msg.rot_y = transform.orientation.y
     lot_coord_msg.rot_z = transform.orientation.z
     lot_coord_msg.rot_w = transform.orientation.w
     if self.location.world_routing_surface is not None:
         level = self.location.level
     else:
         level = 0
     return (lot_coord_msg, level)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:30,代码来源:game_object.py


示例3: _on_leaving_situation

 def _on_leaving_situation(self, end_work_reason):
     service_npc_type = self._service_npc_type
     household = self._hiring_household
     try:
         now = services.time_service().sim_now
         time_worked = now - self._service_start_time
         time_worked_in_hours = time_worked.in_hours()
         if self._had_preroll_work:
             cost = service_npc_type.get_cost(time_worked_in_hours)
         else:
             cost = 0
         if cost > 0:
             (paid_amount, billed_amount) = service_npc_type.try_charge_for_service(household, cost)
             end_work_reason = ServiceNpcEndWorkReason.NOT_PAID
         else:
             paid_amount = 0
             billed_amount = 0
         self._send_end_work_notification(end_work_reason, paid_amount, billed_amount)
         service_record = household.get_service_npc_record(service_npc_type.guid64)
         service_record.time_last_finished_service = now
         if end_work_reason == ServiceNpcEndWorkReason.FIRED:
             service_sim = self.service_sim()
             if service_record is not None:
                 service_record.add_fired_sim(service_sim.id)
                 service_record.remove_preferred_sim(service_sim.id)
         while end_work_reason in ServiceNpcSituation.CANCEL_SERVICE_LEAVING_REASONS:
             services.current_zone().service_npc_service.cancel_service(household, service_npc_type)
     except Exception as e:
         logger.exception('Exception while executing _on_leaving_situation for situation {}', self, exc=e)
     finally:
         if not self._is_recurring:
             services.current_zone().service_npc_service.cancel_service(household, service_npc_type)
     return end_work_reason
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:33,代码来源:service_npc_situation.py


示例4: on_add

 def on_add(self):
     if self._relationship_based_state_change_tuning is None:
         return
     self._state_changes = self._relationship_based_state_change_tuning.state_changes
     self._default_state = self._relationship_based_state_change_tuning.default_state
     services.current_zone().register_callback(zone_types.ZoneState.CLIENT_CONNECTED, self._register_active_sim_change)
     services.current_zone().register_callback(zone_types.ZoneState.HOUSEHOLDS_AND_SIM_INFOS_LOADED, self._publish_relationship_data)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:object_relationship_component.py


示例5: on_update

 def on_update(self):
     super().on_update()
     if self._countdown <= 0:
         services.current_zone().on_hit_their_marks()
         return _ZoneSpinUpStateResult.DONE
     services.game_clock_service().advance_for_hitting_their_marks()
     return _ZoneSpinUpStateResult.WAITING
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:zone_spin_up_service.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:broadcaster_commands.py


示例7: set_venue

def set_venue(venue_type, _connection=None):
    venue_tuning = services.venue_manager().get(venue_type)
    if venue_tuning is None:
        sims4.commands.output('Requesting an unknown venue type: {0}'.format(venue_type), _connection)
        return False
    services.current_zone().venue_service.set_venue_and_schedule_events(venue_tuning)
    return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:venue_commands.py


示例8: on_enter

 def on_enter(self):
     super().on_enter()
     services.current_zone().lot.publish_shared_inventory_items()
     active_household_id = services.active_household_id()
     for script_object in services.object_manager().get_all():
         script_object.finalize(active_household_id=active_household_id)
     return _ZoneSpinUpStateResult.DONE
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:zone_spin_up_service.py


示例9: add

 def add(self, obj, *args, **kwargs):
     super().add(obj, *args, **kwargs)
     if obj.objectage_component is None:
         services.current_zone().increment_object_count(obj)
         household_manager = services.household_manager()
         if household_manager is not None:
             household_manager.increment_household_object_count(obj.get_household_owner_id())
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:object_manager.py


示例10: _run_interaction_gen

 def _run_interaction_gen(self, timeline):
     sim = self.sim
     end_time = services.time_service().sim_now + create_time_span(hours=8)
     fake_alarm_data = AlarmData(None, end_time, None, False)
     default_user_specified_data_id = self._service_tuning.get_default_user_specified_data_id()
     creation_data = ServiceNpcSituationCreationParams(sim.household, self._service_tuning, user_specified_data_id=default_user_specified_data_id, is_recurring=False)
     services.current_zone().service_npc_service._send_service_npc(None, fake_alarm_data, creation_data)
     return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:cheat_interaction.py


示例11: get_jog_waypoint_constraints

 def get_jog_waypoint_constraints(cls, context):
     sim = context.sim
     if context.pick is not None:
         pick_position = context.pick.location
         pick_vector = pick_position - sim.position
         pick_vector /= pick_vector.magnitude()
     else:
         pick_vector = sim.forward
     zone = services.current_zone()
     active_lot = zone.lot
     lot_corners = active_lot.corners
     sim_poly = sims4.geometry.CompoundPolygon(sims4.geometry.Polygon([sim.position]))
     lot_poly = sims4.geometry.CompoundPolygon(sims4.geometry.Polygon([corner for corner in lot_corners]))
     intersection = lot_poly.intersect(sim_poly)
     sim_on_lot = len(intersection) >= 1
     if sim_on_lot:
         spawn_point = zone.get_spawn_point(lot_id=active_lot.lot_id, sim_spawner_tags=SimInfoSpawnerTags.SIM_SPAWNER_TAGS)
         origin_position = spawn_point.center
         routing_surface = routing.SurfaceIdentifier(zone.id, 0, routing.SURFACETYPE_WORLD)
         except_lot_id = active_lot.lot_id
     else:
         origin_position = sim.position
         routing_surface = sim.routing_surface
         except_lot_id = None
     interaction_constraint = Circle(origin_position, cls.CONSTRAINT_RADIUS, routing_surface=routing_surface, los_reference_point=None)
     jog_waypoint_constraints = []
     zone = services.current_zone()
     active_lot = zone.lot
     constraint_set = zone.get_spawn_points_constraint(except_lot_id=except_lot_id)
     constraints_weighted = []
     min_score = sims4.math.MAX_FLOAT
     for constraint in constraint_set:
         spawn_point_vector = constraint.average_position - sim.position
         score = sims4.math.vector_dot_2d(pick_vector, spawn_point_vector)
         if score < min_score:
             min_score = score
         constraints_weighted.append((score, constraint))
     constraints_weighted = [(score - min_score, constraint) for (score, constraint) in constraints_weighted]
     constraints_weighted = sorted(constraints_weighted, key=lambda i: i[0])
     first_constraint = constraints_weighted[-1][1]
     del constraints_weighted[-1]
     first_constraint_circle = Circle(first_constraint.average_position, cls.CONSTRAINT_RADIUS, routing_surface=first_constraint.routing_surface)
     jog_waypoint_constraints.append(first_constraint_circle)
     last_waypoint_position = first_constraint.average_position
     for _ in range(cls.NUM_JOG_POINTS - 1):
         constraints_weighted_next = []
         for (_, constraint) in constraints_weighted:
             average_position = constraint.average_position
             distance_last = (average_position - last_waypoint_position).magnitude_2d()
             distance_home = (average_position - origin_position).magnitude_2d()
             constraints_weighted_next.append((distance_last + distance_home, constraint))
         next_constraint = pop_weighted(constraints_weighted_next)
         next_constraint_circle = Circle(next_constraint.average_position, cls.CONSTRAINT_RADIUS, routing_surface=next_constraint.routing_surface)
         jog_waypoint_constraints.append(next_constraint_circle)
         constraints_weighted = constraints_weighted_next
         last_waypoint_position = next_constraint.average_position
     jog_waypoint_constraints.append(interaction_constraint)
     return (interaction_constraint, jog_waypoint_constraints)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:58,代码来源:jog_interaction.py


示例12: cancel_service

def cancel_service(service_npc_type, max_duration:int=240, _connection=None):
    service_npc_tuning = services.service_npc_manager().get(service_npc_type)
    if service_npc_tuning is not None:
        tgt_client = services.client_manager().get(_connection)
        if tgt_client is None:
            return False
        household = tgt_client.household
        services.current_zone().service_npc_service.cancel_service(household, service_npc_tuning)
        return True
    return False
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:10,代码来源:service_npc_commands.py


示例13: stop

 def stop(self):
     if self._alarm_handle is not None:
         cancel_alarm(self._alarm_handle)
         self._alarm_handle = None
     if self._processing_task is not None:
         self._processing_task.stop()
         self._processing_task = None
     object_manager = services.object_manager()
     object_manager.unregister_callback(CallbackTypes.ON_OBJECT_LOCATION_CHANGED, self._update_object_cache)
     object_manager.unregister_callback(CallbackTypes.ON_OBJECT_ADD, self._update_object_cache)
     services.current_zone().wall_contour_update_callbacks.remove(self._update_object_cache)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:11,代码来源:broadcaster_service.py


示例14: create_situation_for_venue_type

def create_situation_for_venue_type(situation_type, venue_type, opt_sim:OptionalTargetParam=None, _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if not services.current_zone().venue_service.has_zone_for_venue_type((venue_type,)):
        sims4.commands.output('There are no zones that support the venue type provided, {}.'.format(venue_type), _connection)
        return False
    situation_manager = services.get_zone_situation_manager()
    (zone_id, _) = services.current_zone().venue_service.get_zone_and_venue_type_for_venue_types((venue_type,))
    guest_list = SituationGuestList(False, sim.id)
    situation_id = situation_manager.create_situation(situation_type, guest_list=guest_list, user_facing=True, zone_id=zone_id)
    if situation_id is None:
        sims4.commands.output('Insufficient funds to create situation', _connection)
    else:
        sims4.commands.output('Successfully created situation: {}.'.format(situation_id), _connection)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:13,代码来源:situation_commands.py


示例15: c_api_buildbuy_session_begin

def c_api_buildbuy_session_begin(zone_id, account_id):
    with sims4.zone_utils.global_zone_lock(zone_id):
        posture_graph_service = services.current_zone().posture_graph_service
        posture_graph_service.on_enter_buildbuy()
        services.current_zone().on_build_buy_enter()
        indexed_manager.IndexedManager.add_gc_collect_disable_reason(
            BUILD_BUY_OBJECT_LEAK_DISABLED)
        resource_keys = []
        current_zone = services.current_zone()
        household = current_zone.get_active_lot_owner_household()
        if household is not None:
            for unlock in household.build_buy_unlocks:
                resource_keys.append(unlock)
        update_gameplay_unlocked_products(resource_keys, zone_id, account_id)
    return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:15,代码来源:build_buy.py


示例16: generate_summary_report

def generate_summary_report(skip_atomic, reverse_entries):
    labeled_roots = []
    from objects.definition_manager import DefinitionManager
    from sims4.tuning.instance_manager import InstanceManager
    from indexed_manager import IndexedManager
    from postures.posture_graph import PostureGraphService
    SERVICE_GROUPS = [(DefinitionManager, 'DefinitionManager'), (InstanceManager, 'TuningManager'), (IndexedManager, 'IndexedManager'), (PostureGraphService, 'PostureGraph'), (object, 'Other')]
    direction_iter = reversed if reverse_entries else iter
    zone = services.current_zone()
    service_sources = []
    zone_services = [source for service in zone.service_manager.services for source in service.get_buckets_for_memory_tracking()]
    service_sources.append((zone_services, 'ZoneService/'))
    core_services = [source for service in sims4.core_services.service_manager.services for source in service.get_buckets_for_memory_tracking()]
    service_sources.append((core_services, 'CoreService/'))
    for (source, source_name) in service_sources:
        for service in direction_iter(source):
            group = source_name + _first_applicable_match(service, SERVICE_GROUPS)
            labeled_roots.append(('{1}/{0}'.format(service, group), [service]))
    for (name, module) in direction_iter(sorted(sys.modules.items())):
        path_root = 'Other'
        if hasattr(module, '__file__'):
            matching_paths = [path for path in sys.path if module.__file__.startswith(path)]
            if matching_paths:
                path_root = os.path.split(next(iter(matching_paths)))[-1]
                path_root = path_root.capitalize()
        group = 'Module/{}'.format(path_root)
        labeled_roots.append(('{1}/{0}'.format(name, group), [module]))
    report = sizeof.report(labeled_roots, skip_atomic=skip_atomic)
    return report
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:memory_commands.py


示例17: _update

 def _update(self, force_create=False):
     if services.get_super_speed_three_service().in_or_has_requested_super_speed_three():
         gsi_handlers.ambient_handlers.archive_ambient_data('In super speed 3 mode')
         return
     if not self._sources:
         return
     if gsi_handlers.ambient_handlers.archiver.enabled:
         gsi_description = self.get_gsi_description()
     else:
         gsi_description = None
     sources_and_priorities = [(source, source.get_priority()) for source in self._sources]
     sources_and_priorities.sort(key=lambda source: source[1], reverse=True)
     situation_id = None
     source = sources_and_priorities[0][0]
     priority = sources_and_priorities[0][1]
     if priority > 0:
         situation_id = source.start_appropriate_situation()
     elif force_create:
         for (source, _) in sources_and_priorities:
             situation_id = source.start_appropriate_situation()
             while situation_id is not None:
                 break
     if gsi_handlers.ambient_handlers.archiver.enabled:
         if situation_id is not None:
             situation = services.current_zone().situation_manager.get(situation_id)
             gsi_description += '    Created {}'.format(situation)
         gsi_handlers.ambient_handlers.archive_ambient_data(gsi_description)
     return situation_id
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:ambient_service.py


示例18: get_hide_from_lot_picker

def get_hide_from_lot_picker(_connection=None):
    current_zone = services.current_zone()
    world_desc_id = services.get_world_description_id(current_zone.world_id)
    lot = current_zone.lot
    b = services.get_hide_from_lot_picker(lot.lot_id, world_desc_id)
    output = sims4.commands.Output(_connection)
    output('c_api returned {} for lot {} and world {}'.format(b, lot.lot_id, current_zone.world_id))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:developer_commands.py


示例19: _start_broadcaster

 def _start_broadcaster(self):
     if not self.should_broadcast:
         return
     broadcaster_service = services.current_zone().broadcaster_service
     if broadcaster_service is not None and self._broadcaster is None:
         self._broadcaster = EnvironmentScoreTuning.ENVIRONMENT_SCORE_BROADCASTER(broadcasting_object=self.owner)
         broadcaster_service.add_broadcaster(self._broadcaster)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:environment_score_component.py


示例20: _complete_pregnancy_gen

    def _complete_pregnancy_gen(self, timeline, pregnancy_tracker):
        is_off_lot_birth = False
        for offspring_data in pregnancy_tracker.get_offspring_data_gen():
            sim_info = pregnancy_tracker.create_sim_info(offspring_data)
            current_zone = services.current_zone()
            if current_zone.id == sim_info.zone_id:
                create_and_place_baby(sim_info, ignore_daycare=True)
            else:
                is_off_lot_birth = True
        offspring_count = pregnancy_tracker.offspring_count
        pregnancy_tracker.complete_pregnancy()
        pregnancy_tracker.clear_pregnancy()
        if is_off_lot_birth:
            travel_liability = TravelSimLiability(self, self.sim.sim_info, self.sim.sim_info.household.home_zone_id, expecting_dialog_response=True)
            self.add_liability(TRAVEL_SIM_LIABILITY, travel_liability)

            def on_travel_dialog_response(dialog):
                if dialog.accepted:
                    save_lock_liability = self.get_liability(SaveLockLiability.LIABILITY_TOKEN)
                    if save_lock_liability is not None:
                        save_lock_liability.release()
                    travel_liability.travel_dialog_response(dialog)

            travel_dialog_element = UiDialogElement(self.sim, self.get_resolver(), dialog=self.off_lot_birth_dialog, on_response=on_travel_dialog_response, additional_tokens=(offspring_count,))
            result = yield element_utils.run_child(timeline, travel_dialog_element)
            return result
        return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:pregnancy_interactions.py



注:本文中的services.current_zone函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python services.get_instance_manager函数代码示例发布时间:2022-05-27
下一篇:
Python services.client_manager函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap