"""Miscellaneous helper functions for rubato developers."""fromtypingimportSequencefrom.importVector,GameObject,Component,Game,Input
[docs]defworld_mouse()->Vector:""" Returns the mouse position in world-coordinates. Returns: Vector: The mouse position in world coordinates. """ifGame._current!="":returnGame.current().camera.i_transform(Input.get_mouse_pos())returnInput.get_mouse_pos()
[docs]defwrap(comp:Component|Sequence[Component],pos:Vector|tuple[float,float]=(0,0),rotation:float=0,# test: skipz_index:int=0,ignore_cam:bool=False,parent:GameObject|None=None,name:str="",debug:bool=False,active:bool=True,hidden:bool=False,):""" Wraps a component or list of components in a GameObject. Args: comp: The component or list of components to wrap. pos: The position of the GameObject. Defaults to (0, 0). rotation: The rotation of the GameObject. Defaults to 0. z_index: The z_index of the GameObject. Defaults to 0. ignore_cam: Whether the GameObject ignores the scene's camera when drawing or not. Defaults to False. parent: The parent GameObject of the GameObject. Defaults to None. name: The name of the GameObject. Defaults to "". debug: Whether the GameObject is in debug mode. Defaults to False. active: Whether the GameObject is active. Defaults to True. hidden: Whether the GameObject is hidden. Defaults to False. Raises: TypeError: If comp is not a Component or a list of Components. Returns: The wrapped GameObject. """go=GameObject(pos=pos,rotation=rotation,z_index=z_index,ignore_cam=ignore_cam,parent=parent,name=name,debug=debug,active=active,hidden=hidden)ifisinstance(comp,Component):go.add(comp)elifisinstance(comp,list):go.add(*comp)else:raiseTypeError("comp must be a Component or a list of Components.")returngo