Compare commits

..

No commits in common. "ae9256f08325314649ba05679a435d1be35ed0fb" and "d7cb6fa877ce9621553f7966b3ce4357a524f4a2" have entirely different histories.

11 changed files with 27 additions and 119 deletions

View File

@ -19,4 +19,3 @@ position = Vector2( 208, 20 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="PlayerE" parent="." instance=ExtResource( 1 )] [node name="PlayerE" parent="." instance=ExtResource( 1 )]
position = Vector2( 112, 56 )

View File

@ -18,7 +18,7 @@ onready var sound_effect_player: AudioStreamPlayer = $SE_Player
onready var movement_component: Movement_StateReceiver = $Movement_StateReceiver onready var movement_component: Movement_StateReceiver = $Movement_StateReceiver
#onready var movement_state_machine: StateMachineAnimatedActor = $movement_state_machine #onready var movement_state_machine: StateMachineAnimatedActor = $movement_state_machine
onready var movement_state_machine: StateMachine = $Movement_StateMachine onready var movement_state_machine: StateMachine = $movement_state_machine
var sound_effects_dict: Dictionary var sound_effects_dict: Dictionary

View File

@ -35,10 +35,6 @@ func _ready():
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change") get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
self.connect("animation_finished",self,"_on_animation_finished") self.connect("animation_finished",self,"_on_animation_finished")
#set current state since State machine might have set state before this
# processed
current_state = get_node(callable_state_machine).current_state
# Sprites should only have a process function # Sprites should only have a process function
# but if I have this will the sprite still animate? # but if I have this will the sprite still animate?
func _process(delta): func _process(delta):
@ -47,10 +43,6 @@ func _process(delta):
print("You're out of time! I saw it!") print("You're out of time! I saw it!")
request_state_change.call_func('idle') request_state_change.call_func('idle')
#play() #play()
else:
print("what, no current_state?")
if has_method('_state_process_' + current_state.name):
call('_state_process_' + current_state.name)
process_animations() process_animations()
func _on_animation_finished(): func _on_animation_finished():

View File

@ -19,7 +19,7 @@ export var callable_state_machine :NodePath
var request_state_change: FuncRef var request_state_change: FuncRef
onready var desired_movement_vector: Vector2 = Vector2(0,0) onready var desired_movement_vector: Vector2 = Vector2(0,0)
var current_movement_state: String var current_movement_state:String
# Since animactor state machine can actually view properties from this type # Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player. # I'm thinking about moving the velocity tracker in here instead of player.
@ -43,23 +43,19 @@ const RIGHT = 1.0
func _ready(): func _ready():
request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state') request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state')
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change") get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
current_state = get_node(callable_state_machine).current_state
############ ############
# These get called by the parent # These get called by the parent
############ ############
func process_physics(delta): func process_physics(delta):
move_actor_as_desired(delta) move_actor_as_desired(delta)
if has_method('_state_process_physics_' + current_state.name):
call('_state_process_physics_' + current_state.name)
# Shouldn't need a proces function # Shouldn't need a proces function
#func process(delta): #func process(delta):
# pass # pass
func process_input(event: InputEvent): func process_input(event: InputEvent):
if has_method('_state_process_input_' + current_state.name): pass
call('_state_process_input_' + current_state.name)
############ ############

View File

@ -76,7 +76,6 @@ func change_to_known_state(new_state_name: String) -> void:
change_state(states_index["default"]) change_state(states_index["default"])
func get_state_reference(state_name: String) -> State: func get_state_reference(state_name: String) -> State:
print ("what you want? ", state_name)
if states_index.has(state_name): if states_index.has(state_name):
return states_index[state_name] return states_index[state_name]
return null return null

View File

@ -1,19 +1,29 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://lib/classes/animated_sprite_state_receiver.gd" type="Script" id=1]
[ext_resource path="res://lib/classes/state_machine.gd" type="Script" id=2] [ext_resource path="res://lib/classes/state_machine.gd" type="Script" id=2]
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=4]
[ext_resource path="res://lib/classes/movement_state_receiver.gd" type="Script" id=5] [ext_resource path="res://lib/classes/movement_state_receiver.gd" type="Script" id=5]
[ext_resource path="res://lib/classes/actor.gd" type="Script" id=8] [ext_resource path="res://lib/classes/actor.gd" type="Script" id=8]
[sub_resource type="Resource" id=1]
script = ExtResource( 4 )
debug_state = false
timeout_seconds = 2.0
name = "idle"
move_speed = 60.0
move_acceleration = 0.0
move_speed_modifier = 0.0
move_modifier_move_acceleration = 0.0
jerk_factor = 0.0
animation_sequence = [ "idle", "Max Height" ]
emitter_frame_subscriptions = {
}
[node name="ActorTemplate" type="KinematicBody2D"] [node name="ActorTemplate" type="KinematicBody2D"]
collision_layer = 2 collision_layer = 2
script = ExtResource( 8 ) script = ExtResource( 8 )
[node name="Movement_StateMachine" type="Node" parent="."]
script = ExtResource( 2 )
[node name="AnimatedSprite_StateReceiver" type="AnimatedSprite" parent="."] [node name="AnimatedSprite_StateReceiver" type="AnimatedSprite" parent="."]
script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_aseprite_wizard_config_": { "_aseprite_wizard_config_": {
"layer": "", "layer": "",
@ -27,10 +37,14 @@ __meta__ = {
"source": "" "source": ""
} }
} }
callable_state_machine = NodePath("../Movement_StateMachine")
[node name="Movement_StateReceiver" type="Node" parent="."] [node name="Movement_StateReceiver" type="Node" parent="."]
script = ExtResource( 5 ) script = ExtResource( 5 )
callable_state_machine = NodePath("../Movement_StateMachine") callable_state_machine = NodePath("../Movement_StateMachine")
[node name="Movement_StateMachine" type="Node" parent="."]
script = ExtResource( 2 )
starting_state_name = "idle"
states = [ SubResource( 1 ) ]
[node name="SE_Player" type="AudioStreamPlayer" parent="."] [node name="SE_Player" type="AudioStreamPlayer" parent="."]

View File

@ -1,16 +0,0 @@
extends AnimatedSprite_StateReceiver
func _ready():
# Lets see if this nutty thing works
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
state_ref.connect("state_entered", self, "_on_state_entered_idle")
# It works but node order really mattered.
# State machine needed to be processed first probably for ready function.
# good to know!
# I don't need this right now but I proved it can be done!
#func _state_process_idle():
# print("I got called!")
func _on_state_entered_idle():
print("Anim Knows Idle State Entered!")

View File

@ -1,22 +0,0 @@
extends Movement_StateReceiver
func _ready():
# Lets see if this nutty thing works
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
state_ref.connect("state_entered", self, "_on_state_entered_idle")
# It works but node order really mattered.
# State machine needed to be processed first probably for ready function.
# good to know!
var fire_a_note:bool = false
# I don't need this right now but I proved it can be done!
func _state_process_physics_idle():
if fire_a_note == true:
print("I got called! (MC)")
fire_a_note = false
func _on_state_entered_idle():
print("Movement State Idle State Entered!")
fire_a_note = true

View File

@ -1,16 +0,0 @@
extends Actor
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -1,26 +1,13 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2] [ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
[ext_resource path="res://src/actors/players/playerE/PlayerE.gd" type="Script" id=3]
[ext_resource path="res://src/actors/players/playerE/states/idle.tres" type="Resource" id=4]
[ext_resource path="res://src/actors/players/playerE/PlayerE-AnimatedSprite_StateReceiver.gd" type="Script" id=5]
[ext_resource path="res://src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd" type="Script" id=6]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 14 )
[node name="PlayerE" instance=ExtResource( 1 )] [node name="PlayerE" instance=ExtResource( 1 )]
script = ExtResource( 3 )
actor_type = "Player" actor_type = "Player"
[node name="Movement_StateMachine" parent="." index="0"] [node name="AnimatedSprite_StateReceiver" parent="." index="0"]
starting_state_name = "idle"
states = [ ExtResource( 4 ) ]
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
frames = ExtResource( 2 ) frames = ExtResource( 2 )
script = ExtResource( 5 )
__meta__ = { __meta__ = {
"_aseprite_wizard_config_": { "_aseprite_wizard_config_": {
"layer": "", "layer": "",
@ -34,10 +21,3 @@ __meta__ = {
"source": "/home/relay01/Assets/Library/Asset Packs 1-5/Asset Packs 1-4 (final)/Asset Pack-V1/Player Run/player run 48x48.aseprite" "source": "/home/relay01/Assets/Library/Asset Packs 1-5/Asset Packs 1-4 (final)/Asset Pack-V1/Player Run/player run 48x48.aseprite"
} }
} }
[node name="Movement_StateReceiver" parent="." index="2"]
script = ExtResource( 6 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"]
position = Vector2( 0, 2 )
shape = SubResource( 1 )

View File

@ -1,18 +0,0 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
[resource]
resource_name = "idle"
script = ExtResource( 1 )
debug_state = false
timeout_seconds = 2.0
name = "idle"
move_speed = 60.0
move_acceleration = 0.0
move_speed_modifier = 0.0
move_modifier_move_acceleration = 0.0
jerk_factor = 0.0
animation_sequence = [ "idle" ]
emitter_frame_subscriptions = {
}