def soft_reset(game_object: GameObject, reset_reason: ResetReason = ResetReason.RESET_EXPECTED, hard_reset_on_exception: bool = False, source: Any = None, cause: Any = 'S4CL Soft Reset') -> bool: """soft_reset(game_object, reset_reason=ResetReason.RESET_EXPECTED, hard_reset_on_exception=False, source=None, cause=None) Perform a soft reset on an Object. :param game_object: An instance of an Object. :type game_object: GameObject :param reset_reason: The reason for the reset. Default is ResetReason.RESET_EXPECTED. :type reset_reason: ResetReason, optional :param hard_reset_on_exception: If set to True, a hard reset of the Object will be attempted upon an error occurring. If set to False, nothing will occur if the reset failed. Default is False. :type hard_reset_on_exception: bool, optional :param source: The source of the reset. Default is the GameObject. :type source: Any, optional :param cause: The cause of the reset. Default is 'S4CL Soft Reset'. :type cause: Any, optional :return: True, if the reset was successful. False, if not. :rtype: bool """ if game_object is None: return True # noinspection PyBroadException try: if game_object.parent is not None and game_object.parent.is_sim and not game_object.parent.posture_state.is_carrying( game_object): CarryingObject.snap_to_good_location_on_floor( game_object, starting_transform=game_object.parent.transform, starting_routing_surface=game_object.parent.routing_surface ) location = game_object.location game_object.on_reset_send_op(reset_reason) game_object.location = location game_object.resend_location() if game_object.routing_component is not None: game_object.routing_component.on_reset_internal_state( reset_reason) if game_object.idle_component is not None: game_object.idle_component._refresh_active_idle() if game_object.linked_object_component is not None: game_object.linked_object_component._relink(update_others=True) return True except: if hard_reset_on_exception: return CommonObjectSpawnUtils.hard_reset( game_object, reset_reason=reset_reason, source=source, cause=cause) return False
def set_location(game_object: GameObject, location: Vector3) -> bool: """set_location(game_object, location) Set the location of an Object. :param game_object: An instance of an Object. :type game_object: GameObject :param location: The location to put the Object. :type location: Vector3 :return: True, if successful. False, if not. :rtype: bool """ if game_object is None or location is None: return False game_object.location = location return True