Rework player state system to use an event subscription system to avoid directly calling methods on individual state and having to worry about validity
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://6athlweutl2g"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dacvayqstkvws" path="res://Entities/Characters/Player/Scripts/player_body.gd" id="1_qqvsf"]
|
||||
|
||||
[node name="Player Body" type="CharacterBody2D" unique_id=1502234578 groups=["Player Group"]]
|
||||
y_sort_enabled = true
|
||||
script = ExtResource("1_qqvsf")
|
||||
491
Entities/Characters/Player/Individual Components/sprite.tscn
Normal file
491
Entities/Characters/Player/Individual Components/sprite.tscn
Normal file
@@ -0,0 +1,491 @@
|
||||
[gd_scene format=3 uid="uid://uyl0s1e67x6s"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cuar23q48cbja" path="res://Entities/Characters/Player/Scripts/sprite.gd" id="1_jqxwg"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1mourl3rq437" path="res://Assets/Spritesheets/Player/player-full-01.png" id="2_ndjja"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kg8vi"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 1472, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_eqnrc"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 1472, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rr1pu"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 1472, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_85fw5"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 1536, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5dpey"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 1536, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vk7kj"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 1536, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3ej6w"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 1600, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j7iyf"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 1600, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gw75a"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 1600, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w2nd7"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 1472, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rd4wh"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 1472, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rwmr7"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 1472, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_na211"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 1536, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kl0pt"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 1536, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sdskq"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 1536, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1dk7p"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 1600, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5pvpc"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 1600, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3uof2"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 1600, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0s5vo"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_iy4ef"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1l5y2"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tbera"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6giml"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_huf5g"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bsgi0"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_72dk0"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gwc2p"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g4n6s"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tvm7c"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_amsyc"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ei8qf"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3fwgt"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_83xkn"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_df3jv"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bwglw"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j74gm"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e1olu"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 1280, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jmdrl"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 1280, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wk3mk"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 1280, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8mpdo"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 1280, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_46inv"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 1280, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s6rq5"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pu3ni"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qdlmc"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wfvue"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pdvtf"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_k84dj"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_thygw"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 256, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_soxdi"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 256, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bexkr"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 256, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7vbqj"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 256, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xlw27"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 256, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1unn3"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 256, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n4kyy"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(0, 320, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6pm4n"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(64, 320, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2mqt6"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(128, 320, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4bosx"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(192, 320, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xx24f"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(256, 320, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fftbb"]
|
||||
atlas = ExtResource("2_ndjja")
|
||||
region = Rect2(320, 320, 64, 64)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_jqxwg"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kg8vi")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_eqnrc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rr1pu")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"drawing-bow-down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_85fw5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5dpey")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vk7kj")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"drawing-bow-side",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3ej6w")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j7iyf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gw75a")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"drawing-bow-up",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_w2nd7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rd4wh")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rwmr7")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"firing-arrow-down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_na211")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kl0pt")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_sdskq")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"firing-arrow-side",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1dk7p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5pvpc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3uof2")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"firing-arrow-up",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0s5vo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_iy4ef")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1l5y2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tbera")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6giml")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_huf5g")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle-down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bsgi0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_72dk0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gwc2p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_g4n6s")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tvm7c")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_amsyc")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle-side",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ei8qf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3fwgt")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_83xkn")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_df3jv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bwglw")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_j74gm")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle-up",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_e1olu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jmdrl")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_wk3mk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8mpdo")
|
||||
}, {
|
||||
"duration": 8.0,
|
||||
"texture": SubResource("AtlasTexture_46inv")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"opening-chest-down",
|
||||
"speed": 8.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_s6rq5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pu3ni")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qdlmc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_wfvue")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pdvtf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_k84dj")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walking-down",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_thygw")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_soxdi")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bexkr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7vbqj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xlw27")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1unn3")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walking-side",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n4kyy")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6pm4n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_2mqt6")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4bosx")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xx24f")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fftbb")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"walking-up",
|
||||
"speed": 10.0
|
||||
}]
|
||||
|
||||
[node name="Sprite" type="AnimatedSprite2D" unique_id=1296959783]
|
||||
sprite_frames = SubResource("SpriteFrames_jqxwg")
|
||||
animation = &"opening-chest-down"
|
||||
autoplay = "idle-down"
|
||||
script = ExtResource("1_jqxwg")
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://c74mhfemxuuco" path="res://Entities/Characters/Player/Scripts/state_machine.gd" id="1_clu2m"]
|
||||
|
||||
[node name="StateMachine" type="Node" unique_id=732559774]
|
||||
[node name="State Machine" type="Node" unique_id=732559774]
|
||||
script = ExtResource("1_clu2m")
|
||||
@@ -1,10 +0,0 @@
|
||||
extends Node
|
||||
|
||||
@export var state_machine: PlayerStateMachine
|
||||
|
||||
# Public Methods
|
||||
func OnMovementInput(_movement_vector: Vector2) -> void:
|
||||
var current_state := state_machine.GetCurrentStateEnum()
|
||||
if current_state == PlayerStateMachine.States.IDLE:
|
||||
var idle_state := state_machine.current_state as PlayerIdleState
|
||||
idle_state.QueueMovement()
|
||||
@@ -3,8 +3,11 @@ extends Node
|
||||
|
||||
@export var state_machine: PlayerStateMachine
|
||||
|
||||
var _subscribed_events: Array[String] = []
|
||||
var _subscribed_events_callables: Array[Callable] = []
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
push_error("Unimplemented Method: BaseState.GetName")
|
||||
push_error("Unimplemented Method: BaseState.GetStateEnum")
|
||||
return PlayerStateMachine.States.IDLE
|
||||
|
||||
|
||||
@@ -31,3 +34,23 @@ func IsActive() -> bool:
|
||||
|
||||
func IsStateActionable() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func SubscribeToEvent(event_name: String, callback: Callable) -> void:
|
||||
if _subscribed_events.has(event_name):
|
||||
return
|
||||
_subscribed_events.append(event_name)
|
||||
_subscribed_events_callables.append(callback)
|
||||
|
||||
|
||||
# State Machine Visibility Only
|
||||
func _StateMachine_OnEventSent(event_name: String, parameters: Variant) -> void:
|
||||
var idx := _subscribed_events.find(event_name)
|
||||
if idx == -1:
|
||||
push_error("THIS SHOULD NEVER HAPPEN LOL")
|
||||
|
||||
var callable := _subscribed_events_callables[idx]
|
||||
if callable.get_argument_count() == 0:
|
||||
callable.call()
|
||||
else:
|
||||
callable.call(parameters)
|
||||
|
||||
@@ -1,52 +1,14 @@
|
||||
extends BaseState
|
||||
class_name PlayerIdleState
|
||||
|
||||
signal PlayerBecameIdle
|
||||
# idle_state.gd
|
||||
|
||||
@export var player: PlayerCharacter
|
||||
func _ready() -> void:
|
||||
SubscribeToEvent("MovementQueued", OnMovementQueued)
|
||||
|
||||
var _movement_component: MovementComponent
|
||||
var _sit_queued := false
|
||||
var _sit_queue_pos: Vector2
|
||||
var _sit_queue_dir: Enums.Directions
|
||||
|
||||
func OnMovementQueued(dv: Vector2) -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.WALKING, {"dv": dv})
|
||||
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.IDLE
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
_movement_component = ComponentUtils.GetMovementComponent(player)
|
||||
if not _movement_component:
|
||||
print_rich("[color=yellow]Warning: Player does not have a movement component...[/color]")
|
||||
|
||||
PlayerBecameIdle.emit()
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
var item_a := Input.is_action_just_pressed("use_item_a")
|
||||
|
||||
if item_a:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.USING_ITEM_A, {})
|
||||
return
|
||||
|
||||
if _sit_queued:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.SITTING, {"pos": _sit_queue_pos, "dir": _sit_queue_dir})
|
||||
_sit_queued = false
|
||||
return
|
||||
|
||||
if _movement_component and _movement_component.movement_vector != Vector2.ZERO:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.WALKING)
|
||||
|
||||
|
||||
func OnSitOnFurnitureTriggered(sitting_position: Vector2, sitting_direction: Enums.Directions) -> void:
|
||||
if state_machine.GetCurrentStateEnum() != GetStateEnum():
|
||||
return
|
||||
|
||||
_sit_queued = true
|
||||
_sit_queue_pos = sitting_position
|
||||
_sit_queue_dir = sitting_direction
|
||||
|
||||
|
||||
func OnCutsceneStarted() -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.CUTSCENE)
|
||||
|
||||
@@ -1,30 +1,41 @@
|
||||
extends BaseState
|
||||
|
||||
# walking_state.gd
|
||||
|
||||
signal StartedWalking
|
||||
|
||||
@export var walking_speed := 100
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
@export var body: CharacterBody2D
|
||||
|
||||
var _movement_component: MovementComponent
|
||||
var _queued_dv: Vector2
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.WALKING
|
||||
func _ready() -> void:
|
||||
SubscribeToEvent("MovementQueued", OnMovementQueued)
|
||||
SubscribeToEvent("NoMovementQueued", OnNoMovementQueued)
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
_movement_component = ComponentUtils.GetMovementComponent(body)
|
||||
print("Walking State Entered")
|
||||
_queued_dv = _extra_parameters["dv"]
|
||||
StartedWalking.emit()
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
var movement_vector := _movement_component.movement_vector
|
||||
|
||||
if movement_vector == Vector2.ZERO:
|
||||
if _queued_dv == Vector2.ZERO:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
return
|
||||
|
||||
body.velocity = movement_vector * walking_speed
|
||||
body.velocity = _queued_dv * walking_speed
|
||||
body.move_and_slide()
|
||||
|
||||
direction_component.ChangeDirectionUsingMovementVector(movement_vector)
|
||||
|
||||
func OnMovementQueued(dv: Vector2) -> void:
|
||||
_queued_dv = dv
|
||||
|
||||
|
||||
func OnNoMovementQueued() -> void:
|
||||
_queued_dv = Vector2.ZERO
|
||||
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.WALKING
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
extends Node
|
||||
class_name MovementComponent
|
||||
|
||||
signal MovementInput(movement_vector: Vector2)
|
||||
|
||||
var movement_vector: Vector2
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var direction_vector := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
|
||||
if direction_vector:
|
||||
movement_vector = direction_vector
|
||||
MovementInput.emit(movement_vector)
|
||||
else:
|
||||
movement_vector = Vector2.ZERO
|
||||
@@ -1,18 +0,0 @@
|
||||
extends CharacterBody2D
|
||||
class_name PlayerCharacter
|
||||
|
||||
# Signals
|
||||
signal SitOnFurnitureTriggered(sitting_position: Vector2, sitting_direction: Enums.Directions)
|
||||
|
||||
# Exports
|
||||
@export var player_sprite: PlayerSprite
|
||||
@export var state_machine: PlayerStateMachine
|
||||
@export var interact_scanner: InteractScanner
|
||||
|
||||
# Public Methods
|
||||
func QueueCutsceneState() -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.CUTSCENE)
|
||||
|
||||
|
||||
func QueueEndCutsceneState() -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
4
Entities/Characters/Player/Scripts/player_body.gd
Normal file
4
Entities/Characters/Player/Scripts/player_body.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
# PlayerBody.gd:
|
||||
# Represents the player's actual CharacterBody (collision)
|
||||
@@ -1,4 +1,4 @@
|
||||
extends Node2D
|
||||
extends AnimatedSprite2D
|
||||
class_name PlayerSprite
|
||||
|
||||
# Signals
|
||||
@@ -6,37 +6,11 @@ signal DrawingBowAnimationFinished
|
||||
signal FiringArrowAnimationFinished
|
||||
signal AnimationFinished(animation_name: String)
|
||||
|
||||
# Exports
|
||||
@export var state_machine: PlayerStateMachine
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
|
||||
# OnReady Variables
|
||||
@onready var full: AnimatedSprite2D = $Full
|
||||
|
||||
# Private Variables
|
||||
var _all_parts: Array[AnimatedSprite2D]
|
||||
var _current_animation := "idle-down"
|
||||
var _is_flipped := false
|
||||
|
||||
# Public Methods
|
||||
func UpdateSprite() -> void:
|
||||
var current_state := state_machine.current_state
|
||||
var current_direction := direction_component.GetCurrentDirection()
|
||||
var animation := _build_animation_name(current_state, current_direction)
|
||||
var should_flip := _should_flip_horizontal()
|
||||
|
||||
if animation == _current_animation and should_flip == _is_flipped:
|
||||
return
|
||||
|
||||
_current_animation = animation
|
||||
_is_flipped = should_flip
|
||||
|
||||
for part in _all_parts:
|
||||
part.animation = animation
|
||||
part.play()
|
||||
part.flip_h = should_flip
|
||||
|
||||
|
||||
func OnAnimationFinished() -> void:
|
||||
if _current_animation.begins_with("drawing-bow-"):
|
||||
DrawingBowAnimationFinished.emit()
|
||||
@@ -47,18 +21,8 @@ func OnAnimationFinished() -> void:
|
||||
|
||||
func PlaySpecifiedAnimation(animation_name: String) -> void:
|
||||
_current_animation = animation_name
|
||||
for part in _all_parts:
|
||||
part.animation = animation_name
|
||||
part.play()
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
_all_parts = [
|
||||
full
|
||||
]
|
||||
|
||||
UpdateSprite()
|
||||
animation = animation_name
|
||||
play()
|
||||
|
||||
|
||||
func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String:
|
||||
@@ -72,7 +36,3 @@ func _direction_to_animation_state(direction: Enums.Directions) -> String:
|
||||
if direction == Enums.Directions.LEFT or direction == Enums.Directions.RIGHT:
|
||||
return "side"
|
||||
return Enums.Directions.keys()[direction].to_lower()
|
||||
|
||||
|
||||
func _should_flip_horizontal() -> bool:
|
||||
return direction_component.GetCurrentDirection() == Enums.Directions.LEFT
|
||||
|
||||
11
Entities/Characters/Player/Scripts/state_event_connector.gd
Normal file
11
Entities/Characters/Player/Scripts/state_event_connector.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
|
||||
@export var state_machine: PlayerStateMachine
|
||||
|
||||
# Public Methods
|
||||
func OnMovementQueued(direction_vector: Vector2) -> void:
|
||||
state_machine.SendEventToCurrentStateIfValid("MovementQueued", direction_vector)
|
||||
|
||||
|
||||
func OnNoMovementQueued() -> void:
|
||||
state_machine.SendEventToCurrentStateIfValid("NoMovementQueued")
|
||||
@@ -25,6 +25,11 @@ func QueueStateChange(to_state_enum: PlayerStateMachine.States, extra_parameters
|
||||
queued_parameters = extra_parameters
|
||||
|
||||
|
||||
func SendEventToCurrentStateIfValid(signal_name: String, parameters: Variant = null) -> void:
|
||||
if current_state._subscribed_events.has(signal_name):
|
||||
current_state._StateMachine_OnEventSent(signal_name, parameters)
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var children := states_container.get_children()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://dl4bhu5o71rdv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://uyl0s1e67x6s" path="res://Entities/Characters/Player/Individual Components/sprite.tscn" id="1_ydjex"]
|
||||
|
||||
[node name="Decorative Player Map Entity" type="Node2D" unique_id=2077444123]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Sprite" parent="." unique_id=1296959783 instance=ExtResource("1_ydjex")]
|
||||
@@ -1,128 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://6athlweutl2g"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://uyl0s1e67x6s" path="res://Entities/Characters/Player/sprite.tscn" id="1_27cb7"]
|
||||
[ext_resource type="PackedScene" uid="uid://c2ydbmmvnfca6" path="res://Entities/Characters/Player/state_machine.tscn" id="1_lyjr2"]
|
||||
[ext_resource type="Script" uid="uid://dacvayqstkvws" path="res://Entities/Characters/Player/Scripts/player.gd" id="1_qqvsf"]
|
||||
[ext_resource type="Script" uid="uid://b0l02v61if6k8" path="res://Scripts/Components/facing_direction_component.gd" id="1_siygm"]
|
||||
[ext_resource type="Script" uid="uid://dkmc1t43gomdb" path="res://Entities/Characters/Player/Scripts/States/idle_state.gd" id="4_dxcao"]
|
||||
[ext_resource type="Script" uid="uid://ckn7gmtc23b8l" path="res://Entities/Characters/Player/Scripts/States/using_item_a_state.gd" id="5_1mdwi"]
|
||||
[ext_resource type="Script" uid="uid://bwmmah30t3m0u" path="res://Entities/Characters/Player/Scripts/States/walking_state.gd" id="5_cscr0"]
|
||||
[ext_resource type="Script" uid="uid://brlisuoocwehh" path="res://Entities/Characters/Player/Scripts/interact_scanner.gd" id="6_fu1fx"]
|
||||
[ext_resource type="Script" uid="uid://bnp1vowmu15lg" path="res://Entities/Characters/Player/Scripts/States/drawing_bow_state.gd" id="7_cscr0"]
|
||||
[ext_resource type="Script" uid="uid://cd2ewadcm8oi5" path="res://Entities/Characters/Player/Scripts/States/firing_arrow_state.gd" id="8_plevq"]
|
||||
[ext_resource type="Script" uid="uid://bx1a35al4yiej" path="res://Entities/Characters/Player/Scripts/States/sitting_state.gd" id="9_sdxbo"]
|
||||
[ext_resource type="Script" uid="uid://bnontuqj3cnom" path="res://Entities/Characters/Player/Scripts/States/cutscene_state.gd" id="10_p06rw"]
|
||||
[ext_resource type="Script" uid="uid://wfdtd3xlgrvm" path="res://Entities/Characters/Player/Scripts/States/play_animation_state.gd" id="12_aencf"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_apx8m"]
|
||||
size = Vector2(10, 5)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_plevq"]
|
||||
radius = 12.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fu1fx"]
|
||||
size = Vector2(6, 5)
|
||||
|
||||
[node name="Player" type="CharacterBody2D" unique_id=1502234578 node_paths=PackedStringArray("player_sprite", "state_machine", "interact_scanner") groups=["Player Group"]]
|
||||
y_sort_enabled = true
|
||||
script = ExtResource("1_qqvsf")
|
||||
player_sprite = NodePath("Player Sprite")
|
||||
state_machine = NodePath("State Machine")
|
||||
interact_scanner = NodePath("Marker2D/InteractScanner")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=495465356]
|
||||
position = Vector2(0, 4.5)
|
||||
shape = SubResource("RectangleShape2D_apx8m")
|
||||
|
||||
[node name="Components" type="Node" parent="." unique_id=567893784]
|
||||
|
||||
[node name="FacingDirectionComponent" type="Node" parent="Components" unique_id=408127032]
|
||||
script = ExtResource("1_siygm")
|
||||
|
||||
[node name="State Machine" parent="." unique_id=732559774 node_paths=PackedStringArray("states_container", "current_state") instance=ExtResource("1_lyjr2")]
|
||||
states_container = NodePath("States")
|
||||
current_state = NodePath("States/Idle State")
|
||||
|
||||
[node name="States" type="Node" parent="State Machine" unique_id=1171587216]
|
||||
|
||||
[node name="Idle State" type="Node" parent="State Machine/States" unique_id=2017409248 node_paths=PackedStringArray("player", "state_machine")]
|
||||
script = ExtResource("4_dxcao")
|
||||
player = NodePath("../../..")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Walking State" type="Node" parent="State Machine/States" unique_id=1661048365 node_paths=PackedStringArray("direction_component", "body", "state_machine")]
|
||||
script = ExtResource("5_cscr0")
|
||||
direction_component = NodePath("../../../Components/FacingDirectionComponent")
|
||||
body = NodePath("../../..")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Using Item A State" type="Node" parent="State Machine/States" unique_id=1017153142 node_paths=PackedStringArray("body", "direction_component", "state_machine")]
|
||||
script = ExtResource("5_1mdwi")
|
||||
body = NodePath("../../..")
|
||||
direction_component = NodePath("../../../Components/FacingDirectionComponent")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Drawing Bow State" type="Node" parent="State Machine/States" unique_id=317681716 node_paths=PackedStringArray("body", "state_machine")]
|
||||
script = ExtResource("7_cscr0")
|
||||
body = NodePath("../../..")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Firing Arrow State" type="Node" parent="State Machine/States" unique_id=2129772816 node_paths=PackedStringArray("direction_component", "arrow_spawn_marker", "state_machine")]
|
||||
script = ExtResource("8_plevq")
|
||||
direction_component = NodePath("../../../Components/FacingDirectionComponent")
|
||||
arrow_spawn_marker = NodePath("../../../Marker2D")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Sitting State" type="Node" parent="State Machine/States" unique_id=1774602333 node_paths=PackedStringArray("state_machine")]
|
||||
script = ExtResource("9_sdxbo")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Cutscene State" type="Node" parent="State Machine/States" unique_id=1722986400 node_paths=PackedStringArray("state_machine")]
|
||||
script = ExtResource("10_p06rw")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Play Animation State" type="Node" parent="State Machine/States" unique_id=1357816619 node_paths=PackedStringArray("state_machine")]
|
||||
script = ExtResource("12_aencf")
|
||||
state_machine = NodePath("../..")
|
||||
|
||||
[node name="Occlusion Culling Area" type="Area2D" parent="." unique_id=1195961806]
|
||||
collision_layer = 8
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Occlusion Culling Area" unique_id=1162272029]
|
||||
shape = SubResource("CircleShape2D_plevq")
|
||||
|
||||
[node name="Player Sprite" parent="." unique_id=1169131604 node_paths=PackedStringArray("state_machine", "direction_component") instance=ExtResource("1_27cb7")]
|
||||
state_machine = NodePath("../State Machine")
|
||||
direction_component = NodePath("../Components/FacingDirectionComponent")
|
||||
|
||||
[node name="Marker2D" type="Marker2D" parent="." unique_id=2003544808]
|
||||
|
||||
[node name="InteractScanner" type="Area2D" parent="Marker2D" unique_id=408353807 node_paths=PackedStringArray("parent", "direction_component")]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
script = ExtResource("6_fu1fx")
|
||||
parent = NodePath("..")
|
||||
direction_component = NodePath("../../Components/FacingDirectionComponent")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Marker2D/InteractScanner" unique_id=1274307485]
|
||||
position = Vector2(0, 9.5)
|
||||
shape = SubResource("RectangleShape2D_fu1fx")
|
||||
debug_color = Color(0.79959095, 0.41617078, 0.18507844, 0.41960785)
|
||||
|
||||
[connection signal="SitOnFurnitureTriggered" from="." to="State Machine/States/Idle State" method="OnSitOnFurnitureTriggered"]
|
||||
[connection signal="DirectionChanged" from="Components/FacingDirectionComponent" to="Player Sprite" method="UpdateSprite"]
|
||||
[connection signal="DirectionChanged" from="Components/FacingDirectionComponent" to="Marker2D/InteractScanner" method="OnDirectionChanged"]
|
||||
[connection signal="PlayerBecameIdle" from="State Machine/States/Idle State" to="Player Sprite" method="UpdateSprite"]
|
||||
[connection signal="StartedWalking" from="State Machine/States/Walking State" to="Player Sprite" method="UpdateSprite"]
|
||||
[connection signal="PlayerBeganDrawingBow" from="State Machine/States/Drawing Bow State" to="Player Sprite" method="UpdateSprite"]
|
||||
[connection signal="PlayerBeganFiringArrow" from="State Machine/States/Firing Arrow State" to="Player Sprite" method="UpdateSprite"]
|
||||
[connection signal="PlayAnimation" from="State Machine/States/Play Animation State" to="Player Sprite" method="PlaySpecifiedAnimation"]
|
||||
[connection signal="AnimationFinished" from="Player Sprite" to="State Machine/States/Play Animation State" method="OnAnimationFinished"]
|
||||
[connection signal="DrawingBowAnimationFinished" from="Player Sprite" to="State Machine/States/Drawing Bow State" method="OnDrawingBowAnimationFinished"]
|
||||
[connection signal="FiringArrowAnimationFinished" from="Player Sprite" to="State Machine/States/Firing Arrow State" method="OnFiringArrowAnimationFinished"]
|
||||
[connection signal="InteractionActionTriggered" from="Marker2D/InteractScanner" to="." method="_on_interaction_action_triggered"]
|
||||
[connection signal="area_entered" from="Marker2D/InteractScanner" to="." method="_on_interact_scanner_area_entered"]
|
||||
[connection signal="area_exited" from="Marker2D/InteractScanner" to="." method="_on_interact_scanner_area_exited"]
|
||||
[connection signal="body_entered" from="Marker2D/InteractScanner" to="." method="_on_interact_scanner_body_entered"]
|
||||
[connection signal="body_exited" from="Marker2D/InteractScanner" to="." method="_on_interact_scanner_body_exited"]
|
||||
49
Entities/Characters/Player/player_map_entity.tscn
Normal file
49
Entities/Characters/Player/player_map_entity.tscn
Normal file
@@ -0,0 +1,49 @@
|
||||
[gd_scene format=3 uid="uid://c65cfm3t0obwq"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/Individual Components/body.tscn" id="1_62n52"]
|
||||
[ext_resource type="PackedScene" uid="uid://uyl0s1e67x6s" path="res://Entities/Characters/Player/Individual Components/sprite.tscn" id="2_1uhri"]
|
||||
[ext_resource type="PackedScene" uid="uid://c2ydbmmvnfca6" path="res://Entities/Characters/Player/Individual Components/state_machine.tscn" id="3_1uhri"]
|
||||
[ext_resource type="Script" uid="uid://dkmc1t43gomdb" path="res://Entities/Characters/Player/Scripts/States/idle_state.gd" id="4_evnf3"]
|
||||
[ext_resource type="PackedScene" uid="uid://nbkisxm2oekn" path="res://Entities/Characters/Utility/Components/movement_component.tscn" id="5_h314u"]
|
||||
[ext_resource type="Script" uid="uid://bwmmah30t3m0u" path="res://Entities/Characters/Player/Scripts/States/walking_state.gd" id="5_rg3km"]
|
||||
[ext_resource type="Script" uid="uid://ctoxjn2rvtjs6" path="res://Entities/Characters/Player/Scripts/state_event_connector.gd" id="6_18fwg"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_62n52"]
|
||||
size = Vector2(13, 9)
|
||||
|
||||
[node name="Player Map Entity" type="Node2D" unique_id=469362016]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Player Body" parent="." unique_id=1502234578 instance=ExtResource("1_62n52")]
|
||||
|
||||
[node name="Sprite" parent="Player Body" unique_id=1169131604 instance=ExtResource("2_1uhri")]
|
||||
position = Vector2(0, 7)
|
||||
offset = Vector2(0, -7)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player Body" unique_id=760188594]
|
||||
position = Vector2(-0.5, 4.5)
|
||||
shape = SubResource("RectangleShape2D_62n52")
|
||||
|
||||
[node name="State Machine" parent="." unique_id=732559774 node_paths=PackedStringArray("states_container", "current_state") instance=ExtResource("3_1uhri")]
|
||||
states_container = NodePath(".")
|
||||
current_state = NodePath("Idle")
|
||||
|
||||
[node name="Idle" type="Node" parent="State Machine" unique_id=1849660058 node_paths=PackedStringArray("state_machine")]
|
||||
script = ExtResource("4_evnf3")
|
||||
state_machine = NodePath("..")
|
||||
|
||||
[node name="Walking" type="Node" parent="State Machine" unique_id=485440867 node_paths=PackedStringArray("body", "state_machine")]
|
||||
script = ExtResource("5_rg3km")
|
||||
body = NodePath("../../Player Body")
|
||||
state_machine = NodePath("..")
|
||||
|
||||
[node name="Movement Component" parent="." unique_id=737644583 instance=ExtResource("5_h314u")]
|
||||
|
||||
[node name="Internal (Code Here)" type="Node" parent="." unique_id=95043416]
|
||||
|
||||
[node name="State Event Connector" type="Node" parent="Internal (Code Here)" unique_id=186266500 node_paths=PackedStringArray("state_machine")]
|
||||
script = ExtResource("6_18fwg")
|
||||
state_machine = NodePath("../../State Machine")
|
||||
|
||||
[connection signal="MovementQueued" from="Movement Component" to="Internal (Code Here)/State Event Connector" method="OnMovementQueued"]
|
||||
[connection signal="NoMovementQueued" from="Movement Component" to="Internal (Code Here)/State Event Connector" method="OnNoMovementQueued"]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
extends Node
|
||||
class_name MovementComponent
|
||||
|
||||
# movement_component.gd
|
||||
# A simple script that checks for movement input and emits a signal with the
|
||||
# direction vector
|
||||
|
||||
signal MovementQueued(direction_vector: Vector2)
|
||||
signal NoMovementQueued
|
||||
|
||||
var direction_vector: Vector2
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var dv := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
|
||||
if dv:
|
||||
direction_vector = dv
|
||||
MovementQueued.emit(dv)
|
||||
else:
|
||||
direction_vector = Vector2.ZERO
|
||||
NoMovementQueued.emit()
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://nbkisxm2oekn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dwclkwbig1uii" path="res://Entities/Characters/Player/Scripts/movement_component.gd" id="1_b2nib"]
|
||||
[ext_resource type="Script" uid="uid://dwclkwbig1uii" path="res://Entities/Characters/Utility/Components/Scripts/movement_component.gd" id="1_b2nib"]
|
||||
|
||||
[node name="Movement Component" type="Node" unique_id=737644583]
|
||||
script = ExtResource("1_b2nib")
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
extends Node
|
||||
|
||||
# Exports
|
||||
@export var player: PlayerCharacter
|
||||
@export var arrow_parent: Node2D
|
||||
|
||||
# Preloads
|
||||
const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx")
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
var firing_arrow_state: FiringArrowState = player.get_node("State Machine/States/Firing Arrow State")
|
||||
firing_arrow_state.ArrowFired.connect(_on_arrow_fired)
|
||||
|
||||
|
||||
func _on_arrow_fired(fire_position: Vector2, direction: Vector2) -> void:
|
||||
var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile
|
||||
wooden_arrow.SetProjectileStartAndDirection(fire_position, direction)
|
||||
|
||||
if arrow_parent == null:
|
||||
return
|
||||
arrow_parent.add_child(wooden_arrow)
|
||||
#extends Node
|
||||
#
|
||||
## Exports
|
||||
#@export var arrow_parent: Node2D
|
||||
#
|
||||
## Preloads
|
||||
#const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx")
|
||||
#
|
||||
## Private Methods
|
||||
#func _ready() -> void:
|
||||
#firing_arrow_state.ArrowFired.connect(_on_arrow_fired)
|
||||
#
|
||||
#
|
||||
#func _on_arrow_fired(fire_position: Vector2, direction: Vector2) -> void:
|
||||
#var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile
|
||||
#wooden_arrow.SetProjectileStartAndDirection(fire_position, direction)
|
||||
#
|
||||
#if arrow_parent == null:
|
||||
#return
|
||||
#arrow_parent.add_child(wooden_arrow)
|
||||
|
||||
@@ -1,11 +1 @@
|
||||
extends Area2D
|
||||
class_name CollisionLoadingZone
|
||||
|
||||
@export var loading_zone_transporter: LoadingZoneTransporter
|
||||
|
||||
# Private Methods
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body is not PlayerCharacter:
|
||||
return
|
||||
|
||||
loading_zone_transporter.Activate()
|
||||
extends Node
|
||||
|
||||
@@ -45,9 +45,9 @@ func GetAllDialogueTriggers() -> Array[DialogueTrigger]:
|
||||
return arr
|
||||
|
||||
|
||||
func GetPlayer() -> PlayerCharacter:
|
||||
func GetPlayerBody() -> CharacterBody2D:
|
||||
var nodes := get_tree().get_nodes_in_group("Player Group")
|
||||
if nodes.is_empty():
|
||||
return null
|
||||
|
||||
return nodes[0] as PlayerCharacter
|
||||
return nodes[0] as CharacterBody2D
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://ddgeo3vwebqeg" path="res://Entities/Map Objects/Mechanisms/shop_item.tscn" id="3_7ftpj"]
|
||||
[ext_resource type="Script" uid="uid://dkcsftcdqtmg" path="res://Maps/Connectors/Scripts/spawn_marker_connector.gd" id="3_t8w5b"]
|
||||
[ext_resource type="Texture2D" uid="uid://hop1gedjh8s4" path="res://Assets/Spritesheets/Player/icons_full_32.png" id="4_r8s0p"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/player.tscn" id="5_6ky6i"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/Individual Components/body.tscn" id="5_6ky6i"]
|
||||
[ext_resource type="Texture2D" uid="uid://crebnygky3qv0" path="res://Assets/Sprites/Black Square.png" id="6_kt7c3"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="6_t8w5b"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf6llktwqhs8l" path="res://Assets/Sprites/Door Fade.png" id="7_7ftpj"]
|
||||
@@ -44,7 +44,7 @@ script = ExtResource("2_r8s0p")
|
||||
|
||||
[node name="Spawn Marker Connector" type="Node" parent="." unique_id=2053338893 node_paths=PackedStringArray("player", "markers")]
|
||||
script = ExtResource("3_t8w5b")
|
||||
player = NodePath("../Player")
|
||||
player = NodePath("../Player Body")
|
||||
markers = NodePath("../Spawn Markers")
|
||||
|
||||
[node name="Tilemap" type="Node2D" parent="." unique_id=81778152]
|
||||
@@ -115,7 +115,7 @@ destination_marker_name = "Shop Entrance"
|
||||
[node name="Shop Entrance" type="Marker2D" parent="Spawn Markers" unique_id=122141189]
|
||||
position = Vector2(223, 225)
|
||||
|
||||
[node name="Player" parent="." unique_id=1502234578 instance=ExtResource("5_6ky6i")]
|
||||
[node name="Player Body" parent="." unique_id=1502234578 instance=ExtResource("5_6ky6i")]
|
||||
position = Vector2(289, 174)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=1684491254]
|
||||
@@ -145,6 +145,3 @@ texture = ExtResource("6_kt7c3")
|
||||
position = Vector2(224, 232)
|
||||
scale = Vector2(2, 1)
|
||||
texture = ExtResource("7_7ftpj")
|
||||
|
||||
[connection signal="InteractScannerAreaEntered" from="Player" to="Shop Item Notification Connector" method="OnPlayerInteractScannerAreaEntered"]
|
||||
[connection signal="InteractScannerAreaExited" from="Player" to="Shop Item Notification Connector" method="OnPlayerInteractScannerAreaExited"]
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
extends Node
|
||||
class_name BenchInteractionConnector
|
||||
|
||||
# Signals
|
||||
signal SitOnBenchTriggered(position: Vector2, sitting_direction: Enums.Directions)
|
||||
|
||||
# Exports
|
||||
@export var player: PlayerCharacter
|
||||
|
||||
# Private Variables
|
||||
var _benches_in_range: Array[WoodenBench] = []
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
player.interact_scanner.area_entered.connect(_on_interact_scanned)
|
||||
player.interact_scanner.area_exited.connect(_on_interact_unscanned)
|
||||
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
|
||||
|
||||
|
||||
func _on_interact_scanned(area: Area2D) -> void:
|
||||
var parent := area.get_parent()
|
||||
if parent == null or parent is not WoodenBench or _benches_in_range.has(parent):
|
||||
return
|
||||
_benches_in_range.append(parent)
|
||||
|
||||
|
||||
func _on_interact_unscanned(area: Area2D) -> void:
|
||||
var parent: Node = area.get_parent()
|
||||
if parent == null or parent is not WoodenBench or !_benches_in_range.has(parent):
|
||||
return
|
||||
_benches_in_range.erase(parent)
|
||||
|
||||
|
||||
func _on_interact_triggered() -> void:
|
||||
if _benches_in_range.is_empty():
|
||||
return
|
||||
|
||||
var bench := _benches_in_range[0]
|
||||
var sitting_spots_container := bench.get_node("Sitting Spots") as Node2D
|
||||
var sitting_spot_markers := sitting_spots_container.get_children()
|
||||
|
||||
var closest_marker: Marker2D
|
||||
var distance_to_player := 9999.0
|
||||
for node in sitting_spot_markers:
|
||||
var marker := node as Marker2D
|
||||
var distance := marker.global_position.distance_to(player.global_position)
|
||||
if distance < distance_to_player:
|
||||
closest_marker = marker
|
||||
distance_to_player = distance
|
||||
|
||||
if !closest_marker:
|
||||
return
|
||||
|
||||
player.SitOnFurnitureTriggered.emit(closest_marker.global_position, Enums.Directions.DOWN)
|
||||
#class_name BenchInteractionConnector
|
||||
#
|
||||
## Signals
|
||||
#signal SitOnBenchTriggered(position: Vector2, sitting_direction: Enums.Directions)
|
||||
#
|
||||
## Exports
|
||||
#@export var player: PlayerBody
|
||||
#
|
||||
## Private Variables
|
||||
#var _benches_in_range: Array[WoodenBench] = []
|
||||
#
|
||||
## Private Methods
|
||||
#func _ready() -> void:
|
||||
#player.interact_scanner.area_entered.connect(_on_interact_scanned)
|
||||
#player.interact_scanner.area_exited.connect(_on_interact_unscanned)
|
||||
#player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
|
||||
#
|
||||
#
|
||||
#func _on_interact_scanned(area: Area2D) -> void:
|
||||
#var parent := area.get_parent()
|
||||
#if parent == null or parent is not WoodenBench or _benches_in_range.has(parent):
|
||||
#return
|
||||
#_benches_in_range.append(parent)
|
||||
#
|
||||
#
|
||||
#func _on_interact_unscanned(area: Area2D) -> void:
|
||||
#var parent: Node = area.get_parent()
|
||||
#if parent == null or parent is not WoodenBench or !_benches_in_range.has(parent):
|
||||
#return
|
||||
#_benches_in_range.erase(parent)
|
||||
#
|
||||
#
|
||||
#func _on_interact_triggered() -> void:
|
||||
#if _benches_in_range.is_empty():
|
||||
#return
|
||||
#
|
||||
#var bench := _benches_in_range[0]
|
||||
#var sitting_spots_container := bench.get_node("Sitting Spots") as Node2D
|
||||
#var sitting_spot_markers := sitting_spots_container.get_children()
|
||||
#
|
||||
#var closest_marker: Marker2D
|
||||
#var distance_to_player := 9999.0
|
||||
#for node in sitting_spot_markers:
|
||||
#var marker := node as Marker2D
|
||||
#var distance := marker.global_position.distance_to(player.global_position)
|
||||
#if distance < distance_to_player:
|
||||
#closest_marker = marker
|
||||
#distance_to_player = distance
|
||||
#
|
||||
#if !closest_marker:
|
||||
#return
|
||||
#
|
||||
#player.SitOnFurnitureTriggered.emit(closest_marker.global_position, Enums.Directions.DOWN)
|
||||
|
||||
@@ -4,73 +4,65 @@ extends Node
|
||||
signal OpeningOfOpenedChestAttempted
|
||||
|
||||
# Exports
|
||||
@export var player: PlayerCharacter
|
||||
@export var auto_connect_all_chests := true
|
||||
|
||||
# Private Variables
|
||||
var _chests_in_range: Array[BaseChest] = []
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
player.interact_scanner.area_entered.connect(_on_interact_scanned)
|
||||
player.interact_scanner.area_exited.connect(_on_interact_unscanned)
|
||||
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
|
||||
|
||||
var chests := GroupUtils.GetAllTreasureChests()
|
||||
for chest in chests:
|
||||
chest.OpeningAnimationStarted.connect(_on_chest_opening_animation_started)
|
||||
|
||||
|
||||
func _on_chest_opening_animation_started() -> void:
|
||||
var player := GroupUtils.GetPlayer()
|
||||
var children := player.get_children()
|
||||
|
||||
player.QueueCutsceneState()
|
||||
|
||||
var camera_idx := children.find_custom(func(x): return x is Camera2D)
|
||||
if camera_idx == -1: return
|
||||
|
||||
# Zoom In
|
||||
var camera := children[camera_idx] as Camera2D
|
||||
var current_zoom := camera.zoom
|
||||
await get_tree().create_tween().tween_property(camera, "zoom", current_zoom + Vector2(2, 2), 0.5).finished
|
||||
|
||||
# Player the player's chest opening animation
|
||||
player.state_machine.QueueStateChange(PlayerStateMachine.States.PLAY_ANIMATION, { "animation_name": "opening-chest-down" })
|
||||
await player.state_machine.StateChanged
|
||||
var play_animation_state := player.state_machine.current_state as PlayerPlayAnimationState
|
||||
await play_animation_state.AnimationFinished
|
||||
player.state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
|
||||
# Zoom back out
|
||||
await get_tree().create_tween().tween_property(camera, "zoom", current_zoom, 0.5).finished
|
||||
|
||||
|
||||
func _on_interact_scanned(area: Area2D) -> void:
|
||||
var chest = area.get_parent()
|
||||
if chest == null or chest is not BaseChest:
|
||||
return
|
||||
if _chests_in_range.has(chest):
|
||||
return
|
||||
_chests_in_range.append(chest)
|
||||
|
||||
|
||||
func _on_interact_unscanned(area: Area2D) -> void:
|
||||
var chest = area.get_parent()
|
||||
if chest == null or chest is not BaseChest:
|
||||
return
|
||||
if !_chests_in_range.has(chest):
|
||||
return
|
||||
_chests_in_range.erase(chest)
|
||||
|
||||
|
||||
func _on_interact_triggered() -> void:
|
||||
if _chests_in_range.is_empty():
|
||||
return
|
||||
|
||||
var chest := _chests_in_range[0]
|
||||
if !chest.is_open:
|
||||
chest.Open()
|
||||
else:
|
||||
chest.OpenAlreadyOpened()
|
||||
OpeningOfOpenedChestAttempted.emit()
|
||||
## Private Methods
|
||||
#func _ready() -> void:
|
||||
#var chests := GroupUtils.GetAllTreasureChests()
|
||||
#for chest in chests:
|
||||
#chest.OpeningAnimationStarted.connect(_on_chest_opening_animation_started)
|
||||
#
|
||||
#
|
||||
#func _on_chest_opening_animation_started() -> void:
|
||||
#player.QueueCutsceneState()
|
||||
#
|
||||
#var camera_idx := children.find_custom(func(x): return x is Camera2D)
|
||||
#if camera_idx == -1: return
|
||||
#
|
||||
## Zoom In
|
||||
#var camera := children[camera_idx] as Camera2D
|
||||
#var current_zoom := camera.zoom
|
||||
#await get_tree().create_tween().tween_property(camera, "zoom", current_zoom + Vector2(2, 2), 0.5).finished
|
||||
#
|
||||
## Player the player's chest opening animation
|
||||
#player.state_machine.QueueStateChange(PlayerStateMachine.States.PLAY_ANIMATION, { "animation_name": "opening-chest-down" })
|
||||
#await player.state_machine.StateChanged
|
||||
#var play_animation_state := player.state_machine.current_state as PlayerPlayAnimationState
|
||||
#await play_animation_state.AnimationFinished
|
||||
#player.state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
#
|
||||
## Zoom back out
|
||||
#await get_tree().create_tween().tween_property(camera, "zoom", current_zoom, 0.5).finished
|
||||
#
|
||||
#
|
||||
#func _on_interact_scanned(area: Area2D) -> void:
|
||||
#var chest = area.get_parent()
|
||||
#if chest == null or chest is not BaseChest:
|
||||
#return
|
||||
#if _chests_in_range.has(chest):
|
||||
#return
|
||||
#_chests_in_range.append(chest)
|
||||
#
|
||||
#
|
||||
#func _on_interact_unscanned(area: Area2D) -> void:
|
||||
#var chest = area.get_parent()
|
||||
#if chest == null or chest is not BaseChest:
|
||||
#return
|
||||
#if !_chests_in_range.has(chest):
|
||||
#return
|
||||
#_chests_in_range.erase(chest)
|
||||
#
|
||||
#
|
||||
#func _on_interact_triggered() -> void:
|
||||
#if _chests_in_range.is_empty():
|
||||
#return
|
||||
#
|
||||
#var chest := _chests_in_range[0]
|
||||
#if !chest.is_open:
|
||||
#chest.Open()
|
||||
#else:
|
||||
#chest.OpenAlreadyOpened()
|
||||
#OpeningOfOpenedChestAttempted.emit()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
extends Node
|
||||
|
||||
@export var player: PlayerCharacter
|
||||
|
||||
# Public Methods
|
||||
func OnPlayerAreaEntered(area: Area2D) -> void:
|
||||
pass
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
extends Node
|
||||
|
||||
# Exports
|
||||
@export var player: PlayerCharacter
|
||||
|
||||
# Private Variables
|
||||
var _zones_in_range: Array[InteractiveLoadingZone] = []
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
player.interact_scanner.area_entered.connect(_on_interact_scanned)
|
||||
player.interact_scanner.area_exited.connect(_on_interact_unscanned)
|
||||
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
|
||||
|
||||
|
||||
func _on_interact_scanned(area: Area2D) -> void:
|
||||
if area is not InteractiveLoadingZone or _zones_in_range.has(area):
|
||||
return
|
||||
|
||||
_zones_in_range.append(area)
|
||||
|
||||
|
||||
func _on_interact_unscanned(area: Area2D) -> void:
|
||||
if area is not InteractiveLoadingZone or !_zones_in_range.has(area):
|
||||
return
|
||||
|
||||
_zones_in_range.erase(area)
|
||||
|
||||
|
||||
func _on_interact_triggered() -> void:
|
||||
if _zones_in_range.is_empty():
|
||||
return
|
||||
|
||||
var zone := _zones_in_range[0]
|
||||
zone.Activate()
|
||||
#
|
||||
## Exports
|
||||
#@export var player: PlayerBody
|
||||
#
|
||||
## Private Variables
|
||||
#var _zones_in_range: Array[InteractiveLoadingZone] = []
|
||||
#
|
||||
## Private Methods
|
||||
#func _ready() -> void:
|
||||
#player.interact_scanner.area_entered.connect(_on_interact_scanned)
|
||||
#player.interact_scanner.area_exited.connect(_on_interact_unscanned)
|
||||
#player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
|
||||
#
|
||||
#
|
||||
#func _on_interact_scanned(area: Area2D) -> void:
|
||||
#if area is not InteractiveLoadingZone or _zones_in_range.has(area):
|
||||
#return
|
||||
#
|
||||
#_zones_in_range.append(area)
|
||||
#
|
||||
#
|
||||
#func _on_interact_unscanned(area: Area2D) -> void:
|
||||
#if area is not InteractiveLoadingZone or !_zones_in_range.has(area):
|
||||
#return
|
||||
#
|
||||
#_zones_in_range.erase(area)
|
||||
#
|
||||
#
|
||||
#func _on_interact_triggered() -> void:
|
||||
#if _zones_in_range.is_empty():
|
||||
#return
|
||||
#
|
||||
#var zone := _zones_in_range[0]
|
||||
#zone.Activate()
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
[ext_resource type="TileSet" uid="uid://df0lg5vkqwbbt" path="res://Resources/Tilesets/home_interior.tres" id="1_rf04x"]
|
||||
[ext_resource type="Script" uid="uid://dkcsftcdqtmg" path="res://Maps/Connectors/Scripts/spawn_marker_connector.gd" id="2_16uj4"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca75b65eh7vv8" path="res://Entities/Map Objects/Loading Zone/collision_loading_zone.tscn" id="2_fdso5"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/player.tscn" id="2_lky26"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="3_7kg22"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl2jpjtbiju34" path="res://Maps/Connectors/chest_interaction_connector.tscn" id="3_ec540"]
|
||||
[ext_resource type="PackedScene" uid="uid://b7u4hlvuqiefn" path="res://Entities/Map Objects/Chests/Item Chests/item_chest_02 (Metal).tscn" id="4_a58cd"]
|
||||
[ext_resource type="PackedScene" uid="uid://b60nr4wfvijpf" path="res://Entities/Map Objects/Dialogue/dialogue_trigger.tscn" id="5_msu6a"]
|
||||
[ext_resource type="Texture2D" uid="uid://bm5ewxv51potl" path="res://Assets/Spritesheets/NPCs/Miner_Mike.png" id="6_x3y8m"]
|
||||
[ext_resource type="Texture2D" uid="uid://bqvnkdyhfa1yq" path="res://Maps/Forest Dungeon Entrance/Interiors/Home_01_Overlay_01.png" id="11_6xfm6"]
|
||||
[ext_resource type="PackedScene" uid="uid://nbkisxm2oekn" path="res://Entities/Characters/Utility/Components/movement_component.tscn" id="11_fqvwb"]
|
||||
[ext_resource type="PackedScene" uid="uid://c65cfm3t0obwq" path="res://Entities/Characters/Player/player_map_entity.tscn" id="11_s4nwa"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7kg22"]
|
||||
size = Vector2(32, 8)
|
||||
@@ -82,11 +81,11 @@ script = ExtResource("1_18bbf")
|
||||
|
||||
[node name="Spawn Marker Connector" type="Node" parent="Connectors" unique_id=296643918 node_paths=PackedStringArray("player", "markers")]
|
||||
script = ExtResource("2_16uj4")
|
||||
player = NodePath("../../Player")
|
||||
player = NodePath("")
|
||||
markers = NodePath("../../Spawn Markers")
|
||||
|
||||
[node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 node_paths=PackedStringArray("player") instance=ExtResource("3_ec540")]
|
||||
player = NodePath("../../Player")
|
||||
player = NodePath("")
|
||||
|
||||
[node name="Tilemap" type="Node2D" parent="." unique_id=894627186]
|
||||
y_sort_enabled = true
|
||||
@@ -155,15 +154,13 @@ position = Vector2(-0.5, -4)
|
||||
shape = SubResource("RectangleShape2D_6xfm6")
|
||||
debug_color = Color(0.7930861, 0.42714188, 7.70092e-07, 0.41960785)
|
||||
|
||||
[node name="Player Map Entity" parent="." unique_id=469362016 instance=ExtResource("11_s4nwa")]
|
||||
position = Vector2(176, 133)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=2134984506]
|
||||
position = Vector2(127, 110)
|
||||
zoom = Vector2(3, 3)
|
||||
|
||||
[node name="Player" parent="." unique_id=1502234578 instance=ExtResource("2_lky26")]
|
||||
position = Vector2(108, 139)
|
||||
|
||||
[node name="Movement Component" parent="Player" unique_id=737644583 instance=ExtResource("11_fqvwb")]
|
||||
|
||||
[node name="Overlay" type="Sprite2D" parent="." unique_id=455840170]
|
||||
position = Vector2(124, 217)
|
||||
scale = Vector2(0.25, 0.25)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://303hbhqetdhy" path="res://Maps/Connectors/arrow_spawner.tscn" id="2_jtncl"]
|
||||
[ext_resource type="PackedScene" uid="uid://divmfeqf10ri1" path="res://Maps/Connectors/bench_interaction_connector.tscn" id="3_x6da4"]
|
||||
[ext_resource type="Script" uid="uid://kfupww4frb1r" path="res://Maps/Connectors/Scripts/camera_limit_connector.gd" id="3_ycf72"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/player.tscn" id="4_4igim"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/Individual Components/body.tscn" id="4_4igim"]
|
||||
[ext_resource type="PackedScene" uid="uid://b03s7fw8bxdxs" path="res://Maps/Connectors/interactive_loading_zone_connector.tscn" id="4_4lnhp"]
|
||||
[ext_resource type="PackedScene" uid="uid://byp273amg5ji8" path="res://Entities/Map Objects/Chests/Item Chests/item_chest_01 (Wooden).tscn" id="5_bnsbe"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf6llktwqhs8l" path="res://Assets/Sprites/Door Fade.png" id="5_jett5"]
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
[ext_resource type="Script" uid="uid://qv5i4xr6pldc" path="res://Maps/Live Menus/Scripts/title_screen.gd" id="1_q1wq0"]
|
||||
[ext_resource type="TileSet" uid="uid://cds2lapr3niap" path="res://Resources/Tilesets/forest_exterior.tres" id="1_x5wur"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjufxlsrlcuas" path="res://Entities/Buildings/home_01.tscn" id="2_x4fat"]
|
||||
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/player.tscn" id="3_kqssl"]
|
||||
[ext_resource type="PackedScene" uid="uid://be6xfndyj4ckx" path="res://Entities/Map Objects/Trees/tree_02.tscn" id="4_gs8fo"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcx1d8kvp7o0h" path="res://Entities/Map Objects/Trees/tree_03.tscn" id="5_hgldw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl4bhu5o71rdv" path="res://Entities/Characters/Player/decorative_player_map_entity.tscn" id="6_gs8fo"]
|
||||
|
||||
[node name="TitleScreen" type="Node2D" unique_id=791312405]
|
||||
y_sort_enabled = true
|
||||
@@ -61,8 +61,8 @@ position = Vector2(773, 425)
|
||||
[node name="Tree 03 - 2" parent="Entities/Map Objects/Trees" unique_id=1648360632 instance=ExtResource("5_hgldw")]
|
||||
position = Vector2(427, 307)
|
||||
|
||||
[node name="Player" parent="." unique_id=1502234578 instance=ExtResource("3_kqssl")]
|
||||
position = Vector2(470, 358)
|
||||
[node name="Decorative Player Map Entity" parent="Entities" unique_id=2077444123 instance=ExtResource("6_gs8fo")]
|
||||
position = Vector2(488, 375)
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="." unique_id=2020053057]
|
||||
|
||||
|
||||
@@ -1,55 +1,51 @@
|
||||
extends Node
|
||||
|
||||
# Signals
|
||||
#
|
||||
## Signals
|
||||
signal DialogueTriggered(dialogue_name: String)
|
||||
|
||||
# Exports
|
||||
@export var dialogue_box: DialogueBox
|
||||
|
||||
# Private Variables
|
||||
var _dialogue_triggers_in_area: Array[DialogueTrigger] = []
|
||||
|
||||
# Private Methods
|
||||
func _on_map_changed(map_id: Enums.MapIds) -> void:
|
||||
var player := GroupUtils.GetPlayer()
|
||||
if !player:
|
||||
return
|
||||
|
||||
player.interact_scanner.area_entered.connect(_on_interact_scanned)
|
||||
player.interact_scanner.area_exited.connect(_on_interact_unscanned)
|
||||
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
|
||||
|
||||
dialogue_box.DialogueStarted.connect(player.QueueCutsceneState)
|
||||
dialogue_box.DialogueEnded.connect(player.QueueEndCutsceneState)
|
||||
|
||||
var dialogue_triggers := GroupUtils.GetAllDialogueTriggers()
|
||||
|
||||
for trigger in dialogue_triggers:
|
||||
trigger.DialogueTriggered.connect(_on_dialogue_triggered)
|
||||
|
||||
|
||||
func _on_dialogue_triggered(dialogue_name: String) -> void:
|
||||
# Wait one frame so we don't immediately close dialogue box
|
||||
# TODO This is stupid
|
||||
await get_tree().process_frame
|
||||
DialogueTriggered.emit(dialogue_name)
|
||||
|
||||
|
||||
func _on_interact_scanned(area: Area2D) -> void:
|
||||
if area is not DialogueTrigger or _dialogue_triggers_in_area.has(area):
|
||||
return
|
||||
_dialogue_triggers_in_area.append(area)
|
||||
|
||||
|
||||
func _on_interact_unscanned(area: Area2D) -> void:
|
||||
if area is not DialogueTrigger or !_dialogue_triggers_in_area.has(area):
|
||||
return
|
||||
_dialogue_triggers_in_area.erase(area)
|
||||
|
||||
|
||||
func _on_interact_triggered() -> void:
|
||||
if _dialogue_triggers_in_area.is_empty():
|
||||
return
|
||||
|
||||
var trigger := _dialogue_triggers_in_area[0]
|
||||
trigger.Trigger()
|
||||
#
|
||||
## Exports
|
||||
#@export var dialogue_box: DialogueBox
|
||||
#
|
||||
## Private Variables
|
||||
#var _dialogue_triggers_in_area: Array[DialogueTrigger] = []
|
||||
#
|
||||
## Private Methods
|
||||
#func _on_map_changed(map_id: Enums.MapIds) -> void:
|
||||
#var player := GroupUtils.GetPlayerBody() as PlayerBody
|
||||
#if !player:
|
||||
#return
|
||||
#
|
||||
#dialogue_box.DialogueStarted.connect(player.QueueCutsceneState)
|
||||
#dialogue_box.DialogueEnded.connect(player.QueueEndCutsceneState)
|
||||
#
|
||||
#var dialogue_triggers := GroupUtils.GetAllDialogueTriggers()
|
||||
#
|
||||
#for trigger in dialogue_triggers:
|
||||
#trigger.DialogueTriggered.connect(_on_dialogue_triggered)
|
||||
#
|
||||
#
|
||||
#func _on_dialogue_triggered(dialogue_name: String) -> void:
|
||||
## Wait one frame so we don't immediately close dialogue box
|
||||
## TODO This is stupid
|
||||
#await get_tree().process_frame
|
||||
#DialogueTriggered.emit(dialogue_name)
|
||||
#
|
||||
#
|
||||
#func _on_interact_scanned(area: Area2D) -> void:
|
||||
#if area is not DialogueTrigger or _dialogue_triggers_in_area.has(area):
|
||||
#return
|
||||
#_dialogue_triggers_in_area.append(area)
|
||||
#
|
||||
#
|
||||
#func _on_interact_unscanned(area: Area2D) -> void:
|
||||
#if area is not DialogueTrigger or !_dialogue_triggers_in_area.has(area):
|
||||
#return
|
||||
#_dialogue_triggers_in_area.erase(area)
|
||||
#
|
||||
#
|
||||
#func _on_interact_triggered() -> void:
|
||||
#if _dialogue_triggers_in_area.is_empty():
|
||||
#return
|
||||
#
|
||||
#var trigger := _dialogue_triggers_in_area[0]
|
||||
#trigger.Trigger()
|
||||
|
||||
Reference in New Issue
Block a user