def is_at_home(sim_info: SimInfo) -> bool:
     """ Determine if a Sim is currently at home. """
     active_lot = CommonLocationUtils.get_current_lot()
     return CommonLocationUtils.get_current_zone_id(
     ) == CommonHouseholdUtils.get_household_lot_id(
         sim_info) and active_lot.is_position_on_lot(
             CommonSimLocationUtils.get_position(sim_info))
Exemplo n.º 2
0
    def get_household_home_lot_id(household: Household) -> int:
        """get_household_home_lot_id(household)

        Retrieve the decimal identifier of the home Lot for a Household.

        :param household: An instance of a Household.
        :type household: Household
        :return: The home zone identifier of the specified Household or -1 if a problem occurs.
        :rtype: int
        """
        from sims4communitylib.utils.location.common_location_utils import CommonLocationUtils
        if household is None:
            return -1
        home_zone_id = CommonHouseholdUtils.get_household_home_zone_id(
            household)
        if home_zone_id == -1:
            return -1
        home_zone = CommonLocationUtils.get_zone(home_zone_id,
                                                 allow_unloaded_zones=True)
        if home_zone is None or not home_zone.is_instantiated:
            return home_zone_id or -1
        lot = CommonLocationUtils.get_zone_lot(home_zone)
        if lot is None:
            return home_zone_id or -1
        return CommonLocationUtils.get_lot_id(lot)
    def is_at_home(sim_info: SimInfo) -> bool:
        """is_at_home(sim_info)

        Determine if a Sim is currently at home.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is at their home lot. False, if not.
        :rtype: bool
        """
        active_lot = CommonLocationUtils.get_current_lot()
        return CommonLocationUtils.get_current_zone_id(
        ) == CommonHouseholdUtils.get_household_lot_id(
            sim_info) and active_lot.is_position_on_lot(
                CommonSimLocationUtils.get_position(sim_info))
 def is_allowed_on_current_lot(sim_info: SimInfo) -> bool:
     """ Determine if a Sim is allowed on the current lot. """
     from sims4communitylib.utils.common_component_utils import CommonComponentUtils
     from sims4communitylib.enums.types.component_types import CommonComponentType
     from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils
     if CommonSimLocationUtils.is_at_home(sim_info):
         return True
     if CommonSimLocationUtils.is_renting_current_lot(sim_info):
         return True
     if CommonSimTypeUtils.is_player_sim(sim_info) and (
             CommonLocationUtils.current_venue_allows_role_state_routing()
             or not CommonLocationUtils.
             current_venue_requires_player_greeting()):
         return True
     sim = CommonSimUtils.get_sim_instance(sim_info)
     autonomy_component: AutonomyComponent = CommonComponentUtils.get_component(
         sim, CommonComponentType.AUTONOMY)
     if autonomy_component is None or not hasattr(autonomy_component,
                                                  'active_roles'):
         return False
     for role_state_instance in autonomy_component.active_roles():
         if CommonSimTypeUtils.is_non_player_sim(sim_info):
             if role_state_instance._portal_disallowance_tags or not role_state_instance._allow_npc_routing_on_active_lot:
                 return False
         elif role_state_instance._portal_disallowance_tags:
             return False
     return True
    def send_to_position(sim_info: SimInfo, location_position: Vector3,
                         level: int) -> Union[EnqueueResult, None]:
        """send_to_position(sim_info, location_position, level)

        Send a Sim to the specified location.

        :param sim_info: The Sim to send.
        :type sim_info: SimInfo
        :param location_position: The position to send the sim to.
        :type location_position: Vector3
        :param level: The level at which the position is.
        :type level: int
        :return: The result of sending the Sim to the specified location or None if they could not go there.
        :rtype: EnqueueResult
        """
        from server_commands.sim_commands import _build_terrain_interaction_target_and_context, CommandTuning
        if location_position is None:
            return None
        sim = CommonSimUtils.get_sim_instance(sim_info)
        # noinspection PyUnresolvedReferences
        pos = sims4.math.Vector3(location_position.x, location_position.y,
                                 location_position.z)
        routing_surface = routing.SurfaceIdentifier(
            CommonLocationUtils.get_current_zone_id(), level,
            routing.SurfaceType.SURFACETYPE_WORLD)
        (target, context) = _build_terrain_interaction_target_and_context(
            sim, pos, routing_surface, PickType.PICK_TERRAIN,
            objects.terrain.TerrainPoint)
        return sim.push_super_affordance(
            CommandTuning.TERRAIN_GOHERE_AFFORDANCE, target, context)
    def phone_is_silenced() -> bool:
        """phone_is_silenced()

        Determine if the phone is silenced.

        :return: True, if the Phone is silenced. False, if not.
        :rtype: bool
        """
        # noinspection PyUnresolvedReferences
        return CommonLocationUtils.get_current_zone(
        ).ui_dialog_service.is_phone_silenced
Exemplo n.º 7
0
    def is_renting_current_lot(sim_info: SimInfo) -> bool:
        """is_renting_current_lot(sim_info)

        Determine if a Sim is renting the current lot.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is renting the active lot. False, if not.
        :rtype: bool
        """
        return sim_info.is_renting_zone(CommonLocationUtils.get_current_zone_id())
Exemplo n.º 8
0
    def is_on_current_lot(sim_info: SimInfo) -> bool:
        """is_on_current_lot(sim_info)

        Determine if a Sim is on the active Lot.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is on the active Lot. False, if not.
        :rtype: bool
        """
        active_lot = CommonLocationUtils.get_current_lot()
        return CommonSimLocationUtils.is_on_lot(sim_info, active_lot)
Exemplo n.º 9
0
    def is_at_home(sim_info: SimInfo) -> bool:
        """is_at_home(sim_info)

        Determine if a Sim is on their home Lot.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is on their home Lot. False, if not.
        :rtype: bool
        """
        sim = CommonSimUtils.get_sim_instance(sim_info)
        if sim is None or not CommonHouseholdUtils.has_household(sim_info):
            return False
        return sim.on_home_lot or (CommonLocationUtils.get_current_zone_id() == CommonHouseholdUtils.get_household_zone_id(sim_info) and CommonSimLocationUtils.is_on_current_lot(sim_info))
Exemplo n.º 10
0
    def is_on_lot(sim_info: SimInfo, lot: Lot) -> bool:
        """is_on_lot(sim_info, lot)

        Determine if a Sim is on a Lot.

        :param sim_info: An instance of a Sim.
        :type sim_info: SimInfo
        :param lot: An instance of a Lot.
        :type lot: Lot
        :return: True, if the Sim is on the specified Lot. False, if not.
        :rtype: bool
        """
        sim_position = CommonSimLocationUtils.get_position(sim_info)
        if sim_position is None:
            return False
        return CommonLocationUtils.is_position_on_lot(sim_position, lot)
    def can_be_routed_to(game_object: GameObject) -> bool:
        """can_be_routed_to(game_object)

        Determine if an Object can be routed to by Sims.

        :param game_object: An instance of an Object.
        :type game_object: GameObject
        :return: True, if the Object can be routed to by Sims. False, it not.
        :rtype: bool
        """
        position = CommonObjectLocationUtils.get_position(
            game_object) + CommonObjectLocationUtils.get_forward_vector(
                game_object)
        routing_surface = CommonObjectLocationUtils.get_routing_surface(
            game_object)
        return CommonLocationUtils.can_position_be_routed_to(
            position, routing_surface)
 def send_to_position(sim_info: SimInfo, location_position: Vector3,
                      level: int):
     """ Send a sim to the specified location. """
     from server_commands.sim_commands import _build_terrain_interaction_target_and_context, CommandTuning
     if location_position is None:
         return False
     sim = CommonSimUtils.get_sim_instance(sim_info)
     # noinspection PyUnresolvedReferences
     pos = sims4.math.Vector3(location_position.x, location_position.y,
                              location_position.z)
     routing_surface = routing.SurfaceIdentifier(
         CommonLocationUtils.get_current_zone_id(), level,
         routing.SurfaceType.SURFACETYPE_WORLD)
     (target, context) = _build_terrain_interaction_target_and_context(
         sim, pos, routing_surface, PickType.PICK_TERRAIN,
         objects.terrain.TerrainPoint)
     return sim.push_super_affordance(
         CommandTuning.TERRAIN_GOHERE_AFFORDANCE, target, context)
    def get_root_position(game_object: GameObject) -> CommonVector3:
        """get_root_position(game_object)

        Calculate the position of an Object based off of the position of it's Root bone.

        :param game_object: An instance of an Object.
        :type game_object: GameObject
        :return: The position of the Object based off of the position of it's Root bone.
        :rtype: CommonVector3
        """
        object_position = CommonObjectLocationUtils.get_bone_position(
            game_object, bone_name='b__ROOT__'
        ) or CommonObjectLocationUtils.get_position(game_object)
        if object_position is not None and CommonObjectTypeUtils.is_window(
                game_object):
            # For whatever reason, windows have a Y coordinate of -0.0. We fix it here.
            object_position = CommonVector3(
                object_position.x,
                CommonLocationUtils.get_surface_height_at(
                    object_position.x, object_position.z,
                    CommonObjectLocationUtils.get_routing_surface(
                        game_object)), object_position.z)
        return object_position
 def is_renting_current_lot(sim_info: SimInfo) -> bool:
     """ Determine if a Sim is renting the current lot. """
     return sim_info.is_renting_zone(
         CommonLocationUtils.get_current_lot_id())
 def _set_phone_is_silenced(is_silenced: bool):
     # noinspection PyUnresolvedReferences
     CommonLocationUtils.get_current_zone(
     ).ui_dialog_service._set_is_phone_silenced(is_silenced)