Compare commits

..

4 Commits

96 changed files with 1719 additions and 2415 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bo1utikr0r2q1"
path="res://.godot/imported/64x64.png-129f36e07b18bd0408477af73ef87a83.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Spritesheets/Icons/UI/64x64.png"
dest_files=["res://.godot/imported/64x64.png-129f36e07b18bd0408477af73ef87a83.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@@ -0,0 +1,28 @@
extends Node
class_name BaseTestRunner
func _ready() -> void:
var methods := self.get_method_list()
for method in methods:
var method_name: String = method["name"]
if method_name.left(5).to_lower() != "test_":
continue
var return_dict: Dictionary = method["return"]
var return_type: int = return_dict["type"]
if return_type != 1:
print_rich("[color=yellow]Skipping Unit Test Method '%s'. Reason: Return type is not bool[/color]" % method_name)
continue
var args: Array = method["args"]
if not args.is_empty():
print_rich("[color=yellow]Skipping Unit Test Method '%s', Reason: Method requires arguments.[/color]" % method_name)
continue
var result: bool = call(method_name)
if result:
print_rich("[color=green]%s: Success![/color]" % method_name)
else:
print_rich("[color=red]%s: Failure...[/color]" % method_name)

View File

@@ -0,0 +1 @@
uid://bsewsmjxlup47

View File

@@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://rl2o7alqg7w4"]
[node name="BaseTestRunner" type="Node" unique_id=1916529975]

View File

@@ -0,0 +1,14 @@
extends BaseTestRunner
func Test_1() -> bool:
var json_string = "{\"Key\": false}"
var json = JSON.new()
var parse_result := json.parse(json_string)
if parse_result != OK:
return false
return true
func Test_2() -> String:
return ''

View File

@@ -0,0 +1 @@
uid://xrexdmk7d1qx

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://c23ct3b1nmih7"]
[ext_resource type="Script" uid="uid://xrexdmk7d1qx" path="res://Debug/Unit Testing/Scripts/json_parsing_tests.gd" id="1_beu12"]
[node name="JsonParsingTests" type="Node" unique_id=2014332517]
script = ExtResource("1_beu12")

View File

@@ -5,6 +5,10 @@ enum States {
PECKING
}
@export var minimum_pecking_schedule_gap := 8.0
@export var maximum_pecking_schedule_gap := 25.0
@export var should_log_pecking_schedule := false
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
var current_state := States.IDLE
@@ -23,11 +27,12 @@ func _process(delta: float) -> void:
animated_sprite_2d.play("pecking")
await animated_sprite_2d.animation_finished
animated_sprite_2d.play("idle")
pecking_sched = randf_range(8.0, 25.0)
pecking_sched = randf_range(minimum_pecking_schedule_gap, maximum_pecking_schedule_gap)
pecking_timer = 0
current_state = States.IDLE
_print_sched()
func _print_sched() -> void:
print("%s Pecking Schedule: %f" % [name, pecking_sched])
if should_log_pecking_schedule:
print("%s Pecking Schedule: %f" % [name, pecking_sched])

View File

@@ -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")

View 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 = &"idle-down"
autoplay = "idle-down"
script = ExtResource("1_jqxwg")

View File

@@ -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")

View File

@@ -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()

View File

@@ -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)

View File

@@ -3,35 +3,36 @@ extends BaseState
signal PlayerBeganDrawingBow
@export var strafing_speed := 35
@export var movement_componenent: MovementComponent
@export var body: CharacterBody2D
var used_item_action: String
var animation_finished := false
var _used_item_action: String
var _animation_finished := false
var _movement_componenent: MovementComponent
func GetStateEnum() -> PlayerStateMachine.States:
return PlayerStateMachine.States.DRAWING_BOW
func Enter(extra_parameters: Dictionary) -> void:
animation_finished = false
used_item_action = extra_parameters.action_name
_animation_finished = false
_used_item_action = extra_parameters.action_name
_movement_componenent = ComponentUtils.GetMovementComponent(body)
PlayerBeganDrawingBow.emit()
func Update(_delta: float) -> void:
if !animation_finished:
if !_animation_finished:
return
if !Input.is_action_pressed(used_item_action):
if !Input.is_action_pressed(_used_item_action):
state_machine.QueueStateChange(PlayerStateMachine.States.FIRING_ARROW)
return
var movement_vector := movement_componenent.movement_vector
var movement_vector := _movement_componenent.movement_vector
if movement_vector != Vector2.ZERO:
body.velocity = movement_vector * strafing_speed
body.move_and_slide()
func OnDrawingBowAnimationFinished() -> void:
animation_finished = true
_animation_finished = true

View File

@@ -1,47 +1,14 @@
extends BaseState
class_name PlayerIdleState
@export var movement_component: MovementComponent
# idle_state.gd
signal PlayerBecameIdle
func _ready() -> void:
SubscribeToEvent("MovementQueued", OnMovementQueued)
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:
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.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)

View File

@@ -1,27 +1,40 @@
extends BaseState
# walking_state.gd
signal StartedWalking
@export var walking_speed := 100
@export var movement_component: MovementComponent
@export var direction_component: FacingDirectionComponent
@export var body: CharacterBody2D
func GetStateEnum() -> PlayerStateMachine.States:
return PlayerStateMachine.States.WALKING
var _queued_dv: Vector2
func _ready() -> void:
SubscribeToEvent("MovementQueued", OnMovementQueued)
SubscribeToEvent("NoMovementQueued", OnNoMovementQueued)
func Enter(_extra_parameters: Dictionary) -> void:
_queued_dv = _extra_parameters["dv"]
StartedWalking.emit()
func Update(_delta: float) -> void:
if movement_component.movement_vector == Vector2.ZERO:
if _queued_dv == Vector2.ZERO:
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
return
var movement_vector := movement_component.movement_vector
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

View File

@@ -1,18 +0,0 @@
extends Node
class_name MovementComponent
signal MovementInput(movement_vector: Vector2)
# Dynamic Exports
@export var body: CharacterBody2D
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

View File

@@ -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)

View File

@@ -0,0 +1,4 @@
extends CharacterBody2D
# PlayerBody.gd:
# Represents the player's actual CharacterBody (collision)

View File

@@ -1,78 +1,3 @@
extends Node2D
class_name PlayerSprite
extends AnimatedSprite2D
# Signals
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()
elif _current_animation.begins_with("firing-arrow-"):
FiringArrowAnimationFinished.emit()
AnimationFinished.emit(_current_animation)
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()
func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String:
# e.g. "idle-down", "walking-up"
var state_str := state.GetAnimationBaseName().replace("_", "-")
var direction_str := _direction_to_animation_state(direction)
return "%s-%s" % [state_str, direction_str]
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
# sprite.gd

View File

@@ -0,0 +1,64 @@
extends Node
# sprite_animation_changer.gd
# When the player actually changes state or direction, this component will decide
# which sprite animation should play
@export var sprite: AnimatedSprite2D
var _cached_dv: Vector2
var _cached_state: PlayerStateMachine.States
var _walking_animation_data = {
Vector2.LEFT: ["walking-side", true],
Vector2.RIGHT: ["walking-side", false],
Vector2.UP: ["walking-up", false],
Vector2.DOWN: ["walking-down", false]
}
var _idle_animation_data = {
Vector2.LEFT: ["idle-side", true],
Vector2.RIGHT: ["idle-side", false],
Vector2.UP: ["idle-up", false],
Vector2.DOWN: ["idle-down", false]
}
func OnStateChanged(to_state: PlayerStateMachine.States, _from_state: PlayerStateMachine.States) -> void:
_cached_state = to_state
if to_state == PlayerStateMachine.States.WALKING:
_to_walking_state()
return
if to_state == PlayerStateMachine.States.IDLE:
_to_idle_state()
return
func OnMovementQueued(dv: Vector2) -> void:
_cached_dv = Vector2Utils.GetClosestDirectionVector(dv)
if _cached_state == PlayerStateMachine.States.WALKING:
# Direction changed while walking, update animation, just run _to_walking_state again
_to_walking_state()
func _to_walking_state() -> void:
if _walking_animation_data.has(_cached_dv):
var animation_data = _walking_animation_data[_cached_dv]
var animation_name = animation_data[0] as String
var is_flipped = animation_data[1] as bool
sprite.animation = animation_name
sprite.flip_h = is_flipped
sprite.play()
func _to_idle_state() -> void:
if _idle_animation_data.has(_cached_dv):
var animation_data = _idle_animation_data[_cached_dv]
var animation_name = animation_data[0] as String
var is_flipped = animation_data[1] as bool
sprite.animation = animation_name
sprite.flip_h = is_flipped
sprite.play()

View File

@@ -0,0 +1 @@
uid://by3g7ne2b3lgi

View 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")

View File

@@ -1,7 +1,7 @@
extends Node
class_name PlayerStateMachine
signal StateChanged
signal StateChanged(to_state: States, from_state: States)
enum States {
UNSET, IDLE, WALKING, USING_ITEM_A, DRAWING_BOW, FIRING_ARROW,
@@ -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()
@@ -47,6 +52,9 @@ func _process(delta: float) -> void:
func _swap_state() -> void:
var from_state := current_state.GetStateEnum()
var to_state := queued_state
if current_state:
current_state.Exit()
@@ -55,4 +63,4 @@ func _swap_state() -> void:
queued_state = PlayerStateMachine.States.UNSET
queued_parameters = {}
StateChanged.emit()
StateChanged.emit(to_state, from_state)

View File

@@ -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")]

View File

@@ -1,135 +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://dwclkwbig1uii" path="res://Entities/Characters/Player/Scripts/movement_component.gd" id="4_apx8m"]
[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="MovementComponent" type="Node" parent="Components" unique_id=1773880772 node_paths=PackedStringArray("body")]
script = ExtResource("4_apx8m")
body = NodePath("../..")
[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("movement_component", "state_machine")]
script = ExtResource("4_dxcao")
movement_component = NodePath("../../../Components/MovementComponent")
state_machine = NodePath("../..")
[node name="Walking State" type="Node" parent="State Machine/States" unique_id=1661048365 node_paths=PackedStringArray("movement_component", "direction_component", "body", "state_machine")]
script = ExtResource("5_cscr0")
movement_component = NodePath("../../../Components/MovementComponent")
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("movement_componenent", "body", "state_machine")]
script = ExtResource("7_cscr0")
movement_componenent = NodePath("../../../Components/MovementComponent")
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"]

View File

@@ -0,0 +1,57 @@
[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"]
[ext_resource type="Script" uid="uid://by3g7ne2b3lgi" path="res://Entities/Characters/Player/Scripts/sprite_animation_changer.gd" id="8_bm64c"]
[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")]
collision_layer = 17
[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" type="Node" parent="." unique_id=95043416]
[node name="State Event Connector" type="Node" parent="Internal" unique_id=186266500 node_paths=PackedStringArray("state_machine")]
script = ExtResource("6_18fwg")
state_machine = NodePath("../../State Machine")
[node name="Sprite Animation Changer" type="Node" parent="Internal" unique_id=281485983 node_paths=PackedStringArray("sprite")]
script = ExtResource("8_bm64c")
sprite = NodePath("../../Player Body/Sprite")
[connection signal="StateChanged" from="State Machine" to="Internal/Sprite Animation Changer" method="OnStateChanged"]
[connection signal="MovementQueued" from="Movement Component" to="Internal/State Event Connector" method="OnMovementQueued"]
[connection signal="MovementQueued" from="Movement Component" to="Internal/Sprite Animation Changer" method="OnMovementQueued"]
[connection signal="NoMovementQueued" from="Movement Component" to="Internal/State Event Connector" method="OnNoMovementQueued"]

File diff suppressed because it is too large Load Diff

View File

@@ -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()

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://nbkisxm2oekn"]
[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")

View File

@@ -1,6 +1,7 @@
extends StaticBody2D
class_name BaseChest
signal ChestOpened
signal OpeningAnimationStarted
@export var is_open := false
@@ -8,7 +9,12 @@ signal OpeningAnimationStarted
# Public Methods
func Open() -> void:
is_open = true
ChestOpened.emit()
func OpenAlreadyOpened() -> void:
pass
func SetOpenedFromLoad() -> void:
is_open = true

View File

@@ -27,6 +27,11 @@ func OpenAlreadyOpened() -> void:
already_opened_message_dialogue_trigger.Trigger()
func SetOpenedFromLoad() -> void:
super.SetOpenedFromLoad()
chest_01_sprite.play("opened")
# Private Methods
func _ready() -> void:
if is_open:

View File

@@ -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)

View File

@@ -1,5 +1,7 @@
extends StaticBody2D
signal Opened
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D
@@ -15,3 +17,5 @@ func OpenGate() -> void:
collision_shape_2d.set_deferred("disabled", true)
sprite.play("open")
Opened.emit()

View File

@@ -395,6 +395,6 @@ shape = SubResource("RectangleShape2D_5ttkm")
y_sort_enabled = true
position = Vector2(0, 15)
sprite_frames = SubResource("SpriteFrames_pki7h")
animation = &"closed"
animation = &"open"
autoplay = "closed"
offset = Vector2(0, -15)

View File

@@ -1,11 +0,0 @@
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()

View File

@@ -1 +0,0 @@
uid://ckfuj0lm6jv3i

View File

@@ -1,5 +1,5 @@
extends Node
class_name LoadingZoneTransporter
class_name EntranceTransporter
signal MapTransitionQueued(map_id: Enums.MapIds, marker_name: String)

View File

@@ -0,0 +1 @@
uid://bqedrioybnvi5

View File

@@ -1,8 +1,8 @@
extends Area2D
class_name InteractiveLoadingZone
class_name InteractiveEntrance
@export var loading_zone_transporter: LoadingZoneTransporter
@export var entrance_transporter: EntranceTransporter
# Public Methods
func Activate() -> void:
loading_zone_transporter.Activate()
entrance_transporter.Activate()

View File

@@ -1 +0,0 @@
uid://bvl1vdqd5cjkc

View File

@@ -1,9 +1,6 @@
[gd_scene format=3 uid="uid://ca75b65eh7vv8"]
[ext_resource type="Script" uid="uid://ckfuj0lm6jv3i" path="res://Entities/Map Objects/Loading Zone/Scripts/collision_loading_zone.gd" id="1_pb5hg"]
[gd_scene format=3 uid="uid://dq6ifketavnfu"]
[node name="Collision Loading Zone" type="Area2D" unique_id=1043800735 groups=["Collision Loading Zone Group"]]
collision_layer = 0
script = ExtResource("1_pb5hg")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://bbules4o3xayc"]
[ext_resource type="Script" uid="uid://bqedrioybnvi5" path="res://Entities/Map Objects/Loading Zone/Scripts/entrance_transporter.gd" id="1_bkamm"]
[node name="Entrance Transporter" type="Node" unique_id=1690817663 groups=["Loading Zone Transporter Group"]]
script = ExtResource("1_bkamm")

View File

@@ -1,6 +0,0 @@
[gd_scene format=3 uid="uid://bbules4o3xayc"]
[ext_resource type="Script" uid="uid://bvl1vdqd5cjkc" path="res://Entities/Map Objects/Loading Zone/Scripts/loading_zone_transporter.gd" id="1_p8o2m"]
[node name="Loading Zone Transporter" type="Node" unique_id=1690817663 groups=["Loading Zone Transporter Group"]]
script = ExtResource("1_p8o2m")

View File

@@ -4,6 +4,9 @@ extends Node2D
@export var spawn_markers: Node2D
@export var destination_markers: Node2D
# Debug
@export var should_log_schedule := false
@export_range(0.0, 60.0) var minimum_schedule_gap := 20.0
@export_range(1.0, 61.0) var maximum_schedule_gap := 60.0
@@ -25,7 +28,8 @@ func _ready() -> void:
# At spawn, we might want to spawn some leaves sooner...
_spawn_schedule -= randf_range(0.0, _spawn_schedule)
_spawn_schedule = max(0, _spawn_schedule)
print("%s - Leaf Spawn Schedule: %f" % [get_parent().name, _spawn_schedule])
_log_schedule()
func _process(delta: float) -> void:
@@ -33,6 +37,7 @@ func _process(delta: float) -> void:
if _spawn_timer >= _spawn_schedule:
_spawn_timer = 0.0
_set_random_spawn_schedule()
_log_schedule()
var spawn := _get_random_spawn_point()
var destination := _get_random_destination_point()
@@ -76,3 +81,8 @@ func _get_random_destination_point() -> Vector2:
var offset := Vector2(randf_range(-5.0, 5.0), randf_range(-5.0, 5.0))
return marker.position + offset
func _log_schedule() -> void:
if should_log_schedule:
print("%s - Leaf Spawn Schedule: %f" % [get_parent().name, _spawn_schedule])

View File

@@ -0,0 +1,4 @@
[gd_scene format=3 uid="uid://vc0dkptkr1ow"]
[node name="On Collision Trigger" type="Area2D" unique_id=895298999]
collision_layer = 0

BIN
Game Icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

40
Game Icon.png.import Normal file
View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ckbsqf4p5xu44"
path="res://.godot/imported/Game Icon.png-1ecac6caff9b7691e845293f1a955d2a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Game Icon.png"
dest_files=["res://.godot/imported/Game Icon.png-1ecac6caff9b7691e845293f1a955d2a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@@ -0,0 +1,8 @@
extends Node
# Public Methods
func GetMovementComponent(container: Node) -> MovementComponent:
for node in container.get_children():
if node is MovementComponent:
return node
return null

View File

@@ -0,0 +1 @@
uid://cf5j2r4gpceng

View File

@@ -11,23 +11,23 @@ func GetAllTreasureChests() -> Array[BaseChest]:
return arr
func GetAllInteractiveLoadingZones() -> Array[InteractiveLoadingZone]:
func GetAllInteractiveEntrances() -> Array[InteractiveEntrance]:
var nodes := get_tree().get_nodes_in_group("Interactive Loading Zone Group")
var arr: Array[InteractiveLoadingZone] = []
var arr: Array[InteractiveEntrance] = []
for node in nodes:
if node is InteractiveLoadingZone:
if node is InteractiveEntrance:
arr.append(node)
return arr
func GetAllLoadingZoneTransporters() -> Array[LoadingZoneTransporter]:
func GetAllLoadingZoneTransporters() -> Array[EntranceTransporter]:
var nodes := get_tree().get_nodes_in_group("Loading Zone Transporter Group")
var arr: Array[LoadingZoneTransporter] = []
var arr: Array[EntranceTransporter] = []
for node in nodes:
if node is LoadingZoneTransporter:
if node is EntranceTransporter:
arr.append(node)
return arr
@@ -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

View File

@@ -1,10 +1,14 @@
extends Node
const ERROR_404_MAP = preload("uid://durt8y2ovs6me")
const TITLE_SCREEN = preload("uid://be4nw563yydcr")
const HOME_01 = preload("uid://laxewy7irxno")
const PATH_TO_DUNGEON_01 = preload("uid://b07m0k40dh042")
const SHOP = preload("uid://bwt0ijoq4qmhn")
@onready var mapping := {
Enums.MapIds.ERROR_404: ERROR_404_MAP,
Enums.MapIds.TITLE_SCREEN: TITLE_SCREEN,
Enums.MapIds.SHOP_01: SHOP,
Enums.MapIds.PATH_TO_FOREST_DUNGEON_01: PATH_TO_DUNGEON_01,
Enums.MapIds.PATH_TO_FOREST_HOME_01: HOME_01

View File

@@ -1 +1,3 @@
extends CanvasLayer
const MAP_UI = preload("uid://ce6ix6ca6js5f")

View File

@@ -1,10 +1,26 @@
extends Node2D
#@export var initial_map: PackedScene
#
#@onready var world: Node2D = $World
#
## Called when the node enters the scene tree for the first time.
#func _ready() -> void:
#var map := initial_map.instantiate()
#world.add_child(map)
enum StartOptions {
TitleScreen,
InitialMap
}
@export var starting_scene := StartOptions.TitleScreen
@onready var map_transitioner: Node = $"Map Transitioner"
@onready var map_ui: Control = $"Gui/Map UI"
# Private Methods
func _ready() -> void:
match starting_scene:
StartOptions.TitleScreen:
map_transitioner.call_deferred("InstantiateTitleScreen")
StartOptions.InitialMap:
map_transitioner.call_deferred("InstantiateInitialMap")
func _on_map_changed(map_id: Enums.MapIds) -> void:
if map_id != Enums.MapIds.TITLE_SCREEN:
map_ui.set_deferred("visible", true)
else:
map_ui.set_deferred("visible", false)

View File

@@ -1,22 +1,45 @@
extends Node
signal GameStarted
signal MapChanged(map_id: Enums.MapIds)
@export var initial_map_id: Enums.MapIds
@onready var world: Node2D = $"../World"
# Private Methods
func _ready() -> void:
# Public Methods
func InstantiateTitleScreen() -> void:
var map_scene := MapLoader.GetMap(Enums.MapIds.TITLE_SCREEN)
var map := map_scene.instantiate()
world.add_child(map)
if !map.is_node_ready():
await map.ready
map.connect("GameStarted", _on_title_screen_game_started_clicked)
_connect_loading_zone_transporters()
MapChanged.emit(Enums.MapIds.TITLE_SCREEN)
func InstantiateInitialMap() -> void:
var map_scene := MapLoader.GetMap(initial_map_id)
var map := map_scene.instantiate()
world.add_child(map)
await map.ready
if !map.is_node_ready():
await map.ready
_connect_loading_zone_transporters()
MapChanged.emit(initial_map_id)
# Private Methods
func _on_title_screen_game_started_clicked() -> void:
GameStarted.emit()
_on_map_transition_queued(initial_map_id, "")
func _on_map_transition_queued(map_id: Enums.MapIds, marker_name: String) -> void:
print("Map Transition Queued: %s" % [Enums.MapIds.keys()[map_id]])
var map_scene := MapLoader.GetMap(map_id)

View File

@@ -0,0 +1,6 @@
extends Node
# Public Methods
func OnGameStarted() -> void:
print("Loading from disk")
PersistenceManager.LoadFromDisk(PersistenceManager.DEFAULT_SAVE_FILE_PATH)

View File

@@ -0,0 +1 @@
uid://bkvsdwn7swt1p

View File

@@ -5,18 +5,24 @@
[ext_resource type="Script" uid="uid://c4w8hney4mesw" path="res://Main/Scripts/gui.gd" id="3_8gbba"]
[ext_resource type="Script" uid="uid://dr7ljodtof1k5" path="res://Main/Scripts/map_transitioner.gd" id="3_kry3j"]
[ext_resource type="Script" uid="uid://cluyhxrc3pdb" path="res://Scripts/dialogue_trigger_connector.gd" id="4_6bp64"]
[ext_resource type="Script" uid="uid://bkvsdwn7swt1p" path="res://Main/Scripts/persistence_loader.gd" id="4_ib3t1"]
[ext_resource type="PackedScene" uid="uid://cxc4x4yp7l3hg" path="res://UI/dialogue_box.tscn" id="6_21xkr"]
[ext_resource type="PackedScene" uid="uid://ce6ix6ca6js5f" path="res://UI/Screens/map_ui.tscn" id="8_f6fdm"]
[node name="Main" type="Node2D" unique_id=1457826519]
script = ExtResource("1_jjgbg")
[node name="Map Transitioner" type="Node" parent="." unique_id=1528505665]
script = ExtResource("3_kry3j")
initial_map_id = 3
[node name="Dialogue Trigger Connector" type="Node" parent="." unique_id=1187622540 node_paths=PackedStringArray("dialogue_box")]
script = ExtResource("4_6bp64")
dialogue_box = NodePath("../Gui/Dialogue Box")
[node name="Persistence Loader" type="Node" parent="." unique_id=523510879]
script = ExtResource("4_ib3t1")
[node name="World" type="Node2D" parent="." unique_id=578440549]
script = ExtResource("2_bo1nx")
@@ -26,5 +32,10 @@ script = ExtResource("3_8gbba")
[node name="Dialogue Box" parent="Gui" unique_id=586562815 instance=ExtResource("6_21xkr")]
visible = false
[node name="Map UI" parent="Gui" unique_id=98184404 instance=ExtResource("8_f6fdm")]
visible = false
[connection signal="GameStarted" from="Map Transitioner" to="Persistence Loader" method="OnGameStarted"]
[connection signal="MapChanged" from="Map Transitioner" to="." method="_on_map_changed"]
[connection signal="MapChanged" from="Map Transitioner" to="Dialogue Trigger Connector" method="_on_map_changed"]
[connection signal="DialogueTriggered" from="Dialogue Trigger Connector" to="Gui/Dialogue Box" method="OnDialogueTriggered"]

View File

@@ -6,11 +6,11 @@
[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="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_transporter.tscn" id="6_t8w5b"]
[ext_resource type="PackedScene" uid="uid://vc0dkptkr1ow" path="res://Entities/Map Objects/Triggers/on_collision_trigger.tscn" id="7_6p5cp"]
[ext_resource type="Texture2D" uid="uid://bf6llktwqhs8l" path="res://Assets/Sprites/Door Fade.png" id="7_7ftpj"]
[ext_resource type="PackedScene" uid="uid://ca75b65eh7vv8" path="res://Entities/Map Objects/Loading Zone/collision_loading_zone.tscn" id="9_kp1fr"]
[sub_resource type="AtlasTexture" id="AtlasTexture_fdj0q"]
atlas = ExtResource("4_r8s0p")
@@ -42,9 +42,8 @@ script = ExtResource("1_83xsp")
[node name="Shop Item Notification Connector" type="Node" parent="." unique_id=1088308326]
script = ExtResource("2_r8s0p")
[node name="Spawn Marker Connector" type="Node" parent="." unique_id=2053338893 node_paths=PackedStringArray("player", "markers")]
[node name="Spawn Marker Connector" type="Node" parent="." unique_id=2053338893 node_paths=PackedStringArray("markers")]
script = ExtResource("3_t8w5b")
player = NodePath("../Player")
markers = NodePath("../Spawn Markers")
[node name="Tilemap" type="Node2D" parent="." unique_id=81778152]
@@ -100,14 +99,13 @@ debug_color = Color(0.9710676, 0.103622, 0.35069537, 0.41960785)
[node name="Loading Zones" type="Node2D" parent="." unique_id=525992692]
[node name="Collision Loading Zone" parent="Loading Zones" unique_id=1043800735 node_paths=PackedStringArray("loading_zone_transporter") instance=ExtResource("9_kp1fr")]
loading_zone_transporter = NodePath("Loading Zone Transporter")
[node name="On Collision Trigger" parent="Loading Zones" unique_id=895298999 instance=ExtResource("7_6p5cp")]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Loading Zones/Collision Loading Zone" unique_id=1798970421]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Loading Zones/On Collision Trigger" unique_id=1798970421]
position = Vector2(224, 243)
shape = SubResource("RectangleShape2D_kp1fr")
[node name="Loading Zone Transporter" parent="Loading Zones/Collision Loading Zone" unique_id=1690817663 instance=ExtResource("6_t8w5b")]
[node name="Loading Zone Transporter" parent="Loading Zones/On Collision Trigger" unique_id=1690817663 instance=ExtResource("6_t8w5b")]
destination_marker_name = "Shop Entrance"
[node name="Spawn Markers" type="Node2D" parent="." unique_id=680471197]
@@ -115,7 +113,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]
@@ -146,5 +144,4 @@ 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"]
[connection signal="body_entered" from="Loading Zones/On Collision Trigger" to="Loading Zones/On Collision Trigger/Loading Zone Transporter" method="Activate" unbinds=1]

View File

@@ -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)

View File

@@ -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()

View File

@@ -1,12 +1 @@
extends Node
@export var player: PlayerCharacter
# Public Methods
func OnPlayerAreaEntered(area: Area2D) -> void:
pass
# Private Methods
func _ready() -> void:
pass

View File

@@ -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()

View File

@@ -1,10 +1,12 @@
extends Node
@export var player: CharacterBody2D
@export var player_entity: Node2D
@export var markers: Node2D
# Public Methods
func _ready() -> void:
var body := player_entity.get_node("Player Body") as CharacterBody2D
var marker_name := MapLoader.GetSpawnMarker()
if !marker_name:
return
@@ -13,4 +15,4 @@ func _ready() -> void:
if child.name == marker_name:
var marker := child as Marker2D
var position := marker.global_position
player.position = position
body.position = position

File diff suppressed because one or more lines are too long

View File

@@ -3,14 +3,14 @@
[ext_resource type="Script" uid="uid://dbscr0b7k3rtp" path="res://Maps/Connectors/Scripts/collision_loading_zone_connector.gd" id="1_18bbf"]
[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://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_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="PackedScene" uid="uid://vc0dkptkr1ow" path="res://Entities/Map Objects/Triggers/on_collision_trigger.tscn" id="7_s4nwa"]
[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://c65cfm3t0obwq" path="res://Entities/Characters/Player/player_map_entity.tscn" id="11_s4nwa"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7kg22"]
size = Vector2(32, 8)
@@ -79,13 +79,12 @@ y_sort_enabled = true
[node name="Collision Loading Zone Connector" type="Node" parent="Connectors" unique_id=483597596]
script = ExtResource("1_18bbf")
[node name="Spawn Marker Connector" type="Node" parent="Connectors" unique_id=296643918 node_paths=PackedStringArray("player", "markers")]
[node name="Spawn Marker Connector" type="Node" parent="Connectors" unique_id=296643918 node_paths=PackedStringArray("player_entity", "markers")]
script = ExtResource("2_16uj4")
player = NodePath("../../Player")
player_entity = NodePath("../../Player Map Entity")
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")
[node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 instance=ExtResource("3_ec540")]
[node name="Tilemap" type="Node2D" parent="." unique_id=894627186]
y_sort_enabled = true
@@ -115,16 +114,17 @@ locked_message_dialogue_trigger = NodePath("Locked Dialogue Trigger")
[node name="Locked Dialogue Trigger" parent="Objects/Item Chest 02" unique_id=189867444 instance=ExtResource("5_msu6a")]
dialogue_name = "MSG_FOREST_DUNGEON_ENTRANCE_HOME_01_LOCKED_CHEST_01"
[node name="Loading Zones" type="Node2D" parent="." unique_id=1862302491]
[node name="Entrances" type="Node2D" parent="." unique_id=1862302491]
[node name="Collision Loading Zone" parent="Loading Zones" unique_id=1043800735 node_paths=PackedStringArray("loading_zone_transporter") instance=ExtResource("2_fdso5")]
loading_zone_transporter = NodePath("Loading Zone Transporter")
[node name="On Collision Trigger" parent="Entrances" unique_id=895298999 instance=ExtResource("7_s4nwa")]
collision_mask = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="Loading Zones/Collision Loading Zone" unique_id=2049955470]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Entrances/On Collision Trigger" unique_id=2049955470]
position = Vector2(80, 188)
shape = SubResource("RectangleShape2D_7kg22")
[node name="Loading Zone Transporter" parent="Loading Zones/Collision Loading Zone" unique_id=1690817663 instance=ExtResource("3_7kg22")]
[node name="Loading Zone Transporter" parent="Entrances/On Collision Trigger" unique_id=1690817663 instance=ExtResource("3_7kg22")]
destination_map_id = 2
destination_marker_name = "Home 01 Entrance"
[node name="Spawn Markers" type="Node2D" parent="." unique_id=1756787676]
@@ -153,15 +153,17 @@ 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="Overlay" type="Sprite2D" parent="." unique_id=455840170]
position = Vector2(124, 217)
scale = Vector2(0.25, 0.25)
texture = ExtResource("11_6xfm6")
offset = Vector2(16, -436)
[connection signal="body_entered" from="Entrances/On Collision Trigger" to="Entrances/On Collision Trigger/Loading Zone Transporter" method="Activate" unbinds=1]

View File

@@ -6,11 +6,12 @@
[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://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"]
[ext_resource type="PackedScene" uid="uid://did853bh5xeic" path="res://Maps/Connectors/spawn_marker_connector.tscn" id="5_lphfo"]
[ext_resource type="PackedScene" uid="uid://w4mh31se58f4" path="res://Persistence/Connectors/chest_persistence_connector.tscn" id="6_l5trr"]
[ext_resource type="PackedScene" uid="uid://c5ymu08jotbfp" path="res://Persistence/Connectors/gate_persistence_connector.tscn" id="7_0w1de"]
[ext_resource type="PackedScene" uid="uid://be6xfndyj4ckx" path="res://Entities/Map Objects/Trees/tree_02.tscn" id="7_ycf72"]
[ext_resource type="PackedScene" uid="uid://cc3qat6un2323" path="res://Entities/Map Objects/Trees/tree_01.tscn" id="8_yab5j"]
[ext_resource type="PackedScene" uid="uid://bcx1d8kvp7o0h" path="res://Entities/Map Objects/Trees/tree_03.tscn" id="9_lwurn"]
@@ -21,11 +22,13 @@
[ext_resource type="PackedScene" uid="uid://23tpba4r6ucg" path="res://Entities/Map Objects/Decorative/Outdoor/wooden_bench.tscn" id="14_kgsic"]
[ext_resource type="PackedScene" uid="uid://dwbg6wca6yl5j" path="res://Entities/Map Objects/Decorative/Signs/wooden_sign_01.tscn" id="16_dc5v0"]
[ext_resource type="PackedScene" uid="uid://c2p8fteeqyikf" path="res://Entities/Characters/Animals/Frog/npc_frog.tscn" id="18_tfw55"]
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="19_c5vrl"]
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_transporter.tscn" id="19_c5vrl"]
[ext_resource type="PackedScene" uid="uid://coaf2ndwb6h61" path="res://Entities/Map Objects/Decorative/Signs/wooden_sign_02.tscn" id="19_jtncl"]
[ext_resource type="PackedScene" uid="uid://cla2d3gii8qda" path="res://Entities/Map Objects/Loading Zone/interactive_loading_zone.tscn" id="20_c5vrl"]
[ext_resource type="PackedScene" uid="uid://b60nr4wfvijpf" path="res://Entities/Map Objects/Dialogue/dialogue_trigger.tscn" id="20_x6da4"]
[ext_resource type="PackedScene" uid="uid://c7rjjlamkqhnw" path="res://Debug/under_construction_block.tscn" id="26_4lnhp"]
[ext_resource type="PackedScene" uid="uid://c7rjjlamkqhnw" path="res://Debug/Utility Objects/under_construction_block.tscn" id="26_4lnhp"]
[ext_resource type="PackedScene" uid="uid://c65cfm3t0obwq" path="res://Entities/Characters/Player/player_map_entity.tscn" id="27_0w1de"]
[ext_resource type="Script" uid="uid://dtwxia7rlu5xt" path="res://Scripts/Utility/child_node_appender.gd" id="28_mf3dv"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lwurn"]
size = Vector2(768, 494)
@@ -63,30 +66,33 @@ size = Vector2(10, 7)
[node name="Map 01" type="Node2D" unique_id=411453136]
y_sort_enabled = true
[node name="Connectors" type="Node" parent="." unique_id=1365901208]
[node name="Map Connectors" type="Node" parent="." unique_id=1365901208]
[node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 node_paths=PackedStringArray("player") instance=ExtResource("1_jtncl")]
player = NodePath("../../Player")
[node name="Chest Interaction Connector" parent="Map Connectors" unique_id=625804018 instance=ExtResource("1_jtncl")]
[node name="Arrow Spawner" parent="Connectors" unique_id=627092886 node_paths=PackedStringArray("player", "arrow_parent") instance=ExtResource("2_jtncl")]
player = NodePath("../../Player")
arrow_parent = NodePath("../../Objects/Projectiles")
[node name="Arrow Spawner" parent="Map Connectors" unique_id=627092886 instance=ExtResource("2_jtncl")]
[node name="Bench Interaction Connector" parent="Connectors" unique_id=541204437 node_paths=PackedStringArray("player") instance=ExtResource("3_x6da4")]
player = NodePath("../../Player")
[node name="Bench Interaction Connector" parent="Map Connectors" unique_id=541204437 instance=ExtResource("3_x6da4")]
[node name="Interactive Loading Zone Connector" parent="Connectors" unique_id=833475826 node_paths=PackedStringArray("player") instance=ExtResource("4_4lnhp")]
player = NodePath("../../Player")
[node name="Interactive Loading Zone Connector" parent="Map Connectors" unique_id=833475826 instance=ExtResource("4_4lnhp")]
[node name="Spawn Marker Connector" parent="Connectors" unique_id=807187299 node_paths=PackedStringArray("player", "markers") instance=ExtResource("5_lphfo")]
player = NodePath("../../Player")
[node name="Spawn Marker Connector" parent="Map Connectors" unique_id=807187299 node_paths=PackedStringArray("player_entity", "markers") instance=ExtResource("5_lphfo")]
player_entity = NodePath("../../Player Map Entity")
markers = NodePath("../../Spawn Markers")
[node name="Persistence Connectors" type="Node" parent="." unique_id=1245900932]
[node name="Chest Persistence Connector" parent="Persistence Connectors" unique_id=281805027 instance=ExtResource("6_l5trr")]
chests = Array[NodePath]([NodePath("../../Objects/Chests/Item Chest 01 - 1"), NodePath("../../Objects/Chests/Item Chest 01 - 2"), NodePath("../../Objects/Chests/Item Chest 01 - 3")])
[node name="GatePersistenceConnector" parent="Persistence Connectors" unique_id=1082904286 instance=ExtResource("7_0w1de")]
gates = Array[NodePath]([NodePath("../../Objects/Spike Gate"), NodePath("../../Objects/Spike Gate2")])
[node name="Camera Limit Connector" type="Area2D" parent="." unique_id=1290795384 node_paths=PackedStringArray("camera_to_limit")]
collision_layer = 0
collision_mask = 0
script = ExtResource("3_ycf72")
camera_to_limit = NodePath("../Player/Camera2D")
camera_to_limit = NodePath("../Player Map Entity/Child Node Appender/Camera2D")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Camera Limit Connector" unique_id=456404995]
position = Vector2(384, 408)
@@ -331,7 +337,7 @@ position = Vector2(-1, -0.5)
shape = SubResource("RectangleShape2D_xrhbk")
[node name="Loading Zone Transporter" parent="Loading Zones/Shop Door" unique_id=1690817663 instance=ExtResource("19_c5vrl")]
destination_map_id = 1
destination_map_id = 3
destination_marker_name = "Entrance"
[node name="Spawn Markers" type="Node2D" parent="." unique_id=1420428815]
@@ -339,11 +345,13 @@ destination_marker_name = "Entrance"
[node name="Home 01 Entrance" type="Marker2D" parent="Spawn Markers" unique_id=1662896687]
position = Vector2(278, 474)
[node name="Player" parent="." unique_id=1502234578 instance=ExtResource("4_4igim")]
position = Vector2(89, 450)
[node name="Player Map Entity" parent="." unique_id=469362016 instance=ExtResource("27_0w1de")]
[node name="Camera2D" type="Camera2D" parent="Player" unique_id=1115720225]
position = Vector2(0, 1)
[node name="Child Node Appender" type="Node" parent="Player Map Entity" unique_id=1527392334]
script = ExtResource("28_mf3dv")
relative_path = "Player Body"
[node name="Camera2D" type="Camera2D" parent="Player Map Entity/Child Node Appender" unique_id=1115720225]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
@@ -385,7 +393,6 @@ position = Vector2(760, 312)
[node name="Under Construction Block12" parent="Debug" unique_id=1005752992 instance=ExtResource("26_4lnhp")]
position = Vector2(760, 328)
[connection signal="SitOnBenchTriggered" from="Connectors/Bench Interaction Connector" to="Player" method="OnSitOnFurnitureTriggered"]
[connection signal="TargetHit" from="Objects/ArrowTarget" to="Objects/Spike Gate" method="OpenGate"]
[connection signal="TargetHit" from="Objects/ArrowTarget" to="Objects/Spike Gate2" method="OpenGate"]
[connection signal="PressurePlateTripped" from="Objects/PressurePlate" to="Objects/Spike Gate" method="OpenGate"]

View File

@@ -0,0 +1,7 @@
extends Node2D
signal GameStarted
# Private Methods
func _on_start_game_button_pressed() -> void:
GameStarted.emit()

View File

@@ -0,0 +1 @@
uid://qv5i4xr6pldc

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
extends Node
@export var chests: Array[NodePath]
# Private Methods
func _ready() -> void:
for relative_node_path in chests:
var chest: BaseChest = get_node(relative_node_path)
var node_path := chest.get_path()
chest.ChestOpened.connect(func(): _on_chest_opened(chest))
if PersistenceManager.HasData(node_path):
var chest_opened: bool = PersistenceManager.GetData(node_path)
if chest_opened:
chest.call_deferred("SetOpenedFromLoad")
func _on_chest_opened(chest: BaseChest) -> void:
var node_path := chest.get_path()
PersistenceManager.UpdateData(node_path, true)

View File

@@ -0,0 +1 @@
uid://75g2fysjrqji

View File

@@ -0,0 +1,39 @@
extends Node
@export var gates: Array[NodePath]
# Private Methods
func _ready() -> void:
for node_path in gates:
_handle_spike_gate(node_path)
func _handle_spike_gate(node_path: NodePath) -> bool:
var node := get_node(node_path)
node_path = node.get_path()
if not node.name.begins_with("Spike Gate"):
return false
# Connect Signal
node.connect("Opened", func(): _on_spike_gate_opened(node))
if not PersistenceManager.HasData(node_path):
return true
var is_open: bool = PersistenceManager.GetData(node_path)
if not is_open:
return true
var collision_shape: CollisionShape2D = node.get_node("CollisionShape2D")
var animated_sprite: AnimatedSprite2D = node.get_node("AnimatedSprite2D")
node.set_deferred("is_open", true)
collision_shape.set_deferred("disabled", true)
animated_sprite.call_deferred("play", "open")
return true
func _on_spike_gate_opened(node: Node) -> void:
var path := node.get_path()
PersistenceManager.UpdateData(path, true)

View File

@@ -0,0 +1 @@
uid://brsiegtrne15y

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://w4mh31se58f4"]
[ext_resource type="Script" uid="uid://75g2fysjrqji" path="res://Persistence/Connectors/Scripts/chest_persistence_connector.gd" id="1_hytou"]
[node name="Chest Persistence Connector" type="Node" unique_id=281805027]
script = ExtResource("1_hytou")

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://c5ymu08jotbfp"]
[ext_resource type="Script" uid="uid://brsiegtrne15y" path="res://Persistence/Connectors/Scripts/gate_persistence_connector.gd" id="1_0smsr"]
[node name="GatePersistenceConnector" type="Node" unique_id=1082904286]
script = ExtResource("1_0smsr")

View File

@@ -0,0 +1,66 @@
extends Node
const DEFAULT_SAVE_FILE_PATH = "user://savegame.save"
var _save_file_path: String
var _save_dictionary: Dictionary = {}
# Public Methods
func UpdateData(key: String, value: Variant) -> void:
_save_dictionary[key] = value
func UpdateNode(node_path: NodePath, value: Variant) -> void:
UpdateData(str(node_path), value)
func GetData(key: String) -> Variant:
if not _save_dictionary.has(key):
return null
return _save_dictionary[key]
func GetNode(node_path: NodePath) -> Variant:
var key := str(node_path)
return GetData(key)
func HasData(node_path: NodePath) -> bool:
return _save_dictionary.has(node_path)
func SaveToDisk() -> void:
if !_save_file_path:
return
var save_file := FileAccess.open(_save_file_path, FileAccess.WRITE)
var json := JSON.stringify(_save_dictionary)
save_file.store_line(json)
func LoadFromDisk(save_file_path: String) -> void:
_save_file_path = save_file_path
if not FileAccess.file_exists(save_file_path):
print_rich("[color=yellow]Save file at path %s does not exist, creating new save file...[/color]" % save_file_path)
return
var save_file := FileAccess.open(save_file_path, FileAccess.READ)
print("Loading save file from path: %s" % save_file.get_path_absolute())
if save_file.get_position() >= save_file.get_length():
print("Save file was empty...")
return
var line := save_file.get_line()
var json = JSON.new()
var parse_result := json.parse(line)
if parse_result != OK:
print("Parsing result when loading file: [%s] in %s at line %d" % [json.get_error_message(), line, json.get_error_line()])
return
print("JSON data parsed: [%d]" % typeof(json.data))
var data_dict: Dictionary = json.data
_save_dictionary = data_dict

View File

@@ -0,0 +1 @@
uid://dl2kg1qu0ymi7

View File

@@ -782,6 +782,72 @@ texture = ExtResource("8_8d5h8")
1:1/animation_frame_6/duration = 0.3
1:1/animation_frame_7/duration = 0.3
1:1/0 = 0
0:3/animation_columns = 8
0:3/animation_separation = Vector2i(2, 0)
0:3/animation_frame_0/duration = 0.3
0:3/animation_frame_1/duration = 0.3
0:3/animation_frame_2/duration = 0.3
0:3/animation_frame_3/duration = 0.3
0:3/animation_frame_4/duration = 0.3
0:3/animation_frame_5/duration = 0.3
0:3/animation_frame_6/duration = 0.3
0:3/animation_frame_7/duration = 0.3
0:3/0 = 0
0:4/animation_columns = 8
0:4/animation_separation = Vector2i(2, 0)
0:4/animation_frame_0/duration = 0.3
0:4/animation_frame_1/duration = 0.3
0:4/animation_frame_2/duration = 0.3
0:4/animation_frame_3/duration = 0.3
0:4/animation_frame_4/duration = 0.3
0:4/animation_frame_5/duration = 0.3
0:4/animation_frame_6/duration = 0.3
0:4/animation_frame_7/duration = 0.3
0:4/0 = 0
1:4/animation_columns = 8
1:4/animation_separation = Vector2i(2, 0)
1:4/animation_frame_0/duration = 0.3
1:4/animation_frame_1/duration = 0.3
1:4/animation_frame_2/duration = 0.3
1:4/animation_frame_3/duration = 0.3
1:4/animation_frame_4/duration = 0.3
1:4/animation_frame_5/duration = 0.3
1:4/animation_frame_6/duration = 0.3
1:4/animation_frame_7/duration = 0.3
1:4/0 = 0
1:3/animation_columns = 8
1:3/animation_separation = Vector2i(2, 0)
1:3/animation_frame_0/duration = 0.3
1:3/animation_frame_1/duration = 0.3
1:3/animation_frame_2/duration = 0.3
1:3/animation_frame_3/duration = 0.3
1:3/animation_frame_4/duration = 0.3
1:3/animation_frame_5/duration = 0.3
1:3/animation_frame_6/duration = 0.3
1:3/animation_frame_7/duration = 0.3
1:3/0 = 0
2:3/animation_columns = 8
2:3/animation_separation = Vector2i(2, 0)
2:3/animation_frame_0/duration = 0.3
2:3/animation_frame_1/duration = 0.3
2:3/animation_frame_2/duration = 0.3
2:3/animation_frame_3/duration = 0.3
2:3/animation_frame_4/duration = 0.3
2:3/animation_frame_5/duration = 0.3
2:3/animation_frame_6/duration = 0.3
2:3/animation_frame_7/duration = 0.3
2:3/0 = 0
2:4/animation_columns = 8
2:4/animation_separation = Vector2i(2, 0)
2:4/animation_frame_0/duration = 0.3
2:4/animation_frame_1/duration = 0.3
2:4/animation_frame_2/duration = 0.3
2:4/animation_frame_3/duration = 0.3
2:4/animation_frame_4/duration = 0.3
2:4/animation_frame_5/duration = 0.3
2:4/animation_frame_6/duration = 0.3
2:4/animation_frame_7/duration = 0.3
2:4/0 = 0
[resource]
physics_layer_0/collision_layer = 1

View File

@@ -0,0 +1,26 @@
extends Node
# child_node_appender.gd
# All children of this node will be moved onto the node that is specified by
# provided path relative to the parent of this node
@export var relative_path: String
func _ready() -> void:
var parent := get_parent()
if parent == null:
push_error("Child Node Appender has no parent")
return
var node := parent.get_node_or_null(relative_path)
if node == null:
push_error("Provided path does not resolve to a node")
return
var children := get_children()
for child in children:
remove_child(child)
node.add_child(child)

View File

@@ -0,0 +1 @@
uid://dtwxia7rlu5xt

View File

@@ -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()

View File

@@ -17,6 +17,8 @@ enum Items {
}
enum MapIds {
ERROR_404,
TITLE_SCREEN,
PATH_TO_FOREST_DUNGEON_01,
PATH_TO_FOREST_HOME_01,
SHOP_01

13
Scripts/vector2_utils.gd Normal file
View File

@@ -0,0 +1,13 @@
extends Node
class_name Vector2Utils
static func GetClosestDirectionVector(dv: Vector2) -> Vector2:
if dv == Vector2.ZERO:
return dv
if dv.y < 0:
return Vector2.UP
if dv.y > 0:
return Vector2.DOWN
if dv.x < 0:
return Vector2.LEFT
return Vector2.RIGHT

View File

@@ -0,0 +1 @@
uid://b7tucdfjejupa

View File

@@ -0,0 +1,5 @@
extends Control
# Private Methods
func _on_save_button_pressed() -> void:
PersistenceManager.SaveToDisk()

View File

@@ -0,0 +1 @@
uid://dudh233xe7s0b

33
UI/Screens/map_ui.tscn Normal file
View File

@@ -0,0 +1,33 @@
[gd_scene format=3 uid="uid://ce6ix6ca6js5f"]
[ext_resource type="Texture2D" uid="uid://bo1utikr0r2q1" path="res://Assets/Spritesheets/Icons/UI/64x64.png" id="1_j6kbw"]
[ext_resource type="Script" uid="uid://dudh233xe7s0b" path="res://UI/Screens/Scripts/map_ui.gd" id="1_xiqit"]
[sub_resource type="AtlasTexture" id="AtlasTexture_xiqit"]
atlas = ExtResource("1_j6kbw")
region = Rect2(576, 0, 64, 64)
[node name="Map UI" type="Control" unique_id=98184404]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_xiqit")
[node name="Save Button" type="Button" parent="." unique_id=241739999]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -112.0
offset_top = -72.0
grow_horizontal = 0
grow_vertical = 0
text = "Save"
icon = SubResource("AtlasTexture_xiqit")
[connection signal="pressed" from="Save Button" to="." method="_on_save_button_pressed"]

View File

@@ -11,10 +11,10 @@ config_version=5
[application]
config/name="Archipelago Game"
config/version="beta-1.3"
config/version="beta-1.5"
run/main_scene="uid://dqgxg3i307lvr"
config/features=PackedStringArray("4.6", "Forward Plus")
config/icon="res://icon.svg"
config/icon="uid://ckbsqf4p5xu44"
[autoload]
@@ -23,6 +23,8 @@ GameManager="*uid://cb4tuxriixfqs"
GroupUtils="*uid://bk7o4drbfh24p"
MapLoader="*uid://c4jogxtdi3m13"
InputManager="*uid://dnbg1dpjcq6vk"
PersistenceManager="*uid://dl2kg1qu0ymi7"
ComponentUtils="*uid://cf5j2r4gpceng"
[dotnet]
@@ -37,6 +39,7 @@ folder_colors={
"res://Global Managers/": "red",
"res://Main/": "gray",
"res://Maps/": "green",
"res://Persistence/": "blue",
"res://Resources/": "orange",
"res://Scripts/": "red",
"res://UI/": "yellow"
@@ -74,6 +77,7 @@ locale/translations=PackedStringArray("res://Resources/Dialogue/Archipelago Game
2d_physics/layer_2="Interaction"
2d_physics/layer_3="Projectile Collision"
2d_physics/layer_4="Occlusion"
2d_physics/layer_5="Entrance"
[physics]