Compare commits

...

3 Commits

75 changed files with 1474 additions and 2432 deletions

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,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"] [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") 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 @export var state_machine: PlayerStateMachine
var _subscribed_events: Array[String] = []
var _subscribed_events_callables: Array[Callable] = []
func GetStateEnum() -> PlayerStateMachine.States: func GetStateEnum() -> PlayerStateMachine.States:
push_error("Unimplemented Method: BaseState.GetName") push_error("Unimplemented Method: BaseState.GetStateEnum")
return PlayerStateMachine.States.IDLE return PlayerStateMachine.States.IDLE
@@ -31,3 +34,23 @@ func IsActive() -> bool:
func IsStateActionable() -> bool: func IsStateActionable() -> bool:
return true 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 signal PlayerBeganDrawingBow
@export var strafing_speed := 35 @export var strafing_speed := 35
@export var movement_componenent: MovementComponent
@export var body: CharacterBody2D @export var body: CharacterBody2D
var used_item_action: String var _used_item_action: String
var animation_finished := false var _animation_finished := false
var _movement_componenent: MovementComponent
func GetStateEnum() -> PlayerStateMachine.States: func GetStateEnum() -> PlayerStateMachine.States:
return PlayerStateMachine.States.DRAWING_BOW return PlayerStateMachine.States.DRAWING_BOW
func Enter(extra_parameters: Dictionary) -> void: func Enter(extra_parameters: Dictionary) -> void:
animation_finished = false _animation_finished = false
used_item_action = extra_parameters.action_name _used_item_action = extra_parameters.action_name
_movement_componenent = ComponentUtils.GetMovementComponent(body)
PlayerBeganDrawingBow.emit() PlayerBeganDrawingBow.emit()
func Update(_delta: float) -> void: func Update(_delta: float) -> void:
if !animation_finished: if !_animation_finished:
return return
if !Input.is_action_pressed(used_item_action): if !Input.is_action_pressed(_used_item_action):
state_machine.QueueStateChange(PlayerStateMachine.States.FIRING_ARROW) state_machine.QueueStateChange(PlayerStateMachine.States.FIRING_ARROW)
return return
var movement_vector := movement_componenent.movement_vector var movement_vector := _movement_componenent.movement_vector
if movement_vector != Vector2.ZERO: if movement_vector != Vector2.ZERO:
body.velocity = movement_vector * strafing_speed body.velocity = movement_vector * strafing_speed
body.move_and_slide() body.move_and_slide()
func OnDrawingBowAnimationFinished() -> void: func OnDrawingBowAnimationFinished() -> void:
animation_finished = true _animation_finished = true

View File

@@ -1,47 +1,14 @@
extends BaseState 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 func OnMovementQueued(dv: Vector2) -> void:
var _sit_queue_dir: Enums.Directions state_machine.QueueStateChange(PlayerStateMachine.States.WALKING, {"dv": dv})
func GetStateEnum() -> PlayerStateMachine.States: func GetStateEnum() -> PlayerStateMachine.States:
return PlayerStateMachine.States.IDLE 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 extends BaseState
# walking_state.gd
signal StartedWalking signal StartedWalking
@export var walking_speed := 100 @export var walking_speed := 100
@export var movement_component: MovementComponent
@export var direction_component: FacingDirectionComponent
@export var body: CharacterBody2D @export var body: CharacterBody2D
func GetStateEnum() -> PlayerStateMachine.States: var _queued_dv: Vector2
return PlayerStateMachine.States.WALKING
func _ready() -> void:
SubscribeToEvent("MovementQueued", OnMovementQueued)
SubscribeToEvent("NoMovementQueued", OnNoMovementQueued)
func Enter(_extra_parameters: Dictionary) -> void: func Enter(_extra_parameters: Dictionary) -> void:
_queued_dv = _extra_parameters["dv"]
StartedWalking.emit() StartedWalking.emit()
func Update(_delta: float) -> void: func Update(_delta: float) -> void:
if movement_component.movement_vector == Vector2.ZERO: if _queued_dv == Vector2.ZERO:
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE) state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
return return
var movement_vector := movement_component.movement_vector body.velocity = _queued_dv * walking_speed
body.velocity = movement_vector * walking_speed
body.move_and_slide() 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 extends AnimatedSprite2D
class_name PlayerSprite
# Signals # sprite.gd
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

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 extends Node
class_name PlayerStateMachine class_name PlayerStateMachine
signal StateChanged signal StateChanged(to_state: States, from_state: States)
enum States { enum States {
UNSET, IDLE, WALKING, USING_ITEM_A, DRAWING_BOW, FIRING_ARROW, 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 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. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
var children := states_container.get_children() var children := states_container.get_children()
@@ -47,6 +52,9 @@ func _process(delta: float) -> void:
func _swap_state() -> void: func _swap_state() -> void:
var from_state := current_state.GetStateEnum()
var to_state := queued_state
if current_state: if current_state:
current_state.Exit() current_state.Exit()
@@ -55,4 +63,4 @@ func _swap_state() -> void:
queued_state = PlayerStateMachine.States.UNSET queued_state = PlayerStateMachine.States.UNSET
queued_parameters = {} 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,22 +1,21 @@
extends Node extends Node
#extends Node
# Exports #
@export var player: PlayerCharacter ## Exports
@export var arrow_parent: Node2D #@export var arrow_parent: Node2D
#
# Preloads ## Preloads
const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx") #const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx")
#
# Private Methods ## Private Methods
func _ready() -> void: #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)
firing_arrow_state.ArrowFired.connect(_on_arrow_fired) #
#
#func _on_arrow_fired(fire_position: Vector2, direction: Vector2) -> void:
func _on_arrow_fired(fire_position: Vector2, direction: Vector2) -> void: #var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile
var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile #wooden_arrow.SetProjectileStartAndDirection(fire_position, direction)
wooden_arrow.SetProjectileStartAndDirection(fire_position, direction) #
#if arrow_parent == null:
if arrow_parent == null: #return
return #arrow_parent.add_child(wooden_arrow)
arrow_parent.add_child(wooden_arrow)

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 extends Node
class_name LoadingZoneTransporter class_name EntranceTransporter
signal MapTransitionQueued(map_id: Enums.MapIds, marker_name: String) signal MapTransitionQueued(map_id: Enums.MapIds, marker_name: String)

View File

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

View File

@@ -1,8 +1,8 @@
extends Area2D extends Area2D
class_name InteractiveLoadingZone class_name InteractiveEntrance
@export var loading_zone_transporter: LoadingZoneTransporter @export var entrance_transporter: EntranceTransporter
# Public Methods # Public Methods
func Activate() -> void: 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"] [gd_scene format=3 uid="uid://dq6ifketavnfu"]
[ext_resource type="Script" uid="uid://ckfuj0lm6jv3i" path="res://Entities/Map Objects/Loading Zone/Scripts/collision_loading_zone.gd" id="1_pb5hg"]
[node name="Collision Loading Zone" type="Area2D" unique_id=1043800735 groups=["Collision Loading Zone Group"]] [node name="Collision Loading Zone" type="Area2D" unique_id=1043800735 groups=["Collision Loading Zone Group"]]
collision_layer = 0 collision_layer = 0
script = ExtResource("1_pb5hg")
[connection signal="body_entered" from="." to="." method="_on_body_entered"] [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

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

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 return arr
func GetAllInteractiveLoadingZones() -> Array[InteractiveLoadingZone]: func GetAllInteractiveEntrances() -> Array[InteractiveEntrance]:
var nodes := get_tree().get_nodes_in_group("Interactive Loading Zone Group") var nodes := get_tree().get_nodes_in_group("Interactive Loading Zone Group")
var arr: Array[InteractiveLoadingZone] = [] var arr: Array[InteractiveEntrance] = []
for node in nodes: for node in nodes:
if node is InteractiveLoadingZone: if node is InteractiveEntrance:
arr.append(node) arr.append(node)
return arr return arr
func GetAllLoadingZoneTransporters() -> Array[LoadingZoneTransporter]: func GetAllLoadingZoneTransporters() -> Array[EntranceTransporter]:
var nodes := get_tree().get_nodes_in_group("Loading Zone Transporter Group") var nodes := get_tree().get_nodes_in_group("Loading Zone Transporter Group")
var arr: Array[LoadingZoneTransporter] = [] var arr: Array[EntranceTransporter] = []
for node in nodes: for node in nodes:
if node is LoadingZoneTransporter: if node is EntranceTransporter:
arr.append(node) arr.append(node)
return arr return arr
@@ -45,9 +45,9 @@ func GetAllDialogueTriggers() -> Array[DialogueTrigger]:
return arr return arr
func GetPlayer() -> PlayerCharacter: func GetPlayerBody() -> CharacterBody2D:
var nodes := get_tree().get_nodes_in_group("Player Group") var nodes := get_tree().get_nodes_in_group("Player Group")
if nodes.is_empty(): if nodes.is_empty():
return null return null
return nodes[0] as PlayerCharacter return nodes[0] as CharacterBody2D

View File

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

View File

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

View File

@@ -1,10 +1,26 @@
extends Node2D extends Node2D
#@export var initial_map: PackedScene enum StartOptions {
# TitleScreen,
#@onready var world: Node2D = $World InitialMap
# }
## Called when the node enters the scene tree for the first time.
#func _ready() -> void: @export var starting_scene := StartOptions.TitleScreen
#var map := initial_map.instantiate()
#world.add_child(map) @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 extends Node
signal GameStarted
signal MapChanged(map_id: Enums.MapIds) signal MapChanged(map_id: Enums.MapIds)
@export var initial_map_id: Enums.MapIds @export var initial_map_id: Enums.MapIds
@onready var world: Node2D = $"../World" @onready var world: Node2D = $"../World"
# Private Methods # Public Methods
func _ready() -> void: 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_scene := MapLoader.GetMap(initial_map_id)
var map := map_scene.instantiate() var map := map_scene.instantiate()
world.add_child(map) world.add_child(map)
if !map.is_node_ready():
await map.ready await map.ready
_connect_loading_zone_transporters() _connect_loading_zone_transporters()
MapChanged.emit(initial_map_id) 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: func _on_map_transition_queued(map_id: Enums.MapIds, marker_name: String) -> void:
print("Map Transition Queued: %s" % [Enums.MapIds.keys()[map_id]]) print("Map Transition Queued: %s" % [Enums.MapIds.keys()[map_id]])
var map_scene := MapLoader.GetMap(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://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://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://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://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] [node name="Main" type="Node2D" unique_id=1457826519]
script = ExtResource("1_jjgbg") script = ExtResource("1_jjgbg")
[node name="Map Transitioner" type="Node" parent="." unique_id=1528505665] [node name="Map Transitioner" type="Node" parent="." unique_id=1528505665]
script = ExtResource("3_kry3j") script = ExtResource("3_kry3j")
initial_map_id = 3
[node name="Dialogue Trigger Connector" type="Node" parent="." unique_id=1187622540 node_paths=PackedStringArray("dialogue_box")] [node name="Dialogue Trigger Connector" type="Node" parent="." unique_id=1187622540 node_paths=PackedStringArray("dialogue_box")]
script = ExtResource("4_6bp64") script = ExtResource("4_6bp64")
dialogue_box = NodePath("../Gui/Dialogue Box") 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] [node name="World" type="Node2D" parent="." unique_id=578440549]
script = ExtResource("2_bo1nx") 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")] [node name="Dialogue Box" parent="Gui" unique_id=586562815 instance=ExtResource("6_21xkr")]
visible = false 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="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"] [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="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="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="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="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="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"] [sub_resource type="AtlasTexture" id="AtlasTexture_fdj0q"]
atlas = ExtResource("4_r8s0p") atlas = ExtResource("4_r8s0p")
@@ -42,9 +42,8 @@ script = ExtResource("1_83xsp")
[node name="Shop Item Notification Connector" type="Node" parent="." unique_id=1088308326] [node name="Shop Item Notification Connector" type="Node" parent="." unique_id=1088308326]
script = ExtResource("2_r8s0p") 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") script = ExtResource("3_t8w5b")
player = NodePath("../Player")
markers = NodePath("../Spawn Markers") markers = NodePath("../Spawn Markers")
[node name="Tilemap" type="Node2D" parent="." unique_id=81778152] [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="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")] [node name="On Collision Trigger" parent="Loading Zones" unique_id=895298999 instance=ExtResource("7_6p5cp")]
loading_zone_transporter = NodePath("Loading Zone Transporter")
[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) position = Vector2(224, 243)
shape = SubResource("RectangleShape2D_kp1fr") 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" destination_marker_name = "Shop Entrance"
[node name="Spawn Markers" type="Node2D" parent="." unique_id=680471197] [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] [node name="Shop Entrance" type="Marker2D" parent="Spawn Markers" unique_id=122141189]
position = Vector2(223, 225) 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) position = Vector2(289, 174)
[node name="Camera2D" type="Camera2D" parent="." unique_id=1684491254] [node name="Camera2D" type="Camera2D" parent="." unique_id=1684491254]
@@ -146,5 +144,4 @@ position = Vector2(224, 232)
scale = Vector2(2, 1) scale = Vector2(2, 1)
texture = ExtResource("7_7ftpj") texture = ExtResource("7_7ftpj")
[connection signal="InteractScannerAreaEntered" from="Player" to="Shop Item Notification Connector" method="OnPlayerInteractScannerAreaEntered"] [connection signal="body_entered" from="Loading Zones/On Collision Trigger" to="Loading Zones/On Collision Trigger/Loading Zone Transporter" method="Activate" unbinds=1]
[connection signal="InteractScannerAreaExited" from="Player" to="Shop Item Notification Connector" method="OnPlayerInteractScannerAreaExited"]

View File

@@ -1,54 +1,54 @@
extends Node extends Node
class_name BenchInteractionConnector #class_name BenchInteractionConnector
#
# Signals ## Signals
signal SitOnBenchTriggered(position: Vector2, sitting_direction: Enums.Directions) #signal SitOnBenchTriggered(position: Vector2, sitting_direction: Enums.Directions)
#
# Exports ## Exports
@export var player: PlayerCharacter #@export var player: PlayerBody
#
# Private Variables ## Private Variables
var _benches_in_range: Array[WoodenBench] = [] #var _benches_in_range: Array[WoodenBench] = []
#
# Private Methods ## Private Methods
func _ready() -> void: #func _ready() -> void:
player.interact_scanner.area_entered.connect(_on_interact_scanned) #player.interact_scanner.area_entered.connect(_on_interact_scanned)
player.interact_scanner.area_exited.connect(_on_interact_unscanned) #player.interact_scanner.area_exited.connect(_on_interact_unscanned)
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered) #player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
#
#
func _on_interact_scanned(area: Area2D) -> void: #func _on_interact_scanned(area: Area2D) -> void:
var parent := area.get_parent() #var parent := area.get_parent()
if parent == null or parent is not WoodenBench or _benches_in_range.has(parent): #if parent == null or parent is not WoodenBench or _benches_in_range.has(parent):
return #return
_benches_in_range.append(parent) #_benches_in_range.append(parent)
#
#
func _on_interact_unscanned(area: Area2D) -> void: #func _on_interact_unscanned(area: Area2D) -> void:
var parent: Node = area.get_parent() #var parent: Node = area.get_parent()
if parent == null or parent is not WoodenBench or !_benches_in_range.has(parent): #if parent == null or parent is not WoodenBench or !_benches_in_range.has(parent):
return #return
_benches_in_range.erase(parent) #_benches_in_range.erase(parent)
#
#
func _on_interact_triggered() -> void: #func _on_interact_triggered() -> void:
if _benches_in_range.is_empty(): #if _benches_in_range.is_empty():
return #return
#
var bench := _benches_in_range[0] #var bench := _benches_in_range[0]
var sitting_spots_container := bench.get_node("Sitting Spots") as Node2D #var sitting_spots_container := bench.get_node("Sitting Spots") as Node2D
var sitting_spot_markers := sitting_spots_container.get_children() #var sitting_spot_markers := sitting_spots_container.get_children()
#
var closest_marker: Marker2D #var closest_marker: Marker2D
var distance_to_player := 9999.0 #var distance_to_player := 9999.0
for node in sitting_spot_markers: #for node in sitting_spot_markers:
var marker := node as Marker2D #var marker := node as Marker2D
var distance := marker.global_position.distance_to(player.global_position) #var distance := marker.global_position.distance_to(player.global_position)
if distance < distance_to_player: #if distance < distance_to_player:
closest_marker = marker #closest_marker = marker
distance_to_player = distance #distance_to_player = distance
#
if !closest_marker: #if !closest_marker:
return #return
#
player.SitOnFurnitureTriggered.emit(closest_marker.global_position, Enums.Directions.DOWN) #player.SitOnFurnitureTriggered.emit(closest_marker.global_position, Enums.Directions.DOWN)

View File

@@ -4,73 +4,65 @@ extends Node
signal OpeningOfOpenedChestAttempted signal OpeningOfOpenedChestAttempted
# Exports # Exports
@export var player: PlayerCharacter
@export var auto_connect_all_chests := true @export var auto_connect_all_chests := true
# Private Variables # Private Variables
var _chests_in_range: Array[BaseChest] = [] var _chests_in_range: Array[BaseChest] = []
# Private Methods ## Private Methods
func _ready() -> void: #func _ready() -> void:
player.interact_scanner.area_entered.connect(_on_interact_scanned) #var chests := GroupUtils.GetAllTreasureChests()
player.interact_scanner.area_exited.connect(_on_interact_unscanned) #for chest in chests:
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered) #chest.OpeningAnimationStarted.connect(_on_chest_opening_animation_started)
#
var chests := GroupUtils.GetAllTreasureChests() #
for chest in chests: #func _on_chest_opening_animation_started() -> void:
chest.OpeningAnimationStarted.connect(_on_chest_opening_animation_started) #player.QueueCutsceneState()
#
#var camera_idx := children.find_custom(func(x): return x is Camera2D)
func _on_chest_opening_animation_started() -> void: #if camera_idx == -1: return
var player := GroupUtils.GetPlayer() #
var children := player.get_children() ## Zoom In
#var camera := children[camera_idx] as Camera2D
player.QueueCutsceneState() #var current_zoom := camera.zoom
#await get_tree().create_tween().tween_property(camera, "zoom", current_zoom + Vector2(2, 2), 0.5).finished
var camera_idx := children.find_custom(func(x): return x is Camera2D) #
if camera_idx == -1: return ## Player the player's chest opening animation
#player.state_machine.QueueStateChange(PlayerStateMachine.States.PLAY_ANIMATION, { "animation_name": "opening-chest-down" })
# Zoom In #await player.state_machine.StateChanged
var camera := children[camera_idx] as Camera2D #var play_animation_state := player.state_machine.current_state as PlayerPlayAnimationState
var current_zoom := camera.zoom #await play_animation_state.AnimationFinished
await get_tree().create_tween().tween_property(camera, "zoom", current_zoom + Vector2(2, 2), 0.5).finished #player.state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
#
# Player the player's chest opening animation ## Zoom back out
player.state_machine.QueueStateChange(PlayerStateMachine.States.PLAY_ANIMATION, { "animation_name": "opening-chest-down" }) #await get_tree().create_tween().tween_property(camera, "zoom", current_zoom, 0.5).finished
await player.state_machine.StateChanged #
var play_animation_state := player.state_machine.current_state as PlayerPlayAnimationState #
await play_animation_state.AnimationFinished #func _on_interact_scanned(area: Area2D) -> void:
player.state_machine.QueueStateChange(PlayerStateMachine.States.IDLE) #var chest = area.get_parent()
#if chest == null or chest is not BaseChest:
# Zoom back out #return
await get_tree().create_tween().tween_property(camera, "zoom", current_zoom, 0.5).finished #if _chests_in_range.has(chest):
#return
#_chests_in_range.append(chest)
func _on_interact_scanned(area: Area2D) -> void: #
var chest = area.get_parent() #
if chest == null or chest is not BaseChest: #func _on_interact_unscanned(area: Area2D) -> void:
return #var chest = area.get_parent()
if _chests_in_range.has(chest): #if chest == null or chest is not BaseChest:
return #return
_chests_in_range.append(chest) #if !_chests_in_range.has(chest):
#return
#_chests_in_range.erase(chest)
func _on_interact_unscanned(area: Area2D) -> void: #
var chest = area.get_parent() #
if chest == null or chest is not BaseChest: #func _on_interact_triggered() -> void:
return #if _chests_in_range.is_empty():
if !_chests_in_range.has(chest): #return
return #
_chests_in_range.erase(chest) #var chest := _chests_in_range[0]
#if !chest.is_open:
#chest.Open()
func _on_interact_triggered() -> void: #else:
if _chests_in_range.is_empty(): #chest.OpenAlreadyOpened()
return #OpeningOfOpenedChestAttempted.emit()
var chest := _chests_in_range[0]
if !chest.is_open:
chest.Open()
else:
chest.OpenAlreadyOpened()
OpeningOfOpenedChestAttempted.emit()

View File

@@ -1,12 +1 @@
extends Node 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 extends Node
#
# Exports ## Exports
@export var player: PlayerCharacter #@export var player: PlayerBody
#
# Private Variables ## Private Variables
var _zones_in_range: Array[InteractiveLoadingZone] = [] #var _zones_in_range: Array[InteractiveLoadingZone] = []
#
# Private Methods ## Private Methods
func _ready() -> void: #func _ready() -> void:
player.interact_scanner.area_entered.connect(_on_interact_scanned) #player.interact_scanner.area_entered.connect(_on_interact_scanned)
player.interact_scanner.area_exited.connect(_on_interact_unscanned) #player.interact_scanner.area_exited.connect(_on_interact_unscanned)
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered) #player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered)
#
#
func _on_interact_scanned(area: Area2D) -> void: #func _on_interact_scanned(area: Area2D) -> void:
if area is not InteractiveLoadingZone or _zones_in_range.has(area): #if area is not InteractiveLoadingZone or _zones_in_range.has(area):
return #return
#
_zones_in_range.append(area) #_zones_in_range.append(area)
#
#
func _on_interact_unscanned(area: Area2D) -> void: #func _on_interact_unscanned(area: Area2D) -> void:
if area is not InteractiveLoadingZone or !_zones_in_range.has(area): #if area is not InteractiveLoadingZone or !_zones_in_range.has(area):
return #return
#
_zones_in_range.erase(area) #_zones_in_range.erase(area)
#
#
func _on_interact_triggered() -> void: #func _on_interact_triggered() -> void:
if _zones_in_range.is_empty(): #if _zones_in_range.is_empty():
return #return
#
var zone := _zones_in_range[0] #var zone := _zones_in_range[0]
zone.Activate() #zone.Activate()

View File

@@ -1,10 +1,12 @@
extends Node extends Node
@export var player: CharacterBody2D @export var player_entity: Node2D
@export var markers: Node2D @export var markers: Node2D
# Public Methods # Public Methods
func _ready() -> void: func _ready() -> void:
var body := player_entity.get_node("Player Body") as CharacterBody2D
var marker_name := MapLoader.GetSpawnMarker() var marker_name := MapLoader.GetSpawnMarker()
if !marker_name: if !marker_name:
return return
@@ -13,4 +15,4 @@ func _ready() -> void:
if child.name == marker_name: if child.name == marker_name:
var marker := child as Marker2D var marker := child as Marker2D
var position := marker.global_position 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="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="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="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://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/entrance_transporter.tscn" id="3_7kg22"]
[ext_resource type="PackedScene" uid="uid://6athlweutl2g" path="res://Entities/Characters/Player/player.tscn" id="2_lky26"]
[ext_resource type="PackedScene" uid="uid://bbules4o3xayc" path="res://Entities/Map Objects/Loading Zone/loading_zone_transporter.tscn" id="3_7kg22"]
[ext_resource type="PackedScene" uid="uid://dl2jpjtbiju34" path="res://Maps/Connectors/chest_interaction_connector.tscn" id="3_ec540"] [ext_resource type="PackedScene" uid="uid://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://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="PackedScene" uid="uid://b60nr4wfvijpf" path="res://Entities/Map Objects/Dialogue/dialogue_trigger.tscn" id="5_msu6a"]
[ext_resource type="Texture2D" uid="uid://bm5ewxv51potl" path="res://Assets/Spritesheets/NPCs/Miner_Mike.png" id="6_x3y8m"] [ext_resource type="Texture2D" uid="uid://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="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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_7kg22"]
size = Vector2(32, 8) 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] [node name="Collision Loading Zone Connector" type="Node" parent="Connectors" unique_id=483597596]
script = ExtResource("1_18bbf") 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") script = ExtResource("2_16uj4")
player = NodePath("../../Player") player_entity = NodePath("../../Player Map Entity")
markers = NodePath("../../Spawn Markers") markers = NodePath("../../Spawn Markers")
[node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 node_paths=PackedStringArray("player") instance=ExtResource("3_ec540")] [node name="Chest Interaction Connector" parent="Connectors" unique_id=625804018 instance=ExtResource("3_ec540")]
player = NodePath("../../Player")
[node name="Tilemap" type="Node2D" parent="." unique_id=894627186] [node name="Tilemap" type="Node2D" parent="." unique_id=894627186]
y_sort_enabled = true 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")] [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" 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")] [node name="On Collision Trigger" parent="Entrances" unique_id=895298999 instance=ExtResource("7_s4nwa")]
loading_zone_transporter = NodePath("Loading Zone Transporter") 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) position = Vector2(80, 188)
shape = SubResource("RectangleShape2D_7kg22") 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" destination_marker_name = "Home 01 Entrance"
[node name="Spawn Markers" type="Node2D" parent="." unique_id=1756787676] [node name="Spawn Markers" type="Node2D" parent="." unique_id=1756787676]
@@ -153,15 +153,17 @@ position = Vector2(-0.5, -4)
shape = SubResource("RectangleShape2D_6xfm6") shape = SubResource("RectangleShape2D_6xfm6")
debug_color = Color(0.7930861, 0.42714188, 7.70092e-07, 0.41960785) 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] [node name="Camera2D" type="Camera2D" parent="." unique_id=2134984506]
position = Vector2(127, 110) position = Vector2(127, 110)
zoom = Vector2(3, 3) 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] [node name="Overlay" type="Sprite2D" parent="." unique_id=455840170]
position = Vector2(124, 217) position = Vector2(124, 217)
scale = Vector2(0.25, 0.25) scale = Vector2(0.25, 0.25)
texture = ExtResource("11_6xfm6") texture = ExtResource("11_6xfm6")
offset = Vector2(16, -436) 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,7 +6,6 @@
[ext_resource type="PackedScene" uid="uid://303hbhqetdhy" path="res://Maps/Connectors/arrow_spawner.tscn" id="2_jtncl"] [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="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="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://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="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="Texture2D" uid="uid://bf6llktwqhs8l" path="res://Assets/Sprites/Door Fade.png" id="5_jett5"]
@@ -23,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://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://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://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://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://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://b60nr4wfvijpf" path="res://Entities/Map Objects/Dialogue/dialogue_trigger.tscn" id="20_x6da4"]
[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://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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_lwurn"]
size = Vector2(768, 494) size = Vector2(768, 494)
@@ -67,21 +68,16 @@ y_sort_enabled = true
[node name="Map Connectors" type="Node" parent="." unique_id=1365901208] [node name="Map Connectors" type="Node" parent="." unique_id=1365901208]
[node name="Chest Interaction Connector" parent="Map Connectors" unique_id=625804018 node_paths=PackedStringArray("player") instance=ExtResource("1_jtncl")] [node name="Chest Interaction Connector" parent="Map Connectors" unique_id=625804018 instance=ExtResource("1_jtncl")]
player = NodePath("../../Player")
[node name="Arrow Spawner" parent="Map Connectors" unique_id=627092886 node_paths=PackedStringArray("player", "arrow_parent") instance=ExtResource("2_jtncl")] [node name="Arrow Spawner" parent="Map Connectors" unique_id=627092886 instance=ExtResource("2_jtncl")]
player = NodePath("../../Player")
arrow_parent = NodePath("../../Objects/Projectiles")
[node name="Bench Interaction Connector" parent="Map Connectors" unique_id=541204437 node_paths=PackedStringArray("player") instance=ExtResource("3_x6da4")] [node name="Bench Interaction Connector" parent="Map Connectors" unique_id=541204437 instance=ExtResource("3_x6da4")]
player = NodePath("../../Player")
[node name="Interactive Loading Zone Connector" parent="Map Connectors" unique_id=833475826 node_paths=PackedStringArray("player") instance=ExtResource("4_4lnhp")] [node name="Interactive Loading Zone Connector" parent="Map Connectors" unique_id=833475826 instance=ExtResource("4_4lnhp")]
player = NodePath("../../Player")
[node name="Spawn Marker Connector" parent="Map Connectors" unique_id=807187299 node_paths=PackedStringArray("player", "markers") instance=ExtResource("5_lphfo")] [node name="Spawn Marker Connector" parent="Map Connectors" unique_id=807187299 node_paths=PackedStringArray("player_entity", "markers") instance=ExtResource("5_lphfo")]
player = NodePath("../../Player") player_entity = NodePath("../../Player Map Entity")
markers = NodePath("../../Spawn Markers") markers = NodePath("../../Spawn Markers")
[node name="Persistence Connectors" type="Node" parent="." unique_id=1245900932] [node name="Persistence Connectors" type="Node" parent="." unique_id=1245900932]
@@ -96,7 +92,7 @@ gates = Array[NodePath]([NodePath("../../Objects/Spike Gate"), NodePath("../../O
collision_layer = 0 collision_layer = 0
collision_mask = 0 collision_mask = 0
script = ExtResource("3_ycf72") 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] [node name="CollisionShape2D" type="CollisionShape2D" parent="Camera Limit Connector" unique_id=456404995]
position = Vector2(384, 408) position = Vector2(384, 408)
@@ -341,7 +337,7 @@ position = Vector2(-1, -0.5)
shape = SubResource("RectangleShape2D_xrhbk") shape = SubResource("RectangleShape2D_xrhbk")
[node name="Loading Zone Transporter" parent="Loading Zones/Shop Door" unique_id=1690817663 instance=ExtResource("19_c5vrl")] [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" destination_marker_name = "Entrance"
[node name="Spawn Markers" type="Node2D" parent="." unique_id=1420428815] [node name="Spawn Markers" type="Node2D" parent="." unique_id=1420428815]
@@ -349,11 +345,13 @@ destination_marker_name = "Entrance"
[node name="Home 01 Entrance" type="Marker2D" parent="Spawn Markers" unique_id=1662896687] [node name="Home 01 Entrance" type="Marker2D" parent="Spawn Markers" unique_id=1662896687]
position = Vector2(278, 474) position = Vector2(278, 474)
[node name="Player" parent="." unique_id=1502234578 instance=ExtResource("4_4igim")] [node name="Player Map Entity" parent="." unique_id=469362016 instance=ExtResource("27_0w1de")]
position = Vector2(656, 498)
[node name="Camera2D" type="Camera2D" parent="Player" unique_id=1115720225] [node name="Child Node Appender" type="Node" parent="Player Map Entity" unique_id=1527392334]
position = Vector2(0, 1) 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) zoom = Vector2(3, 3)
position_smoothing_enabled = true position_smoothing_enabled = true
@@ -395,7 +393,6 @@ position = Vector2(760, 312)
[node name="Under Construction Block12" parent="Debug" unique_id=1005752992 instance=ExtResource("26_4lnhp")] [node name="Under Construction Block12" parent="Debug" unique_id=1005752992 instance=ExtResource("26_4lnhp")]
position = Vector2(760, 328) position = Vector2(760, 328)
[connection signal="SitOnBenchTriggered" from="Map 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 Gate" method="OpenGate"]
[connection signal="TargetHit" from="Objects/ArrowTarget" to="Objects/Spike Gate2" 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"] [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

@@ -18,4 +18,3 @@ func _ready() -> void:
func _on_chest_opened(chest: BaseChest) -> void: func _on_chest_opened(chest: BaseChest) -> void:
var node_path := chest.get_path() var node_path := chest.get_path()
PersistenceManager.UpdateData(node_path, true) PersistenceManager.UpdateData(node_path, true)
PersistenceManager.SaveToDisk()

View File

@@ -37,4 +37,3 @@ func _handle_spike_gate(node_path: NodePath) -> bool:
func _on_spike_gate_opened(node: Node) -> void: func _on_spike_gate_opened(node: Node) -> void:
var path := node.get_path() var path := node.get_path()
PersistenceManager.UpdateData(path, true) PersistenceManager.UpdateData(path, true)
PersistenceManager.SaveToDisk()

View File

@@ -1,16 +1,28 @@
extends Node extends Node
var _save_dictionary: Dictionary[NodePath, Variant] = {} const DEFAULT_SAVE_FILE_PATH = "user://savegame.save"
var _save_file_path: String
var _save_dictionary: Dictionary = {}
# Public Methods # Public Methods
func UpdateData(node_path: NodePath, value: Variant) -> void: func UpdateData(key: String, value: Variant) -> void:
_save_dictionary[node_path] = value _save_dictionary[key] = value
func GetData(node_path: NodePath) -> Variant: func UpdateNode(node_path: NodePath, value: Variant) -> void:
if not _save_dictionary.has(node_path): UpdateData(str(node_path), value)
func GetData(key: String) -> Variant:
if not _save_dictionary.has(key):
return null return null
return _save_dictionary[node_path] return _save_dictionary[key]
func GetNode(node_path: NodePath) -> Variant:
var key := str(node_path)
return GetData(key)
func HasData(node_path: NodePath) -> bool: func HasData(node_path: NodePath) -> bool:
@@ -18,17 +30,29 @@ func HasData(node_path: NodePath) -> bool:
func SaveToDisk() -> void: func SaveToDisk() -> void:
var save_file := FileAccess.open("user://savegame.save", FileAccess.WRITE) if !_save_file_path:
return
var save_file := FileAccess.open(_save_file_path, FileAccess.WRITE)
var json := JSON.stringify(_save_dictionary) var json := JSON.stringify(_save_dictionary)
save_file.store_line(json) save_file.store_line(json)
func LoadFromDisk() -> void: func LoadFromDisk(save_file_path: String) -> void:
if not FileAccess.file_exists("user://savegame.save"): _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 return
var save_file = FileAccess.open("user://savegame.save", FileAccess.READ)
var save_file := FileAccess.open(save_file_path, FileAccess.READ)
print("Loading save file from path: %s" % save_file.get_path_absolute()) 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 line := save_file.get_line()
var json = JSON.new() var json = JSON.new()
var parse_result := json.parse(line) var parse_result := json.parse(line)
@@ -36,16 +60,7 @@ func LoadFromDisk() -> void:
print("Parsing result when loading file: [%s] in %s at line %d" % [json.get_error_message(), line, json.get_error_line()]) print("Parsing result when loading file: [%s] in %s at line %d" % [json.get_error_message(), line, json.get_error_line()])
return return
print("JSON data parsed: [%d]" % typeof(json.data))
var data_dict: Dictionary = json.data var data_dict: Dictionary = json.data
var node_dict: Dictionary[NodePath, Variant] _save_dictionary = data_dict
for key in data_dict:
var value: Variant = data_dict[key]
var node_path := NodePath(key)
node_dict[node_path] = value
_save_dictionary = node_dict
# Private Methods
func _ready() -> void:
LoadFromDisk()

View File

@@ -782,6 +782,72 @@ texture = ExtResource("8_8d5h8")
1:1/animation_frame_6/duration = 0.3 1:1/animation_frame_6/duration = 0.3
1:1/animation_frame_7/duration = 0.3 1:1/animation_frame_7/duration = 0.3
1:1/0 = 0 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] [resource]
physics_layer_0/collision_layer = 1 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 extends Node
#
# Signals ## Signals
signal DialogueTriggered(dialogue_name: String) signal DialogueTriggered(dialogue_name: String)
#
# Exports ## Exports
@export var dialogue_box: DialogueBox #@export var dialogue_box: DialogueBox
#
# Private Variables ## Private Variables
var _dialogue_triggers_in_area: Array[DialogueTrigger] = [] #var _dialogue_triggers_in_area: Array[DialogueTrigger] = []
#
# Private Methods ## Private Methods
func _on_map_changed(map_id: Enums.MapIds) -> void: #func _on_map_changed(map_id: Enums.MapIds) -> void:
var player := GroupUtils.GetPlayer() #var player := GroupUtils.GetPlayerBody() as PlayerBody
if !player: #if !player:
return #return
#
player.interact_scanner.area_entered.connect(_on_interact_scanned) #dialogue_box.DialogueStarted.connect(player.QueueCutsceneState)
player.interact_scanner.area_exited.connect(_on_interact_unscanned) #dialogue_box.DialogueEnded.connect(player.QueueEndCutsceneState)
player.interact_scanner.InteractionActionTriggered.connect(_on_interact_triggered) #
#var dialogue_triggers := GroupUtils.GetAllDialogueTriggers()
dialogue_box.DialogueStarted.connect(player.QueueCutsceneState) #
dialogue_box.DialogueEnded.connect(player.QueueEndCutsceneState) #for trigger in dialogue_triggers:
#trigger.DialogueTriggered.connect(_on_dialogue_triggered)
var dialogue_triggers := GroupUtils.GetAllDialogueTriggers() #
#
for trigger in dialogue_triggers: #func _on_dialogue_triggered(dialogue_name: String) -> void:
trigger.DialogueTriggered.connect(_on_dialogue_triggered) ## Wait one frame so we don't immediately close dialogue box
## TODO This is stupid
#await get_tree().process_frame
func _on_dialogue_triggered(dialogue_name: String) -> void: #DialogueTriggered.emit(dialogue_name)
# Wait one frame so we don't immediately close dialogue box #
# TODO This is stupid #
await get_tree().process_frame #func _on_interact_scanned(area: Area2D) -> void:
DialogueTriggered.emit(dialogue_name) #if area is not DialogueTrigger or _dialogue_triggers_in_area.has(area):
#return
#_dialogue_triggers_in_area.append(area)
func _on_interact_scanned(area: Area2D) -> void: #
if area is not DialogueTrigger or _dialogue_triggers_in_area.has(area): #
return #func _on_interact_unscanned(area: Area2D) -> void:
_dialogue_triggers_in_area.append(area) #if area is not DialogueTrigger or !_dialogue_triggers_in_area.has(area):
#return
#_dialogue_triggers_in_area.erase(area)
func _on_interact_unscanned(area: Area2D) -> void: #
if area is not DialogueTrigger or !_dialogue_triggers_in_area.has(area): #
return #func _on_interact_triggered() -> void:
_dialogue_triggers_in_area.erase(area) #if _dialogue_triggers_in_area.is_empty():
#return
#
func _on_interact_triggered() -> void: #var trigger := _dialogue_triggers_in_area[0]
if _dialogue_triggers_in_area.is_empty(): #trigger.Trigger()
return
var trigger := _dialogue_triggers_in_area[0]
trigger.Trigger()

View File

@@ -17,6 +17,8 @@ enum Items {
} }
enum MapIds { enum MapIds {
ERROR_404,
TITLE_SCREEN,
PATH_TO_FOREST_DUNGEON_01, PATH_TO_FOREST_DUNGEON_01,
PATH_TO_FOREST_HOME_01, PATH_TO_FOREST_HOME_01,
SHOP_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,7 +11,7 @@ config_version=5
[application] [application]
config/name="Archipelago Game" config/name="Archipelago Game"
config/version="beta-1.4" config/version="beta-1.5"
run/main_scene="uid://dqgxg3i307lvr" run/main_scene="uid://dqgxg3i307lvr"
config/features=PackedStringArray("4.6", "Forward Plus") config/features=PackedStringArray("4.6", "Forward Plus")
config/icon="uid://ckbsqf4p5xu44" config/icon="uid://ckbsqf4p5xu44"
@@ -24,6 +24,7 @@ GroupUtils="*uid://bk7o4drbfh24p"
MapLoader="*uid://c4jogxtdi3m13" MapLoader="*uid://c4jogxtdi3m13"
InputManager="*uid://dnbg1dpjcq6vk" InputManager="*uid://dnbg1dpjcq6vk"
PersistenceManager="*uid://dl2kg1qu0ymi7" PersistenceManager="*uid://dl2kg1qu0ymi7"
ComponentUtils="*uid://cf5j2r4gpceng"
[dotnet] [dotnet]
@@ -76,6 +77,7 @@ locale/translations=PackedStringArray("res://Resources/Dialogue/Archipelago Game
2d_physics/layer_2="Interaction" 2d_physics/layer_2="Interaction"
2d_physics/layer_3="Projectile Collision" 2d_physics/layer_3="Projectile Collision"
2d_physics/layer_4="Occlusion" 2d_physics/layer_4="Occlusion"
2d_physics/layer_5="Entrance"
[physics] [physics]