From 58126341babcecddbc1c15fe205287481d257820 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Tue, 1 Jul 2025 15:50:08 -0500 Subject: [PATCH] Moved player input --- scenes/entities/Player.tscn | 8 ++- scenes/singletons/UI.tscn | 11 ++++- scenes/ui/pause/PauseMain.tscn | 52 ++++++++++++++++++++ scenes/ui/pause/PauseMenu.tscn | 17 +++++++ scripts/entities/player/PlayerInput.gd | 13 +++++ scripts/entities/player/PlayerInput.gd.uid | 1 + scripts/entities/player/PlayerInteraction.gd | 5 +- scripts/entities/player/PlayerMovement.gd | 5 +- scripts/singletons/Pause.gd | 12 ++++- scripts/singletons/UI.gd | 3 +- scripts/ui/pause/PauseMain.gd | 4 ++ scripts/ui/pause/PauseMain.gd.uid | 1 + scripts/ui/pause/PauseMenu.gd | 17 +++++++ scripts/ui/pause/PauseMenu.gd.uid | 1 + 14 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 scenes/ui/pause/PauseMain.tscn create mode 100644 scenes/ui/pause/PauseMenu.tscn create mode 100644 scripts/entities/player/PlayerInput.gd create mode 100644 scripts/entities/player/PlayerInput.gd.uid create mode 100644 scripts/ui/pause/PauseMain.gd create mode 100644 scripts/ui/pause/PauseMain.gd.uid create mode 100644 scripts/ui/pause/PauseMenu.gd create mode 100644 scripts/ui/pause/PauseMenu.gd.uid diff --git a/scenes/entities/Player.tscn b/scenes/entities/Player.tscn index a8c8ecb..df3aec4 100644 --- a/scenes/entities/Player.tscn +++ b/scenes/entities/Player.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=9 format=3 uid="uid://2ch34sio36nv"] +[gd_scene load_steps=10 format=3 uid="uid://2ch34sio36nv"] [ext_resource type="Script" uid="uid://ylmy3nvpirgr" path="res://scripts/entities/player/Player.gd" id="1_24gqh"] [ext_resource type="Script" uid="uid://bwxdv3kxrs4oj" path="res://scripts/entities/player/PlayerMovement.gd" id="2_o7et6"] [ext_resource type="Script" uid="uid://b3nty7pvbo58d" path="res://scripts/entities/player/PlayerInteraction.gd" id="3_24gqh"] +[ext_resource type="Script" uid="uid://bdv1fj1pwknrs" path="res://scripts/entities/player/PlayerInput.gd" id="4_yjynp"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2m2ha"] @@ -30,6 +31,11 @@ script = ExtResource("3_24gqh") interactableArea = NodePath("../../InteractableArea") player = NodePath("../..") +[node name="PlayerInput" type="Node" parent="Scripts" node_paths=PackedStringArray("interaction", "movement")] +script = ExtResource("4_yjynp") +interaction = NodePath("../PlayerInteraction") +movement = NodePath("../PlayerMovement") + [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("CapsuleShape3D_2m2ha") diff --git a/scenes/singletons/UI.tscn b/scenes/singletons/UI.tscn index 4de3d4b..eba3abb 100644 --- a/scenes/singletons/UI.tscn +++ b/scenes/singletons/UI.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=3 format=3 uid="uid://baos0arpiskbp"] +[gd_scene load_steps=4 format=3 uid="uid://baos0arpiskbp"] [ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/ui/VNTextbox.tscn" id="1_1mtk3"] [ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://scripts/singletons/UI.gd" id="1_son71"] +[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://scenes/ui/pause/PauseMenu.tscn" id="2_atyu8"] -[node name="UI" type="Control" node_paths=PackedStringArray("TEXTBOX")] +[node name="UI" type="Control" node_paths=PackedStringArray("TEXTBOX", "PAUSE")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -12,6 +13,12 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_son71") TEXTBOX = NodePath("VNTextbox") +PAUSE = NodePath("PauseMenu") + +[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")] +visible = false +layout_mode = 1 [node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")] +visible = false layout_mode = 1 diff --git a/scenes/ui/pause/PauseMain.tscn b/scenes/ui/pause/PauseMain.tscn new file mode 100644 index 0000000..1c1f71c --- /dev/null +++ b/scenes/ui/pause/PauseMain.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=2 format=3 uid="uid://bt0okj2rie8qf"] + +[ext_resource type="Script" uid="uid://c7kvg0jw6w340" path="res://scripts/ui/pause/PauseMain.gd" id="1_b5xfl"] + +[node name="PauseMain" type="VBoxContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_b5xfl") +metadata/_custom_type_script = "uid://c7kvg0jw6w340" + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ItemList" type="ItemList" parent="HBoxContainer"] +layout_mode = 2 +auto_width = true +item_count = 6 +item_0/text = "Equpiment" +item_1/text = "Abilities" +item_2/text = "Items" +item_3/text = "Quests" +item_4/text = "Options" +item_5/text = "Save" + +[node name="HBoxContainer2" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer2"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="HBoxContainer" type="GridContainer" parent="HBoxContainer2/PanelContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_constants/h_separation = 8 +columns = 2 + +[node name="Money" type="Label" parent="HBoxContainer2/PanelContainer/HBoxContainer"] +layout_mode = 2 +text = "%MONEY%" + +[node name="Playtime" type="Label" parent="HBoxContainer2/PanelContainer/HBoxContainer"] +layout_mode = 2 +text = "%PLAYTIME%" diff --git a/scenes/ui/pause/PauseMenu.tscn b/scenes/ui/pause/PauseMenu.tscn new file mode 100644 index 0000000..ac3e9cd --- /dev/null +++ b/scenes/ui/pause/PauseMenu.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://c0i5e2dj11d8c"] + +[ext_resource type="PackedScene" uid="uid://bt0okj2rie8qf" path="res://scenes/ui/pause/PauseMain.tscn" id="1_33nyv"] +[ext_resource type="Script" uid="uid://cgvf34t5qgwbm" path="res://scripts/ui/pause/PauseMenu.gd" id="1_82qxy"] + +[node name="PauseMenu" type="Control" node_paths=PackedStringArray("MAIN")] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_82qxy") +MAIN = NodePath("PauseMain") + +[node name="PauseMain" parent="." instance=ExtResource("1_33nyv")] +layout_mode = 1 diff --git a/scripts/entities/player/PlayerInput.gd b/scripts/entities/player/PlayerInput.gd new file mode 100644 index 0000000..594d76a --- /dev/null +++ b/scripts/entities/player/PlayerInput.gd @@ -0,0 +1,13 @@ +class_name PlayerInput extends Node + +@export var interaction:PlayerInteraction +@export var movement:PlayerMovement + +func _process(delta: float) -> void: + if Input.is_action_just_pressed("pause"): + PAUSE.menuPause() + + if Input.is_action_just_pressed("interact"): + interaction.interact() + + movement.inputDir = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized() diff --git a/scripts/entities/player/PlayerInput.gd.uid b/scripts/entities/player/PlayerInput.gd.uid new file mode 100644 index 0000000..2306588 --- /dev/null +++ b/scripts/entities/player/PlayerInput.gd.uid @@ -0,0 +1 @@ +uid://bdv1fj1pwknrs diff --git a/scripts/entities/player/PlayerInteraction.gd b/scripts/entities/player/PlayerInteraction.gd index 4572626..1b404a7 100644 --- a/scripts/entities/player/PlayerInteraction.gd +++ b/scripts/entities/player/PlayerInteraction.gd @@ -8,13 +8,10 @@ func canInteract() -> bool: return false return true -func _process(delta: float) -> void: +func interact() -> void: if !canInteract(): return - if !Input.is_action_just_pressed("interact"): - return - var overlapping = interactableArea.get_overlapping_areas() var interactable: InteractableArea = null diff --git a/scripts/entities/player/PlayerMovement.gd b/scripts/entities/player/PlayerMovement.gd index 3346367..85a0df7 100644 --- a/scripts/entities/player/PlayerMovement.gd +++ b/scripts/entities/player/PlayerMovement.gd @@ -1,9 +1,10 @@ class_name PlayerMovement extends Node -const TURN_SPEED = 12.0 +const TURN_SPEED = 30.0 const SPEED = 8.0 @export var player:CharacterBody3D +var inputDir:Vector2 = Vector2.ZERO func canMove() -> bool: if PAUSE.isMovementPaused(): @@ -18,8 +19,6 @@ func _physics_process(delta:float) -> void: # Player movement var directionAdjusted = Vector3.ZERO if canMove(): - var inputDir = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized() - # Use camera orientation for movement direction var cam_basis = cameraCurrent.global_transform.basis # Forward and right vectors, ignore vertical component diff --git a/scripts/singletons/Pause.gd b/scripts/singletons/Pause.gd index 47f2c82..18ff1a5 100644 --- a/scripts/singletons/Pause.gd +++ b/scripts/singletons/Pause.gd @@ -8,9 +8,19 @@ func cutscenePause() -> void: func cutsceneResume() -> void: cutscenePaused = false + func isMovementPaused() -> bool: if cutscenePaused: return true + if !UI.TEXTBOX.isClosed: return true - return false \ No newline at end of file + + if UI.PAUSE.isOpen(): + return true + + return false + + +func menuPause() -> void: + UI.PAUSE.open() \ No newline at end of file diff --git a/scripts/singletons/UI.gd b/scripts/singletons/UI.gd index d5e56ed..659ea99 100644 --- a/scripts/singletons/UI.gd +++ b/scripts/singletons/UI.gd @@ -1,3 +1,4 @@ class_name UISingleton extends Control -@export var TEXTBOX: VNTextbox \ No newline at end of file +@export var TEXTBOX: VNTextbox +@export var PAUSE: PauseMenu \ No newline at end of file diff --git a/scripts/ui/pause/PauseMain.gd b/scripts/ui/pause/PauseMain.gd new file mode 100644 index 0000000..1b0bbcf --- /dev/null +++ b/scripts/ui/pause/PauseMain.gd @@ -0,0 +1,4 @@ +class_name PauseMain extends VBoxContainer + +func _ready() -> void: + visible = true \ No newline at end of file diff --git a/scripts/ui/pause/PauseMain.gd.uid b/scripts/ui/pause/PauseMain.gd.uid new file mode 100644 index 0000000..66d5c31 --- /dev/null +++ b/scripts/ui/pause/PauseMain.gd.uid @@ -0,0 +1 @@ +uid://c7kvg0jw6w340 diff --git a/scripts/ui/pause/PauseMenu.gd b/scripts/ui/pause/PauseMenu.gd new file mode 100644 index 0000000..418415d --- /dev/null +++ b/scripts/ui/pause/PauseMenu.gd @@ -0,0 +1,17 @@ +class_name PauseMenu extends Control + +@export var MAIN:PauseMain + +func _ready() -> void: + hide() + +func isOpen() -> bool: + return visible + +func open() -> void: + visible = true + MAIN.visible = true + +func close() -> void: + visible = false + MAIN.visible = false \ No newline at end of file diff --git a/scripts/ui/pause/PauseMenu.gd.uid b/scripts/ui/pause/PauseMenu.gd.uid new file mode 100644 index 0000000..a0b5318 --- /dev/null +++ b/scripts/ui/pause/PauseMenu.gd.uid @@ -0,0 +1 @@ +uid://cgvf34t5qgwbm