beta-1.3/restructure-files (#2)
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
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()
|
||||
@@ -0,0 +1 @@
|
||||
uid://ctoxjn2rvtjs6
|
||||
33
Entities/Characters/Player/Scripts/States/base_state.gd
Normal file
33
Entities/Characters/Player/Scripts/States/base_state.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
class_name BaseState
|
||||
extends Node
|
||||
|
||||
@export var state_machine: PlayerStateMachine
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
push_error("Unimplemented Method: BaseState.GetName")
|
||||
return PlayerStateMachine.States.IDLE
|
||||
|
||||
|
||||
func GetAnimationBaseName() -> String:
|
||||
var state: String = PlayerStateMachine.States.keys()[GetStateEnum()]
|
||||
return state.to_lower()
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func Exit() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func IsActive() -> bool:
|
||||
return state_machine.GetCurrentStateEnum() == GetStateEnum()
|
||||
|
||||
|
||||
func IsStateActionable() -> bool:
|
||||
return true
|
||||
@@ -0,0 +1 @@
|
||||
uid://cb57l5vpq5bee
|
||||
29
Entities/Characters/Player/Scripts/States/cutscene_state.gd
Normal file
29
Entities/Characters/Player/Scripts/States/cutscene_state.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends BaseState
|
||||
class_name PlayerCutsceneState
|
||||
|
||||
@onready var interact_scanner: InteractScanner = $"../../../Marker2D/InteractScanner"
|
||||
|
||||
# Public Methods
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.CUTSCENE
|
||||
|
||||
|
||||
func GetAnimationBaseName() -> String:
|
||||
return "idle"
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
print("Cutscene Started")
|
||||
interact_scanner.disable_interactions = true
|
||||
|
||||
|
||||
func Exit() -> void:
|
||||
interact_scanner.disable_interactions = false
|
||||
|
||||
|
||||
func OnCutsceneEnded() -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
|
||||
|
||||
func IsStateActionable() -> bool:
|
||||
return false
|
||||
@@ -0,0 +1 @@
|
||||
uid://bnontuqj3cnom
|
||||
@@ -0,0 +1,37 @@
|
||||
extends BaseState
|
||||
|
||||
signal PlayerBeganDrawingBow
|
||||
|
||||
@export var strafing_speed := 35
|
||||
@export var movement_componenent: MovementComponent
|
||||
@export var body: CharacterBody2D
|
||||
|
||||
var used_item_action: String
|
||||
var animation_finished := false
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.DRAWING_BOW
|
||||
|
||||
|
||||
func Enter(extra_parameters: Dictionary) -> void:
|
||||
animation_finished = false
|
||||
used_item_action = extra_parameters.action_name
|
||||
PlayerBeganDrawingBow.emit()
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
if !animation_finished:
|
||||
return
|
||||
|
||||
if !Input.is_action_pressed(used_item_action):
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.FIRING_ARROW)
|
||||
return
|
||||
|
||||
var movement_vector := movement_componenent.movement_vector
|
||||
if movement_vector != Vector2.ZERO:
|
||||
body.velocity = movement_vector * strafing_speed
|
||||
body.move_and_slide()
|
||||
|
||||
|
||||
func OnDrawingBowAnimationFinished() -> void:
|
||||
animation_finished = true
|
||||
@@ -0,0 +1 @@
|
||||
uid://bnp1vowmu15lg
|
||||
@@ -0,0 +1,31 @@
|
||||
extends BaseState
|
||||
class_name FiringArrowState
|
||||
|
||||
signal PlayerBeganFiringArrow
|
||||
signal ArrowFired(spawn_position: Vector2, direction: Vector2)
|
||||
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
@export var arrow_spawn_marker: Marker2D
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.FIRING_ARROW
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
PlayerBeganFiringArrow.emit()
|
||||
|
||||
var position := arrow_spawn_marker.global_position
|
||||
var direction := Vector2.ZERO
|
||||
if direction_component.current_direction == Enums.Directions.LEFT:
|
||||
direction = Vector2.LEFT
|
||||
elif direction_component.current_direction == Enums.Directions.RIGHT:
|
||||
direction = Vector2.RIGHT
|
||||
elif direction_component.current_direction == Enums.Directions.UP:
|
||||
direction = Vector2.UP
|
||||
elif direction_component.current_direction == Enums.Directions.DOWN:
|
||||
direction = Vector2.DOWN
|
||||
ArrowFired.emit(position, direction)
|
||||
|
||||
|
||||
func OnFiringArrowAnimationFinished() -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cd2ewadcm8oi5
|
||||
47
Entities/Characters/Player/Scripts/States/idle_state.gd
Normal file
47
Entities/Characters/Player/Scripts/States/idle_state.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends BaseState
|
||||
class_name PlayerIdleState
|
||||
|
||||
@export var movement_component: MovementComponent
|
||||
|
||||
signal PlayerBecameIdle
|
||||
|
||||
var _sit_queued := false
|
||||
var _sit_queue_pos: Vector2
|
||||
var _sit_queue_dir: Enums.Directions
|
||||
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.IDLE
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
PlayerBecameIdle.emit()
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
var item_a := Input.is_action_just_pressed("use_item_a")
|
||||
|
||||
if item_a:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.USING_ITEM_A, {})
|
||||
return
|
||||
|
||||
if _sit_queued:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.SITTING, {"pos": _sit_queue_pos, "dir": _sit_queue_dir})
|
||||
_sit_queued = false
|
||||
return
|
||||
|
||||
if movement_component.movement_vector != Vector2.ZERO:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.WALKING)
|
||||
|
||||
|
||||
func OnSitOnFurnitureTriggered(sitting_position: Vector2, sitting_direction: Enums.Directions) -> void:
|
||||
if state_machine.GetCurrentStateEnum() != GetStateEnum():
|
||||
return
|
||||
|
||||
_sit_queued = true
|
||||
_sit_queue_pos = sitting_position
|
||||
_sit_queue_dir = sitting_direction
|
||||
|
||||
|
||||
func OnCutsceneStarted() -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.CUTSCENE)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dkmc1t43gomdb
|
||||
@@ -0,0 +1,30 @@
|
||||
extends BaseState
|
||||
class_name PlayerPlayAnimationState
|
||||
|
||||
signal PlayAnimation(animation_name: String)
|
||||
signal AnimationFinished(animation_name: String)
|
||||
|
||||
var current_animation_name: String
|
||||
|
||||
# Public Methods
|
||||
func GetAnimationBaseName() -> String:
|
||||
return "idle"
|
||||
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.PLAY_ANIMATION
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
current_animation_name = _extra_parameters["animation_name"]
|
||||
print("Playing Player Animation State: [%s]" % current_animation_name)
|
||||
PlayAnimation.emit(current_animation_name)
|
||||
|
||||
|
||||
func Exit() -> void:
|
||||
current_animation_name = ''
|
||||
|
||||
|
||||
func OnAnimationFinished(animation_name: String) -> void:
|
||||
if animation_name != current_animation_name: return
|
||||
AnimationFinished.emit(animation_name)
|
||||
@@ -0,0 +1 @@
|
||||
uid://wfdtd3xlgrvm
|
||||
25
Entities/Characters/Player/Scripts/States/sitting_state.gd
Normal file
25
Entities/Characters/Player/Scripts/States/sitting_state.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends BaseState
|
||||
|
||||
@onready var player: PlayerCharacter = $"../../.."
|
||||
@onready var facing_direction_component: FacingDirectionComponent = $"../../../Components/FacingDirectionComponent"
|
||||
|
||||
func GetAnimationBaseName() -> String:
|
||||
return "idle"
|
||||
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.SITTING
|
||||
|
||||
|
||||
func Enter(extra_parameters: Dictionary) -> void:
|
||||
var pos := extra_parameters["pos"] as Vector2
|
||||
var dir := extra_parameters["dir"] as Enums.Directions
|
||||
|
||||
player.position = pos
|
||||
facing_direction_component.SetDirectionManually(dir)
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
if Input.is_action_just_pressed("player_interact"):
|
||||
player.position = Vector2(player.position.x, player.position.y + 16)
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bx1a35al4yiej
|
||||
@@ -0,0 +1,15 @@
|
||||
extends BaseState
|
||||
|
||||
@export var body: CharacterBody2D
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.USING_ITEM_A
|
||||
|
||||
|
||||
func GetAnimationBaseName() -> String:
|
||||
return "idle"
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.DRAWING_BOW, { "action_name": "use_item_a" })
|
||||
@@ -0,0 +1 @@
|
||||
uid://ckn7gmtc23b8l
|
||||
27
Entities/Characters/Player/Scripts/States/walking_state.gd
Normal file
27
Entities/Characters/Player/Scripts/States/walking_state.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends BaseState
|
||||
|
||||
signal StartedWalking
|
||||
|
||||
@export var walking_speed := 100
|
||||
@export var movement_component: MovementComponent
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
@export var body: CharacterBody2D
|
||||
|
||||
func GetStateEnum() -> PlayerStateMachine.States:
|
||||
return PlayerStateMachine.States.WALKING
|
||||
|
||||
|
||||
func Enter(_extra_parameters: Dictionary) -> void:
|
||||
StartedWalking.emit()
|
||||
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
if movement_component.movement_vector == Vector2.ZERO:
|
||||
state_machine.QueueStateChange(PlayerStateMachine.States.IDLE)
|
||||
return
|
||||
|
||||
var movement_vector := movement_component.movement_vector
|
||||
body.velocity = movement_vector * walking_speed
|
||||
body.move_and_slide()
|
||||
|
||||
direction_component.ChangeDirectionUsingMovementVector(movement_vector)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bwmmah30t3m0u
|
||||
28
Entities/Characters/Player/Scripts/interact_scanner.gd
Normal file
28
Entities/Characters/Player/Scripts/interact_scanner.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends Area2D
|
||||
class_name InteractScanner
|
||||
|
||||
signal InteractionActionTriggered()
|
||||
|
||||
@export var parent: Node2D
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
@export var disable_interactions := false
|
||||
|
||||
# Public Methods
|
||||
func OnDirectionChanged() -> void:
|
||||
var direction := direction_component.GetCurrentDirection()
|
||||
if direction == Enums.Directions.LEFT:
|
||||
parent.rotation = deg_to_rad(90)
|
||||
elif direction == Enums.Directions.RIGHT:
|
||||
parent.rotation = deg_to_rad(-90)
|
||||
elif direction == Enums.Directions.UP:
|
||||
parent.rotation = deg_to_rad(180)
|
||||
else:
|
||||
parent.rotation = deg_to_rad(0)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if disable_interactions:
|
||||
return
|
||||
if Input.is_action_just_pressed("player_interact"):
|
||||
InputManager.IgnoreAction("player_interact")
|
||||
InteractionActionTriggered.emit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://brlisuoocwehh
|
||||
18
Entities/Characters/Player/Scripts/movement_component.gd
Normal file
18
Entities/Characters/Player/Scripts/movement_component.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
@@ -0,0 +1 @@
|
||||
uid://dwclkwbig1uii
|
||||
18
Entities/Characters/Player/Scripts/player.gd
Normal file
18
Entities/Characters/Player/Scripts/player.gd
Normal 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)
|
||||
1
Entities/Characters/Player/Scripts/player.gd.uid
Normal file
1
Entities/Characters/Player/Scripts/player.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dacvayqstkvws
|
||||
78
Entities/Characters/Player/Scripts/sprite.gd
Normal file
78
Entities/Characters/Player/Scripts/sprite.gd
Normal file
@@ -0,0 +1,78 @@
|
||||
extends Node2D
|
||||
class_name PlayerSprite
|
||||
|
||||
# Signals
|
||||
signal DrawingBowAnimationFinished
|
||||
signal FiringArrowAnimationFinished
|
||||
signal AnimationFinished(animation_name: String)
|
||||
|
||||
# Exports
|
||||
@export var state_machine: PlayerStateMachine
|
||||
@export var direction_component: FacingDirectionComponent
|
||||
|
||||
# OnReady Variables
|
||||
@onready var full: AnimatedSprite2D = $Full
|
||||
|
||||
# Private Variables
|
||||
var _all_parts: Array[AnimatedSprite2D]
|
||||
var _current_animation := "idle-down"
|
||||
var _is_flipped := false
|
||||
|
||||
# Public Methods
|
||||
func UpdateSprite() -> void:
|
||||
var current_state := state_machine.current_state
|
||||
var current_direction := direction_component.GetCurrentDirection()
|
||||
var animation := _build_animation_name(current_state, current_direction)
|
||||
var should_flip := _should_flip_horizontal()
|
||||
|
||||
if animation == _current_animation and should_flip == _is_flipped:
|
||||
return
|
||||
|
||||
_current_animation = animation
|
||||
_is_flipped = should_flip
|
||||
|
||||
for part in _all_parts:
|
||||
part.animation = animation
|
||||
part.play()
|
||||
part.flip_h = should_flip
|
||||
|
||||
|
||||
func OnAnimationFinished() -> void:
|
||||
if _current_animation.begins_with("drawing-bow-"):
|
||||
DrawingBowAnimationFinished.emit()
|
||||
elif _current_animation.begins_with("firing-arrow-"):
|
||||
FiringArrowAnimationFinished.emit()
|
||||
AnimationFinished.emit(_current_animation)
|
||||
|
||||
|
||||
func PlaySpecifiedAnimation(animation_name: String) -> void:
|
||||
_current_animation = animation_name
|
||||
for part in _all_parts:
|
||||
part.animation = animation_name
|
||||
part.play()
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
_all_parts = [
|
||||
full
|
||||
]
|
||||
|
||||
UpdateSprite()
|
||||
|
||||
|
||||
func _build_animation_name(state: BaseState, direction: Enums.Directions) -> String:
|
||||
# e.g. "idle-down", "walking-up"
|
||||
var state_str := state.GetAnimationBaseName().replace("_", "-")
|
||||
var direction_str := _direction_to_animation_state(direction)
|
||||
return "%s-%s" % [state_str, direction_str]
|
||||
|
||||
|
||||
func _direction_to_animation_state(direction: Enums.Directions) -> String:
|
||||
if direction == Enums.Directions.LEFT or direction == Enums.Directions.RIGHT:
|
||||
return "side"
|
||||
return Enums.Directions.keys()[direction].to_lower()
|
||||
|
||||
|
||||
func _should_flip_horizontal() -> bool:
|
||||
return direction_component.GetCurrentDirection() == Enums.Directions.LEFT
|
||||
1
Entities/Characters/Player/Scripts/sprite.gd.uid
Normal file
1
Entities/Characters/Player/Scripts/sprite.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cuar23q48cbja
|
||||
58
Entities/Characters/Player/Scripts/state_machine.gd
Normal file
58
Entities/Characters/Player/Scripts/state_machine.gd
Normal file
@@ -0,0 +1,58 @@
|
||||
extends Node
|
||||
class_name PlayerStateMachine
|
||||
|
||||
signal StateChanged
|
||||
|
||||
enum States {
|
||||
UNSET, IDLE, WALKING, USING_ITEM_A, DRAWING_BOW, FIRING_ARROW,
|
||||
SITTING, CUTSCENE, PLAY_ANIMATION
|
||||
}
|
||||
|
||||
@export var states_container: Node
|
||||
@export var current_state: BaseState
|
||||
|
||||
var state_dict := {}
|
||||
var queued_state: PlayerStateMachine.States = PlayerStateMachine.States.UNSET
|
||||
var queued_parameters: Dictionary = {}
|
||||
|
||||
# Public Methods
|
||||
func GetCurrentStateEnum() -> States:
|
||||
return current_state.GetStateEnum()
|
||||
|
||||
|
||||
func QueueStateChange(to_state_enum: PlayerStateMachine.States, extra_parameters: Dictionary = {}) -> void:
|
||||
queued_state = to_state_enum
|
||||
queued_parameters = extra_parameters
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var children := states_container.get_children()
|
||||
for child in children:
|
||||
if child is not BaseState:
|
||||
continue
|
||||
var state := child as BaseState
|
||||
state_dict[state.GetStateEnum()] = state
|
||||
|
||||
if current_state:
|
||||
current_state.Enter({})
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if current_state:
|
||||
current_state.Update(delta)
|
||||
|
||||
if queued_state != PlayerStateMachine.States.UNSET:
|
||||
_swap_state()
|
||||
|
||||
|
||||
func _swap_state() -> void:
|
||||
if current_state:
|
||||
current_state.Exit()
|
||||
|
||||
current_state = state_dict[queued_state] as BaseState
|
||||
current_state.Enter(queued_parameters)
|
||||
queued_state = PlayerStateMachine.States.UNSET
|
||||
queued_parameters = {}
|
||||
|
||||
StateChanged.emit()
|
||||
1
Entities/Characters/Player/Scripts/state_machine.gd.uid
Normal file
1
Entities/Characters/Player/Scripts/state_machine.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c74mhfemxuuco
|
||||
135
Entities/Characters/Player/player.tscn
Normal file
135
Entities/Characters/Player/player.tscn
Normal file
@@ -0,0 +1,135 @@
|
||||
[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"]
|
||||
40
Entities/Characters/Player/player_bow_sprite.tscn
Normal file
40
Entities/Characters/Player/player_bow_sprite.tscn
Normal file
@@ -0,0 +1,40 @@
|
||||
[gd_scene format=3 uid="uid://cbog2vcpvg734"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dxycty45yvcdq" path="res://Assets/Spritesheets/Player/Tools/Wooden_Bow.png" id="1_b6p0h"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yka8g"]
|
||||
atlas = ExtResource("1_b6p0h")
|
||||
region = Rect2(0, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8vxy0"]
|
||||
atlas = ExtResource("1_b6p0h")
|
||||
region = Rect2(64, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_26j7r"]
|
||||
atlas = ExtResource("1_b6p0h")
|
||||
region = Rect2(128, 0, 64, 64)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_a2gi6"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yka8g")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8vxy0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_26j7r")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"draw-bow-down",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="Player Bow Sprite" type="Node2D" unique_id=1297275413]
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1622645109]
|
||||
sprite_frames = SubResource("SpriteFrames_a2gi6")
|
||||
animation = &"draw-bow-down"
|
||||
frame = 2
|
||||
frame_progress = 1.0
|
||||
1756
Entities/Characters/Player/sprite.tscn
Normal file
1756
Entities/Characters/Player/sprite.tscn
Normal file
File diff suppressed because it is too large
Load Diff
6
Entities/Characters/Player/state_machine.tscn
Normal file
6
Entities/Characters/Player/state_machine.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://c2ydbmmvnfca6"]
|
||||
|
||||
[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]
|
||||
script = ExtResource("1_clu2m")
|
||||
Reference in New Issue
Block a user