From 5805ac2260fa9497dcd04f837aef88d262f8ef06 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Fri, 28 Nov 2025 15:55:42 -0600 Subject: [PATCH] prog --- cutscene/CutsceneTest.tscn | 9 --------- entity/npc/NPC.gd | 25 +++++++++++++++---------- entity/npc/NPC.tscn | 19 +++++++++++++------ entity/npc/NPCInteract.gd | 20 ++++++++++++++++++++ entity/npc/NPCInteract.gd.uid | 1 + entity/player/Player.gd | 8 ++++---- map/TestMap.tscn | 13 +++++++++---- singleton/UI.tscn | 1 + ui/pause/PauseMenu.tscn | 1 + 9 files changed, 64 insertions(+), 33 deletions(-) delete mode 100644 cutscene/CutsceneTest.tscn create mode 100644 entity/npc/NPCInteract.gd create mode 100644 entity/npc/NPCInteract.gd.uid diff --git a/cutscene/CutsceneTest.tscn b/cutscene/CutsceneTest.tscn deleted file mode 100644 index e71fe8e..0000000 --- a/cutscene/CutsceneTest.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://bhvoo48bpbkf3"] - -[ext_resource type="PackedScene" uid="uid://d3rtd0ln7l2gr" path="res://scenes/maps/MapTundra.tscn" id="1_fsb0j"] - -[node name="CutsceneTest" type="Node3D"] - -[node name="MapTundra" parent="." instance=ExtResource("1_fsb0j")] - -[node name="Camera3D" type="Camera3D" parent="."] diff --git a/entity/npc/NPC.gd b/entity/npc/NPC.gd index 3f23124..83c878e 100644 --- a/entity/npc/NPC.gd +++ b/entity/npc/NPC.gd @@ -2,28 +2,33 @@ class_name NPC extends CharacterBody3D @export var _movement:NPCMovement +@export var _interact:NPCInteract -@export var walkSpeed:float = 48.0: +# NPC Movement Accessors +@export var walkSpeed:float: set(value): if _movement: _movement.walkSpeed = value get: if _movement: return _movement.walkSpeed - return 48.0 + return 0 -@export var runSpeed:float = 64.0: +@export var runSpeed:float: set(value): if _movement: _movement.runSpeed = value get: if _movement: return _movement.runSpeed - return 64.0 + return 0 -func onInteract(player:Player) -> void: - UI.TEXTBOX.setText("Hello, I'm an NPC!\nThis is the second line here, I am purposefully adding a tonne of words so that it is forced to go across multiple lines and you can see how the word wrapping works, not only using Godot's built in word wrapping but with my advanced visibile characters smart wrapping. Now I am doing a multiline thing\nLine 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\nLine 9\nLine 10"); - pass - -func _enter_tree() -> void: - pass +# NPC Interact Accessors +@export var interactType:NPCInteract.InteractType: + set(value): + if _interact: + _interact.interactType = value + get: + if _interact: + return _interact.interactType + return NPCInteract.InteractType.NONE diff --git a/entity/npc/NPC.tscn b/entity/npc/NPC.tscn index 9d7df01..9f1328e 100644 --- a/entity/npc/NPC.tscn +++ b/entity/npc/NPC.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=8 format=3 uid="uid://kabs7mopalmo"] +[gd_scene load_steps=9 format=3 uid="uid://kabs7mopalmo"] [ext_resource type="Script" uid="uid://crw7ls7t8cwct" path="res://entity/npc/NPC.gd" id="1_00k55"] [ext_resource type="Script" uid="uid://b00rxpveu3v4m" path="res://InteractableArea.gd" id="2_x8luf"] [ext_resource type="Script" uid="uid://tlfthv88ki0y" path="res://entity/npc/NPCMovement.gd" id="3_1seh5"] +[ext_resource type="Script" uid="uid://dunhfgdwp8wjh" path="res://entity/npc/NPCInteract.gd" id="3_binvk"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jphom"] @@ -15,12 +16,12 @@ shading_mode = 0 [sub_resource type="CapsuleMesh" id="CapsuleMesh_jphom"] material = SubResource("StandardMaterial3D_jphom") -[node name="NPC" type="CharacterBody3D" node_paths=PackedStringArray("_movement")] +[node name="NPC" type="CharacterBody3D" node_paths=PackedStringArray("_movement", "_interact")] script = ExtResource("1_00k55") -facingDirection = null -walkSpeed = null -runSpeed = null _movement = NodePath("Scripts/NPCMovement") +_interact = NodePath("Scripts/NPCInteract") +walkSpeed = 8.0 +runSpeed = 12.0 [node name="Scripts" type="Node" parent="."] @@ -28,6 +29,10 @@ _movement = NodePath("Scripts/NPCMovement") script = ExtResource("3_1seh5") body = NodePath("../..") +[node name="NPCInteract" type="Node" parent="Scripts"] +script = ExtResource("3_binvk") +metadata/_custom_type_script = "uid://dunhfgdwp8wjh" + [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("CapsuleShape3D_jphom") @@ -45,4 +50,6 @@ shape = SubResource("BoxShape3D_jphom") mesh = SubResource("CapsuleMesh_jphom") skeleton = NodePath("../..") -[connection signal="interactEvent" from="Rotate/InteractableArea" to="." method="onInteract"] +[connection signal="interactEvent" from="Rotate/InteractableArea" to="Scripts/NPCInteract" method="onInteract"] +[connection signal="interactable" from="Rotate/InteractableArea" to="Scripts/NPCInteract" method="onInteractable"] +[connection signal="notInteractable" from="Rotate/InteractableArea" to="Scripts/NPCInteract" method="onNotInteractable"] diff --git a/entity/npc/NPCInteract.gd b/entity/npc/NPCInteract.gd new file mode 100644 index 0000000..3ff5a26 --- /dev/null +++ b/entity/npc/NPCInteract.gd @@ -0,0 +1,20 @@ +@tool +class_name NPCInteract extends Node + +enum InteractType { + NONE, + TEXT, + CUTSCENE +} + +@export var interactType:InteractType = InteractType.NONE + +func onInteract(player:Player) -> void: + print("NPC Interacted with by Player: %s" % player.name) + pass + +func onInteractable(player:Player) -> void: + pass + +func onNotInteractable(player:Player) -> void: + pass diff --git a/entity/npc/NPCInteract.gd.uid b/entity/npc/NPCInteract.gd.uid new file mode 100644 index 0000000..90cbc6b --- /dev/null +++ b/entity/npc/NPCInteract.gd.uid @@ -0,0 +1 @@ +uid://dunhfgdwp8wjh diff --git a/entity/player/Player.gd b/entity/player/Player.gd index 074c62f..fa84a88 100644 --- a/entity/player/Player.gd +++ b/entity/player/Player.gd @@ -3,20 +3,20 @@ class_name Player extends CharacterBody3D @export var _movement:PlayerMovement -@export var walkSpeed:float = EntityMovement.WALK_SPEED_DEFAULT: +@export var walkSpeed:float: set(value): if _movement: _movement.walkSpeed = value get: if _movement: return _movement.walkSpeed - return EntityMovement.WALK_SPEED_DEFAULT + return 0.0 -@export var runSpeed:float = EntityMovement.RUN_SPEED_DEFAULT: +@export var runSpeed:float: set(value): if _movement: _movement.runSpeed = value get: if _movement: return _movement.runSpeed - return EntityMovement.RUN_SPEED_DEFAULT + return 0.0 diff --git a/map/TestMap.tscn b/map/TestMap.tscn index 620b13b..206c0cb 100644 --- a/map/TestMap.tscn +++ b/map/TestMap.tscn @@ -11,9 +11,14 @@ script = ExtResource("1_6ms5s") [node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")] [node name="Player" parent="." instance=ExtResource("2_0d2qr")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5777, 1.74123, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5777, 1.09878, 0) +walkSpeed = 8.0 +runSpeed = 12.0 [node name="NPC" parent="." instance=ExtResource("3_0vfw4")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.3026, 1.9909, -2.12904) -walkSpeed = 48.0 -runSpeed = 64.0 +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.3026, 1.11551, -2.12904) +interactType = 1 + +[node name="Meta" type="Node" parent="."] + +[node name="Cutscenes" type="Node" parent="Meta"] diff --git a/singleton/UI.tscn b/singleton/UI.tscn index f734ce3..c4669ab 100644 --- a/singleton/UI.tscn +++ b/singleton/UI.tscn @@ -19,4 +19,5 @@ PAUSE = NodePath("PauseMenu") layout_mode = 1 [node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")] +visible = false layout_mode = 1 diff --git a/ui/pause/PauseMenu.tscn b/ui/pause/PauseMenu.tscn index 694f412..4e8131d 100644 --- a/ui/pause/PauseMenu.tscn +++ b/ui/pause/PauseMenu.tscn @@ -16,6 +16,7 @@ MAIN = NodePath("PauseMain") SETTINGS = NodePath("PauseSettings") [node name="PauseSettings" parent="." instance=ExtResource("2_3djnw")] +visible = false layout_mode = 1 [node name="PauseMain" parent="." instance=ExtResource("1_33nyv")]