gd: added input addon
This commit is contained in:
58
guide_examples/input_contexts/boat.gd
Normal file
58
guide_examples/input_contexts/boat.gd
Normal file
@ -0,0 +1,58 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
signal exited()
|
||||
@export var speed:float = 300
|
||||
@export var turn_speed_degrees:float = 180
|
||||
|
||||
@export var context:GUIDEMappingContext
|
||||
@export var accelerate:GUIDEAction
|
||||
@export var turn:GUIDEAction
|
||||
@export var leave:GUIDEAction
|
||||
|
||||
|
||||
@onready var _player_spot:Node2D = %PlayerSpot
|
||||
@onready var _exit_spot:Node2D = %ExitSpot
|
||||
|
||||
var _player:Node2D
|
||||
|
||||
func _ready():
|
||||
leave.triggered.connect(_on_leave)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# rotate by our turn axis
|
||||
rotate(turn.value_axis_1d * deg_to_rad(turn_speed_degrees) * delta)
|
||||
# accelerate by our acceleration axis
|
||||
velocity = transform.x * accelerate.value_axis_1d * speed
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func enter(player:Node2D):
|
||||
# Move the player to the player spot
|
||||
_player = player
|
||||
player.reparent(_player_spot, false)
|
||||
_player.position = Vector2.ZERO
|
||||
|
||||
# And enable the boat controls
|
||||
GUIDE.enable_mapping_context(context)
|
||||
|
||||
|
||||
func _on_leave():
|
||||
# Disable boat controls
|
||||
GUIDE.disable_mapping_context(context)
|
||||
|
||||
# put player back in the world
|
||||
_player.reparent(get_parent(), false)
|
||||
_player.global_position = _exit_spot.global_position
|
||||
|
||||
# this is to prevent the physics engine from going crazy when moving
|
||||
# the player's body
|
||||
await get_tree().physics_frame
|
||||
|
||||
# notify any interested parties that the player has exited
|
||||
exited.emit()
|
||||
|
||||
|
||||
|
||||
|
||||
|
1
guide_examples/input_contexts/boat.gd.uid
Normal file
1
guide_examples/input_contexts/boat.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bkggahcvec2hd
|
10
guide_examples/input_contexts/boat.svg
Normal file
10
guide_examples/input_contexts/boat.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 256 192" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
||||
<g transform="matrix(1,0,0,1,-5.17241,-1.19363)">
|
||||
<path d="M23.263,34.448L23.263,159.78C23.263,159.78 147.401,167.339 177.64,157.392C207.879,147.446 251.248,92.936 251.248,92.936C251.248,92.936 206.998,44.178 178.834,36.835C141.698,27.154 23.263,34.448 23.263,34.448Z" style="fill:url(#_Linear1);stroke:rgb(51,34,18);stroke-width:8.44px;"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-6.36605,-99.8326,99.8326,-6.36605,49.1255,135.474)"><stop offset="0" style="stop-color:rgb(102,54,1);stop-opacity:1"/><stop offset="0.56" style="stop-color:rgb(87,48,5);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(30,25,19);stop-opacity:1"/></linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
37
guide_examples/input_contexts/boat.svg.import
Normal file
37
guide_examples/input_contexts/boat.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cyqlk5nkvswx7"
|
||||
path="res://.godot/imported/boat.svg-547042152e7d4e4afdfc306682d6e571.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://guide_examples/input_contexts/boat.svg"
|
||||
dest_files=["res://.godot/imported/boat.svg-547042152e7d4e4afdfc306682d6e571.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
6
guide_examples/input_contexts/input_contexts.gd
Normal file
6
guide_examples/input_contexts/input_contexts.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
@export var starting_context:GUIDEMappingContext
|
||||
|
||||
func _ready():
|
||||
GUIDE.enable_mapping_context(starting_context)
|
1
guide_examples/input_contexts/input_contexts.gd.uid
Normal file
1
guide_examples/input_contexts/input_contexts.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cnf3xx5jxiu8q
|
194
guide_examples/input_contexts/input_contexts.tscn
Normal file
194
guide_examples/input_contexts/input_contexts.tscn
Normal file
@ -0,0 +1,194 @@
|
||||
[gd_scene load_steps=25 format=3 uid="uid://b6h4wnjfjs70m"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/input_contexts/boat.gd" id="1_61cdj"]
|
||||
[ext_resource type="Script" path="res://guide_examples/input_contexts/input_contexts.gd" id="1_386pq"]
|
||||
[ext_resource type="Texture2D" uid="uid://byjxtsekdl8t2" path="res://guide_examples/shared/godot_logo.svg" id="1_x61i0"]
|
||||
[ext_resource type="Texture2D" uid="uid://cyqlk5nkvswx7" path="res://guide_examples/input_contexts/boat.svg" id="1_yfaid"]
|
||||
[ext_resource type="Resource" uid="uid://bv3t73wg3atf7" path="res://guide_examples/input_contexts/mapping_contexts/boat_context.tres" id="2_ha2ml"]
|
||||
[ext_resource type="Resource" uid="uid://5jercxe6t3go" path="res://guide_examples/input_contexts/mapping_contexts/boat_actions/accelerate.tres" id="3_8s4br"]
|
||||
[ext_resource type="Script" path="res://guide_examples/input_contexts/player.gd" id="3_kn2qk"]
|
||||
[ext_resource type="Resource" uid="uid://cplpvxhus6bwb" path="res://guide_examples/input_contexts/mapping_contexts/player_context.tres" id="4_3xwjv"]
|
||||
[ext_resource type="Resource" uid="uid://qsysw0ljlj0l" path="res://guide_examples/input_contexts/mapping_contexts/boat_actions/turn.tres" id="4_w1gps"]
|
||||
[ext_resource type="Resource" uid="uid://cnaj42xnfcibo" path="res://guide_examples/input_contexts/mapping_contexts/player_actions/move.tres" id="5_70jqj"]
|
||||
[ext_resource type="Resource" uid="uid://bk2j1ww7iwqd0" path="res://guide_examples/input_contexts/mapping_contexts/boat_actions/leave.tres" id="5_typxl"]
|
||||
[ext_resource type="Resource" uid="uid://crjkk2edn8g8k" path="res://guide_examples/input_contexts/mapping_contexts/player_actions/use.tres" id="6_aiqns"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="12_jcoq7"]
|
||||
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="12_u0g3a"]
|
||||
[ext_resource type="Script" path="res://guide_examples/shared/instructions_label.gd" id="14_ui0u7"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_w57h4"]
|
||||
size = Vector2(1972, 59)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_r5hqg"]
|
||||
size = Vector2(59, 1161)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ifvju"]
|
||||
size = Vector2(2030.5, 60.5)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qarqo"]
|
||||
size = Vector2(102, 1160.5)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_la1oy"]
|
||||
size = Vector2(446.5, 1141)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3q8sb"]
|
||||
size = Vector2(368, 148)
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_54ta5"]
|
||||
radius = 75.0
|
||||
height = 252.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3lf7l"]
|
||||
size = Vector2(126, 130)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_dt2nf"]
|
||||
radius = 141.891
|
||||
|
||||
[node name="InputContexts" type="Node2D"]
|
||||
script = ExtResource("1_386pq")
|
||||
starting_context = ExtResource("4_3xwjv")
|
||||
|
||||
[node name="World" type="Node2D" parent="."]
|
||||
|
||||
[node name="Sea" type="ColorRect" parent="World"]
|
||||
offset_right = 2009.0
|
||||
offset_bottom = 1129.0
|
||||
color = Color(0.0440738, 0.000205037, 0.549847, 1)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Land" type="Polygon2D" parent="World"]
|
||||
color = Color(0.336331, 0.394587, 0.063959, 1)
|
||||
polygon = PackedVector2Array(55, -51, 259, -24, 398, 124, 356, 225, 279, 461, 394, 656, 412, 865, 342, 1085, -15, 1119, -22, -67)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Jetty" type="ColorRect" parent="World/Land"]
|
||||
offset_left = 283.0
|
||||
offset_top = 144.0
|
||||
offset_right = 641.0
|
||||
offset_bottom = 280.0
|
||||
color = Color(0.243329, 0.15798, 7.21961e-08, 1)
|
||||
|
||||
[node name="World Boundaries" type="StaticBody2D" parent="World"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="World/World Boundaries"]
|
||||
position = Vector2(976, -19.5)
|
||||
shape = SubResource("RectangleShape2D_w57h4")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="World/World Boundaries"]
|
||||
position = Vector2(-10, 532)
|
||||
shape = SubResource("RectangleShape2D_r5hqg")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="World/World Boundaries"]
|
||||
position = Vector2(975.75, 1082.25)
|
||||
shape = SubResource("RectangleShape2D_ifvju")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="World/World Boundaries"]
|
||||
position = Vector2(1940, 532.25)
|
||||
shape = SubResource("RectangleShape2D_qarqo")
|
||||
|
||||
[node name="NoBoatZone" type="StaticBody2D" parent="World"]
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="World/NoBoatZone"]
|
||||
position = Vector2(210.75, 556.5)
|
||||
shape = SubResource("RectangleShape2D_la1oy")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="World/NoBoatZone"]
|
||||
position = Vector2(454, 211)
|
||||
shape = SubResource("RectangleShape2D_3q8sb")
|
||||
|
||||
[node name="Boat" type="CharacterBody2D" parent="."]
|
||||
position = Vector2(744, 269)
|
||||
rotation = -1.44336
|
||||
collision_layer = 5
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_61cdj")
|
||||
speed = 500.0
|
||||
context = ExtResource("2_ha2ml")
|
||||
accelerate = ExtResource("3_8s4br")
|
||||
turn = ExtResource("4_w1gps")
|
||||
leave = ExtResource("5_typxl")
|
||||
|
||||
[node name="Boat" type="Sprite2D" parent="Boat"]
|
||||
texture = ExtResource("1_yfaid")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Boat"]
|
||||
position = Vector2(-13, 0)
|
||||
rotation = -1.57573
|
||||
shape = SubResource("CapsuleShape2D_54ta5")
|
||||
|
||||
[node name="PlayerSpot" type="Node2D" parent="Boat"]
|
||||
unique_name_in_owner = true
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.8, 0.8)
|
||||
|
||||
[node name="ExitSpot" type="Marker2D" parent="Boat"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(-11.0732, -212.314)
|
||||
|
||||
[node name="Player" type="CharacterBody2D" parent="."]
|
||||
position = Vector2(205, 212)
|
||||
script = ExtResource("3_kn2qk")
|
||||
context = ExtResource("4_3xwjv")
|
||||
move = ExtResource("5_70jqj")
|
||||
use = ExtResource("6_aiqns")
|
||||
|
||||
[node name="Icon" type="Sprite2D" parent="Player"]
|
||||
texture = ExtResource("1_x61i0")
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape2D" parent="Player"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(-1, 1)
|
||||
shape = SubResource("RectangleShape2D_3lf7l")
|
||||
|
||||
[node name="DetectionArea" type="Area2D" parent="Player"]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/DetectionArea"]
|
||||
shape = SubResource("CircleShape2D_dt2nf")
|
||||
|
||||
[node name="UILayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Label" type="Label" parent="UILayer"]
|
||||
offset_left = 894.0
|
||||
offset_top = 24.0
|
||||
offset_right = 1872.0
|
||||
offset_bottom = 132.0
|
||||
theme = ExtResource("12_u0g3a")
|
||||
text = "This demonstrates the use of multiple mapping contexts. We have one for the player
|
||||
and one for the boat. When the player enters the boat, the boat mappings will
|
||||
become active and will become inactive once the player leaves. "
|
||||
|
||||
[node name="BoatInstructions" type="RichTextLabel" parent="UILayer"]
|
||||
offset_left = 1316.0
|
||||
offset_top = 772.0
|
||||
offset_right = 1356.0
|
||||
offset_bottom = 812.0
|
||||
theme = ExtResource("12_u0g3a")
|
||||
script = ExtResource("14_ui0u7")
|
||||
instructions_text = "%s to accelerate/break.
|
||||
%s to turn the boat.
|
||||
%s to leave the boat."
|
||||
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("3_8s4br"), ExtResource("4_w1gps"), ExtResource("5_typxl")])
|
||||
limit_to_context = ExtResource("2_ha2ml")
|
||||
|
||||
[node name="PlayerInstructions" type="RichTextLabel" parent="UILayer"]
|
||||
offset_left = 1316.0
|
||||
offset_top = 772.0
|
||||
offset_right = 1356.0
|
||||
offset_bottom = 812.0
|
||||
theme = ExtResource("12_u0g3a")
|
||||
script = ExtResource("14_ui0u7")
|
||||
instructions_text = "%s to move.
|
||||
%s to enter the boat.
|
||||
"
|
||||
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("5_70jqj"), ExtResource("6_aiqns")])
|
||||
limit_to_context = ExtResource("4_3xwjv")
|
||||
|
||||
[node name="DebugLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="GuideDebugger" parent="DebugLayer" instance=ExtResource("12_jcoq7")]
|
||||
theme = ExtResource("12_u0g3a")
|
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://5jercxe6t3go"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_tkn2p"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_tkn2p")
|
||||
name = &""
|
||||
action_value_type = 1
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://bk2j1ww7iwqd0"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_3d3m7"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_3d3m7")
|
||||
name = &""
|
||||
action_value_type = 0
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://qsysw0ljlj0l"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_4gxp2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_4gxp2")
|
||||
name = &""
|
||||
action_value_type = 1
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
142
guide_examples/input_contexts/mapping_contexts/boat_context.tres
Normal file
142
guide_examples/input_contexts/mapping_contexts/boat_context.tres
Normal file
@ -0,0 +1,142 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=26 format=3 uid="uid://bv3t73wg3atf7"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://qsysw0ljlj0l" path="res://guide_examples/input_contexts/mapping_contexts/boat_actions/turn.tres" id="1_ovglr"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_key.gd" id="2_0hduu"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="3_jicb2"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="4_ymfat"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="5_3quxn"]
|
||||
[ext_resource type="Resource" uid="uid://5jercxe6t3go" path="res://guide_examples/input_contexts/mapping_contexts/boat_actions/accelerate.tres" id="6_pocgd"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="7_1yt57"]
|
||||
[ext_resource type="Resource" uid="uid://bk2j1ww7iwqd0" path="res://guide_examples/input_contexts/mapping_contexts/boat_actions/leave.tres" id="7_t38lc"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_released.gd" id="8_f0mvl"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_2l73a"]
|
||||
script = ExtResource("2_0hduu")
|
||||
key = 87
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_p26ag"]
|
||||
script = ExtResource("4_ymfat")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_2l73a")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_fndx2"]
|
||||
script = ExtResource("2_0hduu")
|
||||
key = 83
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8c6p8"]
|
||||
script = ExtResource("3_jicb2")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7ubh7"]
|
||||
script = ExtResource("4_ymfat")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_fndx2")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_8c6p8")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_yd1l1"]
|
||||
script = ExtResource("5_3quxn")
|
||||
action = ExtResource("6_pocgd")
|
||||
input_mappings = Array[ExtResource("4_ymfat")]([SubResource("Resource_p26ag"), SubResource("Resource_7ubh7")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_bw7vh"]
|
||||
script = ExtResource("2_0hduu")
|
||||
key = 65
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_55txo"]
|
||||
script = ExtResource("3_jicb2")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_4pm2b"]
|
||||
script = ExtResource("4_ymfat")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_bw7vh")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_55txo")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_mathf"]
|
||||
script = ExtResource("2_0hduu")
|
||||
key = 68
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_j5i1b"]
|
||||
script = ExtResource("4_ymfat")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_mathf")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_siw8f"]
|
||||
script = ExtResource("5_3quxn")
|
||||
action = ExtResource("1_ovglr")
|
||||
input_mappings = Array[ExtResource("4_ymfat")]([SubResource("Resource_4pm2b"), SubResource("Resource_j5i1b")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_xiqqo"]
|
||||
script = ExtResource("2_0hduu")
|
||||
key = 69
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ooy6b"]
|
||||
script = ExtResource("8_f0mvl")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8047g"]
|
||||
script = ExtResource("4_ymfat")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_xiqqo")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_ooy6b")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_npqbc"]
|
||||
script = ExtResource("5_3quxn")
|
||||
action = ExtResource("7_t38lc")
|
||||
input_mappings = Array[ExtResource("4_ymfat")]([SubResource("Resource_8047g")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("7_1yt57")
|
||||
display_name = ""
|
||||
mappings = Array[ExtResource("5_3quxn")]([SubResource("Resource_yd1l1"), SubResource("Resource_siw8f"), SubResource("Resource_npqbc")])
|
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://cnaj42xnfcibo"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_amhrr"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_amhrr")
|
||||
name = &""
|
||||
action_value_type = 2
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://crjkk2edn8g8k"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_7lwep"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_7lwep")
|
||||
name = &""
|
||||
action_value_type = 0
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,145 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=27 format=3 uid="uid://cplpvxhus6bwb"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="1_126cd"]
|
||||
[ext_resource type="Resource" uid="uid://cnaj42xnfcibo" path="res://guide_examples/input_contexts/mapping_contexts/player_actions/move.tres" id="1_hm3wk"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_key.gd" id="2_xomf3"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_input_swizzle.gd" id="3_0ask7"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="4_07e03"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="5_1myws"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="6_h3mfx"]
|
||||
[ext_resource type="Resource" uid="uid://crjkk2edn8g8k" path="res://guide_examples/input_contexts/mapping_contexts/player_actions/use.tres" id="7_dx1om"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_released.gd" id="8_hlvtj"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5yf1p"]
|
||||
script = ExtResource("2_xomf3")
|
||||
key = 87
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vo6fb"]
|
||||
script = ExtResource("3_0ask7")
|
||||
order = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ixhgx"]
|
||||
script = ExtResource("4_07e03")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pia7e"]
|
||||
script = ExtResource("5_1myws")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_5yf1p")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_vo6fb"), SubResource("Resource_ixhgx")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_a11mt"]
|
||||
script = ExtResource("2_xomf3")
|
||||
key = 83
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6ecpg"]
|
||||
script = ExtResource("3_0ask7")
|
||||
order = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_s1oiy"]
|
||||
script = ExtResource("5_1myws")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_a11mt")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_6ecpg")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_m84eo"]
|
||||
script = ExtResource("2_xomf3")
|
||||
key = 65
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qn63o"]
|
||||
script = ExtResource("4_07e03")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_4dh7v"]
|
||||
script = ExtResource("5_1myws")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_m84eo")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_qn63o")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_njvt5"]
|
||||
script = ExtResource("2_xomf3")
|
||||
key = 68
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_hvhr4"]
|
||||
script = ExtResource("5_1myws")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_njvt5")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_o0rtq"]
|
||||
script = ExtResource("6_h3mfx")
|
||||
action = ExtResource("1_hm3wk")
|
||||
input_mappings = Array[ExtResource("5_1myws")]([SubResource("Resource_pia7e"), SubResource("Resource_s1oiy"), SubResource("Resource_4dh7v"), SubResource("Resource_hvhr4")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_t3oa4"]
|
||||
script = ExtResource("2_xomf3")
|
||||
key = 69
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ocal3"]
|
||||
script = ExtResource("8_hlvtj")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_o528y"]
|
||||
script = ExtResource("5_1myws")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_t3oa4")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_ocal3")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0a33p"]
|
||||
script = ExtResource("6_h3mfx")
|
||||
action = ExtResource("7_dx1om")
|
||||
input_mappings = Array[ExtResource("5_1myws")]([SubResource("Resource_o528y")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_126cd")
|
||||
display_name = ""
|
||||
mappings = Array[ExtResource("6_h3mfx")]([SubResource("Resource_o0rtq"), SubResource("Resource_0a33p")])
|
42
guide_examples/input_contexts/player.gd
Normal file
42
guide_examples/input_contexts/player.gd
Normal file
@ -0,0 +1,42 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var context:GUIDEMappingContext
|
||||
@export var move:GUIDEAction
|
||||
@export var use:GUIDEAction
|
||||
|
||||
@export var speed:float = 300
|
||||
|
||||
@onready var _detection_area:Area2D = %DetectionArea
|
||||
@onready var _collision_shape:CollisionShape2D = %CollisionShape
|
||||
|
||||
func _ready():
|
||||
use.triggered.connect(_enter_boat)
|
||||
|
||||
func _physics_process(_delta):
|
||||
velocity = move.value_axis_2d.normalized() * speed
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _enter_boat():
|
||||
var boats := _detection_area.get_overlapping_bodies()
|
||||
if boats.is_empty():
|
||||
return
|
||||
|
||||
# Disable player input while in the boat
|
||||
GUIDE.disable_mapping_context(context)
|
||||
|
||||
# disable our own collisions while in the boat
|
||||
_collision_shape.set_deferred("disabled", true)
|
||||
|
||||
# enter the boat
|
||||
boats[0].enter(self)
|
||||
boats[0].exited.connect(_boat_exited, CONNECT_ONE_SHOT)
|
||||
|
||||
|
||||
func _boat_exited():
|
||||
# re-enable our own mapping context
|
||||
GUIDE.enable_mapping_context(context)
|
||||
|
||||
# and re-enable our collisions
|
||||
_collision_shape.set_deferred("disabled", false)
|
||||
|
1
guide_examples/input_contexts/player.gd.uid
Normal file
1
guide_examples/input_contexts/player.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bc00xf6yb6mw0
|
Reference in New Issue
Block a user