### Low-Level RoadPoint Connection (Less Recommended) Source: https://github.com/theduckcow/godot-road-generator/wiki/Class:-RoadPoint Manually set the `next_pt_init` and `prior_pt_init` properties to connect RoadPoints. This method is less recommended as it might interfere with internal plugin logic. ```gdscript # You can also do this in a low-level way, though is less recommended as it may get in the way of plugin internals: target_point.next_pt_init = target_point.get_path_to(new_rp) new_rp.prior_pt_init = new_rp.get_path_to(target_point) ``` -------------------------------- ### Add and Configure a RoadPoint Source: https://github.com/theduckcow/godot-road-generator/wiki/Class:-RoadPoint Instantiate a new RoadPoint, add it to a RoadContainer, and set its traffic direction. Ensure the RoadPoint is added as a child to an existing RoadContainer. ```gdscript # Add a RoadPoint var new_rp = RoadPoint.new() # Be sure to add as a child to a RoadContaineralready in your scene. # You can fetch all RoadContainers via RoadManager's `get_containers()` function. var container: RoadContainer container.add_child(new_rp) # Set the number of lanes: 1 reverse, 2 forward new_rp.traffic_dir = [RoadPoint.LaneDir.REVERSE, RoadPoint.LaneDir.FORWARD, RoadPoint.LaneDir.FORWARD] ``` -------------------------------- ### Gut Doubled Script Template Structure Source: https://github.com/theduckcow/godot-road-generator/blob/main/addons/gut/double_templates/script_template.txt This snippet shows the basic structure of a Gut doubled script, including placeholders for extends, constants, and properties, followed by the initialization of Gut's double tools. ```gdscript # ############################################################################## # Gut Doubled Script # ############################################################################## {extends} {constants} {properties} # ------------------------------------------------------------------------------ # GUT stuff # ------------------------------------------------------------------------------ var __gutdbl_values = { double = self, thepath = '{path}', subpath = '{subpath}', stubber = {stubber_id}, spy = {spy_id}, gut = {gut_id}, from_singleton = '{singleton_name}', is_partial = {is_partial}, doubled_methods = {doubled_methods}, } var __gutdbl = load('res://addons/gut/double_tools.gd').new(__gutdbl_values) # Here so other things can check for a method to know if this is a double. func __gutdbl_check_method__(): pass # ------------------------------------------------------------------------------ # Doubled Methods # ------------------------------------------------------------------------------ ``` -------------------------------- ### Connect RoadPoints Source: https://github.com/theduckcow/godot-road-generator/wiki/Class:-RoadPoint Connect the newly created RoadPoint to an existing one. This ensures the correct flow and direction of the road segments. Use `connect_roadpoint` for a recommended approach. ```gdscript # Most importantly, you need to connect this roadpoint to some existing ones. # Here, we're just getting the reference of some random existing point var target_point: RoadPoint = container.get_children()[0] # Connect them to each other, specifying which "side" of the RoadPoints should be connected. # By connecting one RP's "next" to the following's "prior", you ensure that the flow/direction of RoadPoints is always in the same direction. Technically this shoudln't matter, but some edges can arise when pointing RP's in opposite directions. var this_direction = RoadPoint.PointInit.NEXT var target_direction = RoadPoint.PointInit.PRIOR new_rp.connect_roadpoint(this_direction, target_point, target_direction) ``` -------------------------------- ### Function Declaration with Double Template Source: https://github.com/theduckcow/godot-road-generator/blob/main/addons/gut/double_templates/function_template.txt This snippet shows a typical function declaration using double templates. It includes a warning for varargs and demonstrates how to spy on method calls and handle stubbing logic. ```GDScript func _ready(): var __gutdbl = GUDTBDouble.new() var _method_name = "_ready" var _param_array = [] __gutdbl.spy_on(_method_name, _param_array) if(__gutdbl.is_stubbed_to_call_super(_method_name, _param_array)): return else: return await __gutdbl.handle_other_stubs(_method_name, _param_array) ``` -------------------------------- ### RoadContainer Public Functions Source: https://github.com/theduckcow/godot-road-generator/wiki/Class:-RoadContainer This section details the public functions available for the RoadContainer class that can be useful during runtime. These functions allow for geometry reconstruction, updating road edges, retrieving road points and segments, snapping points, and managing connections. ```APIDOC ## rebuild_segments(clear_existing=false) ### Description Reconstructs all geometry for this RoadContainer. This is typically called automatically by the plugin but can be manually invoked if `RoadManager.auto_refresh` is disabled. ### Parameters #### Path Parameters None #### Query Parameters - **clear_existing** (boolean) - Optional - If true, clears existing geometry before rebuilding. ### Request Example ``` road_container.rebuild_segments(clear_existing=true) ``` ### Response #### Success Response (200) None ## update_edges ### Description Updates export variable lengths and counts to account for connections to other RoadContainers. This function is usually maintained automatically by the plugin but can be called manually to ensure edges are updated when creating connections. ### Parameters None ### Request Example ``` road_container.update_edges() ``` ### Response #### Success Response (200) None ## get_roadpoints(skip_edge_connected=false) ### Description Retrieves the list of all RoadPoints within this container. Optionally skips RoadPoints that are at the container's edge and connected to another container. ### Parameters #### Path Parameters None #### Query Parameters - **skip_edge_connected** (boolean) - Optional - If true, skips edge-connected RoadPoints. ### Request Example ``` road_container.get_roadpoints(skip_edge_connected=true) ``` ### Response #### Success Response (200) - **return_value** (Array) - A list of RoadPoints. ## get_segments() ### Description Retrieves the list of all RoadSegments in this container. This can be used to iterate over segments and identify RoadLanes. ### Parameters None ### Request Example ``` road_container.get_segments() ``` ### Response #### Success Response (200) - **return_value** (Array) - A list of RoadSegments. ## snap_to_road_point(input_rp, target_rp) ### Description Transforms the parent RoadContainer of the first input RoadPoint (`input_rp`) so that `input_rp` becomes perfectly aligned and attached to the target RoadPoint (`target_rp`). ### Parameters #### Path Parameters None #### Query Parameters - **input_rp** (RoadPoint) - The RoadPoint to be snapped. - **target_rp** (RoadPoint) - The target RoadPoint to snap to. ### Request Example ``` road_container.snap_to_road_point(input_rp, target_rp) ``` ### Response #### Success Response (200) None ## get_transform_for_snap_rp(input_rp, target_rp) ### Description A utility function to calculate the transform needed for snapping a RoadPoint to another. It's useful for manual transformations before connecting the RoadPoints. ### Parameters #### Path Parameters None #### Query Parameters - **input_rp** (RoadPoint) - The RoadPoint to be snapped. - **target_rp** (RoadPoint) - The target RoadPoint to snap to. ### Request Example ``` road_container.get_transform_for_snap_rp(input_rp, target_rp) ``` ### Response #### Success Response (200) - **return_value** (Transform) - The calculated transform for snapping. ## get_open_edges() ### Description Retrieves a list of all open edges in the container. An open edge is a direction of a RoadPoint that is not yet connected to another RoadPoint. ### Parameters None ### Request Example ``` road_container.get_open_edges() ``` ### Response #### Success Response (200) - **return_value** (Array) - A list of open edges (RoadPoints). ## get_connected_edges() ### Description Retrieves a list of edges in the container that are connected to another RoadContainer. This can include connections to RoadContainers in different scenes. ### Parameters None ### Request Example ``` road_container.get_connected_edges() ``` ### Response #### Success Response (200) - **return_value** (Array) - A list of connected edges (RoadPoints). ``` -------------------------------- ### Disconnect RoadPoints Source: https://github.com/theduckcow/godot-road-generator/wiki/Class:-RoadPoint Disconnect a RoadPoint from another by specifying the directions involved. This is necessary when removing or reconfiguring road segments. The target's direction must be specified to handle potential circular connections. ```gdscript # To disconnect a RoadPoint, you only need to specify which direction on this node you'd like to disconnect and the target's direction to disconnect. You need to specify the target's direction as technically the same RoadPoint could be both the PRIO and NEXT endpoint, if making a tight circle. new_rp.disconnect_roadpoint(this_direction, target_direction) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.