Compare commits

4 Commits

Author SHA1 Message Date
7cd34cb07e beta-1.5 (#4)
Reviewed-on: #4
2026-03-28 20:34:59 -06:00
5fb4a96159 beta-1.4/persistence-implementation (#3)
Reviewed-on: #3
2026-03-19 13:27:37 -06:00
bfe4f7d6a9 beta-1.3/restructure-files (#2)
Reviewed-on: #2
2026-03-17 13:45:35 -06:00
86e3198645 beta-1.2/signal-refactor (#1)
Reviewed-on: #1
2026-03-15 12:19:12 -06:00
193 changed files with 1341 additions and 483 deletions

3
.gitignore vendored
View File

@@ -17,3 +17,6 @@ mono_crash.*.json
# Android build files # Android build files
/android/ /android/
# Rider files
.idea

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bo1utikr0r2q1"
path="res://.godot/imported/64x64.png-129f36e07b18bd0408477af73ef87a83.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Spritesheets/Icons/UI/64x64.png"
dest_files=["res://.godot/imported/64x64.png-129f36e07b18bd0408477af73ef87a83.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://clqfyxjtn67m"] [gd_scene format=3 uid="uid://clqfyxjtn67m"]
[ext_resource type="Script" uid="uid://c5pt6iroi01si" path="res://Scripts/Characters/Chicken/npc_chicken.gd" id="1_etrql"] [ext_resource type="Script" uid="uid://c5pt6iroi01si" path="res://Entities/Characters/Animals/Chicken/Scripts/npc_chicken.gd" id="1_etrql"]
[ext_resource type="Texture2D" uid="uid://d4lf74neoqf4p" path="res://Assets/Spritesheets/Animals/Chickens/Chicken_01.png" id="1_hjr72"] [ext_resource type="Texture2D" uid="uid://d4lf74neoqf4p" path="res://Assets/Spritesheets/Animals/Chickens/Chicken_01.png" id="1_hjr72"]
[sub_resource type="AtlasTexture" id="AtlasTexture_etrql"] [sub_resource type="AtlasTexture" id="AtlasTexture_etrql"]

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,7 +1,8 @@
extends BaseState extends BaseState
class_name FiringArrowState
signal PlayerBeganFiringArrow signal PlayerBeganFiringArrow
signal PlayerFiredArrow(spawn_position: Vector2, direction: Vector2) signal ArrowFired(spawn_position: Vector2, direction: Vector2)
@export var direction_component: FacingDirectionComponent @export var direction_component: FacingDirectionComponent
@export var arrow_spawn_marker: Marker2D @export var arrow_spawn_marker: Marker2D
@@ -23,7 +24,7 @@ func Enter(_extra_parameters: Dictionary) -> void:
direction = Vector2.UP direction = Vector2.UP
elif direction_component.current_direction == Enums.Directions.DOWN: elif direction_component.current_direction == Enums.Directions.DOWN:
direction = Vector2.DOWN direction = Vector2.DOWN
PlayerFiredArrow.emit(position, direction) ArrowFired.emit(position, direction)
func OnFiringArrowAnimationFinished() -> void: func OnFiringArrowAnimationFinished() -> void:

View File

@@ -1,10 +1,11 @@
extends BaseState extends BaseState
class_name PlayerIdleState class_name PlayerIdleState
@export var movement_component: MovementComponent
signal PlayerBecameIdle signal PlayerBecameIdle
@export var player: PlayerCharacter
var _movement_component: MovementComponent
var _sit_queued := false var _sit_queued := false
var _sit_queue_pos: Vector2 var _sit_queue_pos: Vector2
var _sit_queue_dir: Enums.Directions var _sit_queue_dir: Enums.Directions
@@ -15,6 +16,10 @@ func GetStateEnum() -> PlayerStateMachine.States:
func Enter(_extra_parameters: Dictionary) -> void: func Enter(_extra_parameters: Dictionary) -> void:
_movement_component = ComponentUtils.GetMovementComponent(player)
if not _movement_component:
print_rich("[color=yellow]Warning: Player does not have a movement component...[/color]")
PlayerBecameIdle.emit() PlayerBecameIdle.emit()
@@ -30,7 +35,7 @@ func Update(_delta: float) -> void:
_sit_queued = false _sit_queued = false
return return
if movement_component.movement_vector != Vector2.ZERO: if _movement_component and _movement_component.movement_vector != Vector2.ZERO:
state_machine.QueueStateChange(PlayerStateMachine.States.WALKING) state_machine.QueueStateChange(PlayerStateMachine.States.WALKING)

View File

@@ -3,24 +3,27 @@ extends BaseState
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 direction_component: FacingDirectionComponent
@export var body: CharacterBody2D @export var body: CharacterBody2D
var _movement_component: MovementComponent
func GetStateEnum() -> PlayerStateMachine.States: func GetStateEnum() -> PlayerStateMachine.States:
return PlayerStateMachine.States.WALKING return PlayerStateMachine.States.WALKING
func Enter(_extra_parameters: Dictionary) -> void: func Enter(_extra_parameters: Dictionary) -> void:
_movement_component = ComponentUtils.GetMovementComponent(body)
StartedWalking.emit() StartedWalking.emit()
func Update(_delta: float) -> void: func Update(_delta: float) -> void:
if movement_component.movement_vector == Vector2.ZERO: var movement_vector := _movement_component.movement_vector
if movement_vector == 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 = movement_vector * walking_speed body.velocity = movement_vector * walking_speed
body.move_and_slide() body.move_and_slide()

View File

@@ -3,9 +3,6 @@ class_name MovementComponent
signal MovementInput(movement_vector: Vector2) signal MovementInput(movement_vector: Vector2)
# Dynamic Exports
@export var body: CharacterBody2D
var movement_vector: Vector2 var movement_vector: Vector2
func _physics_process(_delta: float) -> void: func _physics_process(_delta: float) -> void:

View File

@@ -0,0 +1,18 @@
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

@@ -1,22 +1,22 @@
extends Node2D extends Node2D
class_name PlayerSprite
# Signals
signal DrawingBowAnimationFinished signal DrawingBowAnimationFinished
signal FiringArrowAnimationFinished signal FiringArrowAnimationFinished
signal AnimationFinished(animation_name: String) signal AnimationFinished(animation_name: String)
# Exports
@export var state_machine: PlayerStateMachine @export var state_machine: PlayerStateMachine
@export var direction_component: FacingDirectionComponent @export var direction_component: FacingDirectionComponent
# OnReady Variables
@onready var full: AnimatedSprite2D = $Full @onready var full: AnimatedSprite2D = $Full
@onready var base: AnimatedSprite2D = $Base
@onready var hair: AnimatedSprite2D = $Hair
@onready var pants: AnimatedSprite2D = $Pants
@onready var hands: AnimatedSprite2D = $Hands
@onready var shoes: AnimatedSprite2D = $Shoes
var all_parts: Array[AnimatedSprite2D] # Private Variables
var current_animation := "idle-down" var _all_parts: Array[AnimatedSprite2D]
var is_flipped := false var _current_animation := "idle-down"
var _is_flipped := false
# Public Methods # Public Methods
func UpdateSprite() -> void: func UpdateSprite() -> void:
@@ -25,37 +25,37 @@ func UpdateSprite() -> void:
var animation := _build_animation_name(current_state, current_direction) var animation := _build_animation_name(current_state, current_direction)
var should_flip := _should_flip_horizontal() var should_flip := _should_flip_horizontal()
if animation == current_animation and should_flip == is_flipped: if animation == _current_animation and should_flip == _is_flipped:
return return
current_animation = animation _current_animation = animation
is_flipped = should_flip _is_flipped = should_flip
for part in all_parts: for part in _all_parts:
part.animation = animation part.animation = animation
part.play() part.play()
part.flip_h = should_flip part.flip_h = should_flip
func OnAnimationFinished() -> void: func OnAnimationFinished() -> void:
if current_animation.begins_with("drawing-bow-"): if _current_animation.begins_with("drawing-bow-"):
DrawingBowAnimationFinished.emit() DrawingBowAnimationFinished.emit()
elif current_animation.begins_with("firing-arrow-"): elif _current_animation.begins_with("firing-arrow-"):
FiringArrowAnimationFinished.emit() FiringArrowAnimationFinished.emit()
AnimationFinished.emit(current_animation) AnimationFinished.emit(_current_animation)
func PlaySpecifiedAnimation(animation_name: String) -> void: func PlaySpecifiedAnimation(animation_name: String) -> void:
current_animation = animation_name _current_animation = animation_name
for part in all_parts: for part in _all_parts:
part.animation = animation_name part.animation = animation_name
part.play() part.play()
# 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:
all_parts = [ _all_parts = [
full, #base, hair, pants, hands, shoes full
] ]
UpdateSprite() UpdateSprite()
@@ -63,8 +63,8 @@ func _ready() -> void:
func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String: func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String:
# e.g. "idle-down", "walking-up" # e.g. "idle-down", "walking-up"
var state_str = state.GetAnimationBaseName().replace("_", "-") var state_str := state.GetAnimationBaseName().replace("_", "-")
var direction_str = _direction_to_animation_state(direction) var direction_str := _direction_to_animation_state(direction)
return "%s-%s" % [state_str, direction_str] return "%s-%s" % [state_str, direction_str]

View File

@@ -1,19 +1,18 @@
[gd_scene format=3 uid="uid://6athlweutl2g"] [gd_scene format=3 uid="uid://6athlweutl2g"]
[ext_resource type="PackedScene" uid="uid://uyl0s1e67x6s" path="res://Scenes/Characters/Player/sprite.tscn" id="1_27cb7"] [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://Scenes/Characters/Player/state_machine.tscn" id="1_lyjr2"] [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://Scripts/Characters/Player/player.gd" id="1_qqvsf"] [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://b0l02v61if6k8" path="res://Scripts/Components/facing_direction_component.gd" id="1_siygm"]
[ext_resource type="Script" uid="uid://dwclkwbig1uii" path="res://Scripts/Characters/Player/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://dkmc1t43gomdb" path="res://Scripts/Characters/Player/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://ckn7gmtc23b8l" path="res://Scripts/Characters/Player/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://bwmmah30t3m0u" path="res://Scripts/Characters/Player/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://brlisuoocwehh" path="res://Scripts/Characters/Player/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://bnp1vowmu15lg" path="res://Scripts/Characters/Player/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://cd2ewadcm8oi5" path="res://Scripts/Characters/Player/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://bx1a35al4yiej" path="res://Scripts/Characters/Player/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://bnontuqj3cnom" path="res://Scripts/Characters/Player/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"]
[ext_resource type="Script" uid="uid://wfdtd3xlgrvm" path="res://Scripts/Characters/Player/States/play_animation_state.gd" id="12_aencf"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_apx8m"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_apx8m"]
size = Vector2(10, 5) size = Vector2(10, 5)
@@ -24,11 +23,12 @@ radius = 12.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fu1fx"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_fu1fx"]
size = Vector2(6, 5) size = Vector2(6, 5)
[node name="Player" type="CharacterBody2D" unique_id=1502234578 node_paths=PackedStringArray("player_sprite", "state_machine") groups=["Player Group"]] [node name="Player" type="CharacterBody2D" unique_id=1502234578 node_paths=PackedStringArray("player_sprite", "state_machine", "interact_scanner") groups=["Player Group"]]
y_sort_enabled = true y_sort_enabled = true
script = ExtResource("1_qqvsf") script = ExtResource("1_qqvsf")
player_sprite = NodePath("Player Sprite") player_sprite = NodePath("Player Sprite")
state_machine = NodePath("State Machine") state_machine = NodePath("State Machine")
interact_scanner = NodePath("Marker2D/InteractScanner")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=495465356] [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=495465356]
position = Vector2(0, 4.5) position = Vector2(0, 4.5)
@@ -39,24 +39,19 @@ shape = SubResource("RectangleShape2D_apx8m")
[node name="FacingDirectionComponent" type="Node" parent="Components" unique_id=408127032] [node name="FacingDirectionComponent" type="Node" parent="Components" unique_id=408127032]
script = ExtResource("1_siygm") 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")] [node name="State Machine" parent="." unique_id=732559774 node_paths=PackedStringArray("states_container", "current_state") instance=ExtResource("1_lyjr2")]
states_container = NodePath("States") states_container = NodePath("States")
current_state = NodePath("States/Idle State") current_state = NodePath("States/Idle State")
[node name="States" type="Node" parent="State Machine" unique_id=1171587216] [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")] [node name="Idle State" type="Node" parent="State Machine/States" unique_id=2017409248 node_paths=PackedStringArray("player", "state_machine")]
script = ExtResource("4_dxcao") script = ExtResource("4_dxcao")
movement_component = NodePath("../../../Components/MovementComponent") player = NodePath("../../..")
state_machine = NodePath("../..") 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")] [node name="Walking State" type="Node" parent="State Machine/States" unique_id=1661048365 node_paths=PackedStringArray("direction_component", "body", "state_machine")]
script = ExtResource("5_cscr0") script = ExtResource("5_cscr0")
movement_component = NodePath("../../../Components/MovementComponent")
direction_component = NodePath("../../../Components/FacingDirectionComponent") direction_component = NodePath("../../../Components/FacingDirectionComponent")
body = NodePath("../../..") body = NodePath("../../..")
state_machine = NodePath("../..") state_machine = NodePath("../..")
@@ -67,9 +62,8 @@ body = NodePath("../../..")
direction_component = NodePath("../../../Components/FacingDirectionComponent") direction_component = NodePath("../../../Components/FacingDirectionComponent")
state_machine = NodePath("../..") 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")] [node name="Drawing Bow State" type="Node" parent="State Machine/States" unique_id=317681716 node_paths=PackedStringArray("body", "state_machine")]
script = ExtResource("7_cscr0") script = ExtResource("7_cscr0")
movement_componenent = NodePath("../../../Components/MovementComponent")
body = NodePath("../../..") body = NodePath("../../..")
state_machine = NodePath("../..") state_machine = NodePath("../..")
@@ -116,8 +110,6 @@ position = Vector2(0, 9.5)
shape = SubResource("RectangleShape2D_fu1fx") shape = SubResource("RectangleShape2D_fu1fx")
debug_color = Color(0.79959095, 0.41617078, 0.18507844, 0.41960785) debug_color = Color(0.79959095, 0.41617078, 0.18507844, 0.41960785)
[connection signal="CutsceneEnded" from="." to="State Machine/States/Cutscene State" method="OnCutsceneEnded"]
[connection signal="CutsceneStarted" from="." to="State Machine/States/Idle State" method="OnCutsceneStarted"]
[connection signal="SitOnFurnitureTriggered" from="." to="State Machine/States/Idle State" method="OnSitOnFurnitureTriggered"] [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="Player Sprite" method="UpdateSprite"]
[connection signal="DirectionChanged" from="Components/FacingDirectionComponent" to="Marker2D/InteractScanner" method="OnDirectionChanged"] [connection signal="DirectionChanged" from="Components/FacingDirectionComponent" to="Marker2D/InteractScanner" method="OnDirectionChanged"]
@@ -125,7 +117,6 @@ debug_color = Color(0.79959095, 0.41617078, 0.18507844, 0.41960785)
[connection signal="StartedWalking" from="State Machine/States/Walking 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="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="PlayerBeganFiringArrow" from="State Machine/States/Firing Arrow State" to="Player Sprite" method="UpdateSprite"]
[connection signal="PlayerFiredArrow" from="State Machine/States/Firing Arrow State" to="." method="_on_using_item_a_state_arrow_fired"]
[connection signal="PlayAnimation" from="State Machine/States/Play Animation State" to="Player Sprite" method="PlaySpecifiedAnimation"] [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="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="DrawingBowAnimationFinished" from="Player Sprite" to="State Machine/States/Drawing Bow State" method="OnDrawingBowAnimationFinished"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://uyl0s1e67x6s"] [gd_scene format=3 uid="uid://uyl0s1e67x6s"]
[ext_resource type="Texture2D" uid="uid://de0ihg453ruyi" path="res://Assets/Spritesheets/Player/Player_Base_animations.png" id="1_45g06"] [ext_resource type="Texture2D" uid="uid://de0ihg453ruyi" path="res://Assets/Spritesheets/Player/Player_Base_animations.png" id="1_45g06"]
[ext_resource type="Script" uid="uid://cuar23q48cbja" path="res://Scripts/Characters/Player/sprite.gd" id="1_jqxwg"] [ext_resource type="Script" uid="uid://cuar23q48cbja" path="res://Entities/Characters/Player/Scripts/sprite.gd" id="1_jqxwg"]
[ext_resource type="Texture2D" uid="uid://1g5dx0dbupwk" path="res://Assets/Spritesheets/Player/Hair_1_Blonde.png" id="2_jqxwg"] [ext_resource type="Texture2D" uid="uid://1g5dx0dbupwk" path="res://Assets/Spritesheets/Player/Hair_1_Blonde.png" id="2_jqxwg"]
[ext_resource type="Texture2D" uid="uid://d1mourl3rq437" path="res://Assets/Spritesheets/Player/player-full-01.png" id="2_ndjja"] [ext_resource type="Texture2D" uid="uid://d1mourl3rq437" path="res://Assets/Spritesheets/Player/player-full-01.png" id="2_ndjja"]
[ext_resource type="Texture2D" uid="uid://4mpha6wuvyfy" path="res://Assets/Spritesheets/Player/Farmer_Shirt_1_Black.png" id="3_ndjja"] [ext_resource type="Texture2D" uid="uid://4mpha6wuvyfy" path="res://Assets/Spritesheets/Player/Farmer_Shirt_1_Black.png" id="3_ndjja"]

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://c2ydbmmvnfca6"] [gd_scene format=3 uid="uid://c2ydbmmvnfca6"]
[ext_resource type="Script" uid="uid://c74mhfemxuuco" path="res://Scripts/Characters/Player/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="StateMachine" type="Node" unique_id=732559774]
script = ExtResource("1_clu2m") script = ExtResource("1_clu2m")

View File

@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://nbkisxm2oekn"]
[ext_resource type="Script" uid="uid://dwclkwbig1uii" path="res://Entities/Characters/Player/Scripts/movement_component.gd" id="1_b2nib"]
[node name="Movement Component" type="Node" unique_id=737644583]
script = ExtResource("1_b2nib")

View File

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

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://d24gcv3umq60k"] [gd_scene format=3 uid="uid://d24gcv3umq60k"]
[ext_resource type="Script" uid="uid://d4g6s63d0bh4o" path="res://Scripts/Objects/Occlusion/occlusion_culler.gd" id="1_4550i"] [ext_resource type="Script" uid="uid://ba0nsd76er3xa" path="res://Entities/Characters/Utility/Occlusion/Scripts/occlusion_culler.gd" id="1_4550i"]
[node name="Occlusion Culler" type="Area2D" unique_id=1362480066] [node name="Occlusion Culler" type="Area2D" unique_id=1362480066]
collision_layer = 0 collision_layer = 0

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://cd3iyspcdg8m"] [gd_scene format=3 uid="uid://cd3iyspcdg8m"]
[ext_resource type="Script" uid="uid://0fsmtp1umvmp" path="res://Scripts/Objects/Chests/Bases/chest_base.gd" id="1_6u2sl"] [ext_resource type="Script" uid="uid://0fsmtp1umvmp" path="res://Entities/Map Objects/Chests/Scripts/Bases/chest_base.gd" id="1_6u2sl"]
[node name="Base Chest" type="StaticBody2D" unique_id=975880832 groups=["Treasure Chest Group"]] [node name="Base Chest" type="StaticBody2D" unique_id=975880832 groups=["Treasure Chest Group"]]
y_sort_enabled = true y_sort_enabled = true

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://cncm0c4dmosgs"] [gd_scene format=3 uid="uid://cncm0c4dmosgs"]
[ext_resource type="Script" uid="uid://dbuc0f87m24xf" path="res://Scripts/Objects/Chests/Bases/item_chest.gd" id="1_mkt0u"] [ext_resource type="Script" uid="uid://dbuc0f87m24xf" path="res://Entities/Map Objects/Chests/Scripts/Bases/item_chest.gd" id="1_mkt0u"]
[node name="Base Item Chest" type="StaticBody2D" unique_id=991903258] [node name="Base Item Chest" type="StaticBody2D" unique_id=991903258]
script = ExtResource("1_mkt0u") script = ExtResource("1_mkt0u")

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://byp273amg5ji8"] [gd_scene format=3 uid="uid://byp273amg5ji8"]
[ext_resource type="Script" uid="uid://bvq13h8uyx572" path="res://Scripts/Objects/Chests/item_chest_01.gd" id="1_lp0kr"] [ext_resource type="Script" uid="uid://bvq13h8uyx572" path="res://Entities/Map Objects/Chests/Scripts/item_chest_01.gd" id="1_lp0kr"]
[ext_resource type="PackedScene" uid="uid://d3rqn611axsfk" path="res://Scenes/Animated Sprites/chest01_sprite.tscn" id="2_iwcc8"] [ext_resource type="PackedScene" uid="uid://d3rqn611axsfk" path="res://Entities/Map Objects/Chests/Sprites/chest01_sprite.tscn" id="2_iwcc8"]
[ext_resource type="Texture2D" uid="uid://crf23tc55dxu" path="res://Assets/Spritesheets/Treasure Chests/Chest_Anim.png" id="3_iwcc8"] [ext_resource type="Texture2D" uid="uid://crf23tc55dxu" path="res://Assets/Spritesheets/Treasure Chests/Chest_Anim.png" id="3_iwcc8"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_y3ooa"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_y3ooa"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://b7u4hlvuqiefn"] [gd_scene format=3 uid="uid://b7u4hlvuqiefn"]
[ext_resource type="Script" uid="uid://bvq13h8uyx572" path="res://Scripts/Objects/Chests/item_chest_01.gd" id="1_77oue"] [ext_resource type="Script" uid="uid://bvq13h8uyx572" path="res://Entities/Map Objects/Chests/Scripts/item_chest_01.gd" id="1_77oue"]
[ext_resource type="PackedScene" uid="uid://d3rqn611axsfk" path="res://Scenes/Animated Sprites/chest01_sprite.tscn" id="2_jpeii"] [ext_resource type="PackedScene" uid="uid://d3rqn611axsfk" path="res://Entities/Map Objects/Chests/Sprites/chest01_sprite.tscn" id="2_jpeii"]
[ext_resource type="Texture2D" uid="uid://dcbk854sc3uud" path="res://Assets/Spritesheets/Home Decor/Metal_Chest_Anim.png" id="3_jpeii"] [ext_resource type="Texture2D" uid="uid://dcbk854sc3uud" path="res://Assets/Spritesheets/Home Decor/Metal_Chest_Anim.png" id="3_jpeii"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_y3ooa"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_y3ooa"]

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://23tpba4r6ucg"] [gd_scene format=3 uid="uid://23tpba4r6ucg"]
[ext_resource type="Texture2D" uid="uid://nocnsf1xr3ap" path="res://Assets/Spritesheets/Outdoor Decor/Benches.png" id="1_jlu4v"] [ext_resource type="Texture2D" uid="uid://nocnsf1xr3ap" path="res://Assets/Spritesheets/Outdoor Decor/Benches.png" id="1_jlu4v"]
[ext_resource type="Script" uid="uid://c6n652dy18xbm" path="res://Scripts/Objects/Decorative/Outdoor/wooden_bench.gd" id="1_nv27i"] [ext_resource type="Script" uid="uid://c6n652dy18xbm" path="res://Entities/Map Objects/Decorative/Outdoor/Scripts/wooden_bench.gd" id="1_nv27i"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_nv27i"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_nv27i"]
size = Vector2(30, 11) size = Vector2(30, 11)

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://b60nr4wfvijpf"] [gd_scene format=3 uid="uid://b60nr4wfvijpf"]
[ext_resource type="Script" uid="uid://cfsfx0sahh5t7" path="res://Scripts/Objects/Dialogue/dialogue_trigger.gd" id="1_dyjvr"] [ext_resource type="Script" uid="uid://cfsfx0sahh5t7" path="res://Entities/Map Objects/Dialogue/Scripts/dialogue_trigger.gd" id="1_dyjvr"]
[node name="Dialogue Trigger" type="Area2D" unique_id=189867444 groups=["Dialog Trigger Group"]] [node name="Dialogue Trigger" type="Area2D" unique_id=189867444 groups=["Dialog Trigger Group"]]
collision_layer = 2 collision_layer = 2

View File

@@ -1,24 +1,22 @@
extends Node extends Node
# Exports
@export var player: PlayerCharacter
@export var arrow_parent: Node2D @export var arrow_parent: Node2D
# Preloads
const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx") const wooden_arrow_scene: PackedScene = preload("uid://b2wq5m01b68rx")
# Public Methods
func OnArrowFired(fire_position: Vector2, direction: Vector2) -> void:
var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile
wooden_arrow.SetProjectileStartAndDirection(fire_position, direction)
if arrow_parent == null:
return
arrow_parent.add_child(wooden_arrow)
# Private Methods # Private Methods
func _ready() -> void: func _ready() -> void:
var players := get_tree().get_nodes_in_group("Player Group") var firing_arrow_state: FiringArrowState = player.get_node("State Machine/States/Firing Arrow State")
if players == null or players.is_empty() or players[0] is not PlayerCharacter: firing_arrow_state.ArrowFired.connect(_on_arrow_fired)
func _on_arrow_fired(fire_position: Vector2, direction: Vector2) -> void:
var wooden_arrow := wooden_arrow_scene.instantiate() as BaseProjectile
wooden_arrow.SetProjectileStartAndDirection(fire_position, direction)
if arrow_parent == null:
return return
arrow_parent.add_child(wooden_arrow)
var player := players[0] as PlayerCharacter
player.ArrowFired.connect(OnArrowFired)

View File

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

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://da4qqruhldc6b"] [gd_scene format=3 uid="uid://da4qqruhldc6b"]
[ext_resource type="Texture2D" uid="uid://1kmd0qww3368" path="res://Assets/Spritesheets/Outdoor Objects/Spike_Gate_anim.png" id="1_5ttkm"] [ext_resource type="Texture2D" uid="uid://1kmd0qww3368" path="res://Assets/Spritesheets/Outdoor Objects/Spike_Gate_anim.png" id="1_5ttkm"]
[ext_resource type="Script" uid="uid://8erg53skow38" path="res://Scripts/Objects/Gates/Spike Gate/spike_gate.gd" id="1_kye8r"] [ext_resource type="Script" uid="uid://8erg53skow38" path="res://Entities/Map Objects/Gates/Spike Gate/Scripts/spike_gate.gd" id="1_kye8r"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5ttkm"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_5ttkm"]
size = Vector2(29, 4) size = Vector2(29, 4)
@@ -395,6 +395,6 @@ shape = SubResource("RectangleShape2D_5ttkm")
y_sort_enabled = true y_sort_enabled = true
position = Vector2(0, 15) position = Vector2(0, 15)
sprite_frames = SubResource("SpriteFrames_pki7h") sprite_frames = SubResource("SpriteFrames_pki7h")
animation = &"closed" animation = &"open"
autoplay = "closed" autoplay = "closed"
offset = Vector2(0, -15) offset = Vector2(0, -15)

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://ca75b65eh7vv8"] [gd_scene format=3 uid="uid://ca75b65eh7vv8"]
[ext_resource type="Script" uid="uid://g0r5waf50gp5" path="res://Scripts/Objects/Loading Zone/collision_loading_zone.gd" id="1_pb5hg"] [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

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://cla2d3gii8qda"] [gd_scene format=3 uid="uid://cla2d3gii8qda"]
[ext_resource type="Script" uid="uid://dla7fe0nsbdvv" path="res://Scripts/Objects/Loading Zone/interactive_loading_zone.gd" id="1_7bdbd"] [ext_resource type="Script" uid="uid://csspyy43sohfl" path="res://Entities/Map Objects/Loading Zone/Scripts/interactive_loading_zone.gd" id="1_7bdbd"]
[node name="Interactive Loading Zone" type="Area2D" unique_id=1427014981 groups=["Interactive Loading Zone Group"]] [node name="Interactive Loading Zone" type="Area2D" unique_id=1427014981 groups=["Interactive Loading Zone Group"]]
collision_layer = 2 collision_layer = 2

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://bbules4o3xayc"] [gd_scene format=3 uid="uid://bbules4o3xayc"]
[ext_resource type="Script" uid="uid://cshtpe5n2iubh" path="res://Scripts/Objects/Loading Zone/loading_zone_transporter.gd" id="1_p8o2m"] [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"]] [node name="Loading Zone Transporter" type="Node" unique_id=1690817663 groups=["Loading Zone Transporter Group"]]
script = ExtResource("1_p8o2m") script = ExtResource("1_p8o2m")

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://b8m08wroe1qu2"] [gd_scene format=3 uid="uid://b8m08wroe1qu2"]
[ext_resource type="Texture2D" uid="uid://k2htcxstdj5v" path="res://Assets/Spritesheets/Outdoor Objects/Arrow Target-Sheet.png" id="1_b0s8y"] [ext_resource type="Texture2D" uid="uid://k2htcxstdj5v" path="res://Assets/Spritesheets/Outdoor Objects/Arrow Target-Sheet.png" id="1_b0s8y"]
[ext_resource type="Script" uid="uid://6jls1eokv2to" path="res://Scripts/Objects/arrow_target.gd" id="1_uhut5"] [ext_resource type="Script" uid="uid://6jls1eokv2to" path="res://Entities/Map Objects/Mechanisms/Scripts/arrow_target.gd" id="1_uhut5"]
[sub_resource type="CircleShape2D" id="CircleShape2D_uhut5"] [sub_resource type="CircleShape2D" id="CircleShape2D_uhut5"]
radius = 8.0 radius = 8.0

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://b5t4h63xhuods"] [gd_scene format=3 uid="uid://b5t4h63xhuods"]
[ext_resource type="Script" uid="uid://cxt7ht66jiac8" path="res://Scripts/Objects/Mechanisms/pressure_plate.gd" id="1_po2h8"] [ext_resource type="Script" uid="uid://cxt7ht66jiac8" path="res://Entities/Map Objects/Mechanisms/Scripts/pressure_plate.gd" id="1_po2h8"]
[ext_resource type="Texture2D" uid="uid://dhtolttw5h33" path="res://Assets/Spritesheets/Mechanisms/Pressure Plate.png" id="1_ulio5"] [ext_resource type="Texture2D" uid="uid://dhtolttw5h33" path="res://Assets/Spritesheets/Mechanisms/Pressure Plate.png" id="1_ulio5"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ulio5"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_ulio5"]

View File

@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://ddgeo3vwebqeg"] [gd_scene format=3 uid="uid://ddgeo3vwebqeg"]
[ext_resource type="Script" uid="uid://cggyjxrk4qqfm" path="res://Scripts/Objects/shop_item.gd" id="1_0luup"] [ext_resource type="Script" uid="uid://cggyjxrk4qqfm" path="res://Entities/Map Objects/Mechanisms/Scripts/shop_item.gd" id="1_0luup"]
[node name="ShopItem" type="Area2D" unique_id=1768344009] [node name="ShopItem" type="Area2D" unique_id=1768344009]
collision_layer = 2 collision_layer = 2

View File

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

View File

@@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://dpwm1tn0mbr3l"]
[ext_resource type="Script" uid="uid://vmyfl4obus88" path="res://Entities/Map Objects/Trees/Effects/Scripts/leaf_spawner.gd" id="1_l7yxv"]
[node name="Leaf Spawner" type="Node2D" unique_id=986945632]
y_sort_enabled = true
script = ExtResource("1_l7yxv")

Some files were not shown because too many files have changed in this diff Show More