Working resource based state machine. All existing states are broken.
This commit is contained in:
parent
8fa6a6f370
commit
03e740c7d1
|
|
@ -1,14 +1,14 @@
|
||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/Player.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 208, 20 )
|
extents = Vector2( 208, 20 )
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
[node name="ActorTemplate" parent="." instance=ExtResource( 1 )]
|
||||||
position = Vector2( 147, 101 )
|
position = Vector2( 152, 64 )
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="."]
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
margin_top = 160.0
|
margin_top = 160.0
|
||||||
|
|
|
||||||
BIN
assets/actors/players/playerE/Player Idle 48x48.png
Normal file
BIN
assets/actors/players/playerE/Player Idle 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
35
assets/actors/players/playerE/Player Idle 48x48.png.import
Normal file
35
assets/actors/players/playerE/Player Idle 48x48.png.import
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Player Idle 48x48.png-eec2a2bcc99a731fac49b2105239676a.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/actors/players/playerE/Player Idle 48x48.png"
|
||||||
|
dest_files=[ "res://.import/Player Idle 48x48.png-eec2a2bcc99a731fac49b2105239676a.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
||||||
|
|
@ -75,10 +75,11 @@ func play_sound_frame(animation: String, frame: int ):
|
||||||
|
|
||||||
func attack():
|
func attack():
|
||||||
#print(self.name, ": It's not inheritence, it's funcrefs")
|
#print(self.name, ": It's not inheritence, it's funcrefs")
|
||||||
if movement_state_machine.current_state.name != 'attack':
|
# if movement_state_machine.current_state.name != 'attack':
|
||||||
if($movement_state_machine/attack):
|
# if($movement_state_machine/attack):
|
||||||
movement_state_machine.change_state($movement_state_machine/attack)
|
# movement_state_machine.change_state($movement_state_machine/attack)
|
||||||
if ($Hitbox_Component/CollisionShape2D):
|
# if ($Hitbox_Component/CollisionShape2D):
|
||||||
#print(self.name, ": Found a hitbox")
|
# #print(self.name, ": Found a hitbox")
|
||||||
var hit_box = $Hitbox_Component
|
# var hit_box = $Hitbox_Component
|
||||||
hit_box.set_hitbox(true)
|
# hit_box.set_hitbox(true)
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class_name State
|
class_name State
|
||||||
extends Node
|
extends Resource
|
||||||
|
|
||||||
export var debug_state: bool = false
|
export var debug_state: bool = false
|
||||||
export var timeout_seconds: float = 0.0
|
export var timeout_seconds: float = 0.0
|
||||||
|
|
@ -8,27 +8,46 @@ signal state_entered()
|
||||||
signal state_exited()
|
signal state_exited()
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
# Declare member variables here. Examples:
|
||||||
#var modifier_stack_ref: Array # Well this didn't work
|
|
||||||
var state_timeout: Timer
|
var state_timeout: Timer
|
||||||
var state_ready: bool = true
|
var state_ready: bool = true
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
var name: String
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
# Resources don't have _ready callbacks I think
|
||||||
|
# You'd have to use the constructor callback _init
|
||||||
|
#func _ready():
|
||||||
|
# pass # Replace with function body.
|
||||||
|
|
||||||
|
#func _init():
|
||||||
|
# print ("Am I really a parent's constructor?")
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
##TODO: this bit me in the butt. Should add a safety or something.
|
||||||
|
# Only add timout node if timer value was specified.
|
||||||
|
if(timeout_seconds > 0.0):
|
||||||
|
state_timeout = Timer.new()
|
||||||
|
state_timeout.wait_time = timeout_seconds
|
||||||
|
state_timeout.one_shot = true
|
||||||
|
state_timeout.autostart = false
|
||||||
|
#add_child(state_timeout)
|
||||||
|
#get_tree().get_root().add_child(state_timeout)
|
||||||
|
#TODO: Need to figure out how to add this to tree
|
||||||
|
print ("State init called for no reason?")
|
||||||
|
#modifier = StateModifier.new()
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func exit() -> void:
|
func exit() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func process_input(_event: InputEvent) -> State:
|
func process_input(_event: InputEvent) -> String:
|
||||||
return null
|
return ''
|
||||||
|
|
||||||
func process_frame(_delta: float) -> State:
|
func process_frame(_delta: float) -> String:
|
||||||
return null
|
return ''
|
||||||
|
|
||||||
func process_physics(_delta: float) -> State:
|
func process_physics(_delta: float) -> String:
|
||||||
return null
|
return ''
|
||||||
|
|
|
||||||
|
|
@ -65,21 +65,6 @@ var previous_speed_multiplier: float
|
||||||
|
|
||||||
var modifier: StateModifier
|
var modifier: StateModifier
|
||||||
|
|
||||||
#var animation_sequence_timer: Timer
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
##TODO: this bit me in the butt. Should add a safety or something.
|
|
||||||
# Only add timout node if timer value was specified.
|
|
||||||
if(timeout_seconds > 0.0):
|
|
||||||
state_timeout = Timer.new()
|
|
||||||
state_timeout.wait_time = timeout_seconds
|
|
||||||
state_timeout.one_shot = true
|
|
||||||
state_timeout.autostart = false
|
|
||||||
add_child(state_timeout)
|
|
||||||
|
|
||||||
#modifier = StateModifier.new()
|
|
||||||
|
|
||||||
# If called, this will attempt to make the most appropriate animation change
|
# If called, this will attempt to make the most appropriate animation change
|
||||||
# would likely be triggered from an animation sequence finishing or a
|
# would likely be triggered from an animation sequence finishing or a
|
||||||
|
|
@ -192,8 +177,8 @@ func transfer_modifiers(exiting_state_modifier : StateModifier):
|
||||||
else:
|
else:
|
||||||
print("Insert modifier merge function here...")
|
print("Insert modifier merge function here...")
|
||||||
|
|
||||||
func process_input(_event: InputEvent) -> State:
|
func process_input(_event: InputEvent) -> String:
|
||||||
return null
|
return ''
|
||||||
|
|
||||||
func process_animations():
|
func process_animations():
|
||||||
|
|
||||||
|
|
@ -249,12 +234,12 @@ func process_animations():
|
||||||
else:
|
else:
|
||||||
frame_signal_emitted = false
|
frame_signal_emitted = false
|
||||||
|
|
||||||
func process_frame(_delta: float) -> State:
|
func process_frame(_delta: float) -> String:
|
||||||
return null
|
return ''
|
||||||
|
|
||||||
func process_physics(_delta: float) -> State:
|
func process_physics(_delta: float) -> String:
|
||||||
move_actor_as_desired(_delta)
|
move_actor_as_desired(_delta)
|
||||||
return null
|
return ''
|
||||||
|
|
||||||
#func _on_AnimatedSprite_animation_finished():
|
#func _on_AnimatedSprite_animation_finished():
|
||||||
# if animations.frames.get_animation_loop(animations.animation) == false:
|
# if animations.frames.get_animation_loop(animations.animation) == false:
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,34 @@
|
||||||
class_name StateMachine extends Node
|
class_name StateMachine extends Node
|
||||||
|
|
||||||
export (NodePath) var starting_state
|
#export (NodePath) var starting_state
|
||||||
export var debug_state_machine: bool = false
|
export var debug_state_machine: bool = false
|
||||||
|
|
||||||
|
# I guess I would declare a number of states here
|
||||||
|
#export (Reference) var states # Doesn't work
|
||||||
|
#var starting_state: State
|
||||||
|
|
||||||
var current_state: State
|
var current_state: State
|
||||||
#var state_modifiers: Array
|
#var state_modifiers: Array
|
||||||
|
export(Dictionary) var states :Dictionary
|
||||||
|
|
||||||
# Initialize the state machine by giving each child state a reference to the
|
# Initialize the state machine by giving each child state a reference to the
|
||||||
# parent object it belongs to and enter the default starting_state.
|
# parent object it belongs to and enter the default starting_state.
|
||||||
func init() -> void:
|
func init() -> void:
|
||||||
for child in get_children():
|
# for child in get_children():
|
||||||
if child is State:
|
# if child is State:
|
||||||
if debug_state_machine:
|
# if debug_state_machine:
|
||||||
print("Initializing State Node: ", child.name)
|
# print("Initializing State Node: ", child.name)
|
||||||
# child.modifier_stack_ref = state_modifiers
|
## child.modifier_stack_ref = state_modifiers
|
||||||
if debug_state_machine:
|
# if debug_state_machine:
|
||||||
child.debug_state = true
|
# child.debug_state = true
|
||||||
|
|
||||||
|
for s in states.keys():
|
||||||
|
var this_state = states.s
|
||||||
|
if this_state is State:
|
||||||
|
if debug_state_machine:
|
||||||
|
print("Initializing State Node: ", s)
|
||||||
|
this_state.debug_state = true
|
||||||
|
|
||||||
# Initialize to the default state
|
|
||||||
change_state(get_node(starting_state))
|
|
||||||
|
|
||||||
# Change to the new state by first calling any exit logic on the current state.
|
# Change to the new state by first calling any exit logic on the current state.
|
||||||
func change_state(new_state: State) -> void:
|
func change_state(new_state: State) -> void:
|
||||||
|
|
@ -31,13 +41,19 @@ func change_state(new_state: State) -> void:
|
||||||
# print("Active Modifiers:")
|
# print("Active Modifiers:")
|
||||||
# for mods in state_modifiers:
|
# for mods in state_modifiers:
|
||||||
# print(mods.name)
|
# print(mods.name)
|
||||||
|
|
||||||
|
func change_to_known_state(new_state_name: String) -> void:
|
||||||
|
if new_state_name.empty() == false:
|
||||||
|
if states.has(new_state_name):
|
||||||
|
change_state(states[new_state_name])
|
||||||
|
else:
|
||||||
|
push_warning("Attempt to switch state to unknown: " + new_state_name + get_parent().name)
|
||||||
|
change_state(states["default"])
|
||||||
|
|
||||||
# Pass through functions for the Player to call,
|
# Pass through functions for the Player to call,
|
||||||
# handling state changes as needed.
|
# handling state changes as needed.
|
||||||
func process_physics(delta: float) -> void:
|
func process_physics(delta: float) -> void:
|
||||||
var new_state = current_state.process_physics(delta)
|
change_to_known_state( current_state.process_physics(delta) )
|
||||||
if new_state:
|
|
||||||
change_state(new_state)
|
|
||||||
|
|
||||||
func process_input(event: InputEvent) -> void:
|
func process_input(event: InputEvent) -> void:
|
||||||
var new_state = current_state.process_input(event)
|
var new_state = current_state.process_input(event)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
class_name StateMachineAnimatedActor extends StateMachine
|
class_name StateMachineAnimatedActor extends StateMachine
|
||||||
|
|
||||||
#var physics_modifier : StateModifier
|
|
||||||
|
|
||||||
func change_state(new_state: State) -> void:
|
func change_state(new_state: State) -> void:
|
||||||
if new_state.state_ready == false:
|
if new_state.state_ready == false:
|
||||||
# Don't transition to unready state
|
# Don't transition to unready state
|
||||||
|
|
@ -39,19 +37,43 @@ func set_previous_animation( old_state: StateAnimatedActor, new_state: StateAnim
|
||||||
# parent object it belongs to and enter the default starting_state.
|
# parent object it belongs to and enter the default starting_state.
|
||||||
func init_animated_actor(parent: KinematicBody2D, animations: AnimatedSprite, move_component: MovementComponent) -> void:
|
func init_animated_actor(parent: KinematicBody2D, animations: AnimatedSprite, move_component: MovementComponent) -> void:
|
||||||
animations.connect("animation_finished", self, "_on_AnimatedSprite_animation_finished")
|
animations.connect("animation_finished", self, "_on_AnimatedSprite_animation_finished")
|
||||||
for child in get_children():
|
# for child in get_children():
|
||||||
|
# if child is StateAnimatedActor:
|
||||||
|
# if debug_state_machine:
|
||||||
|
# print("Initializing State Node for ", parent.name, ": ", child.name)
|
||||||
|
# child.parent = parent
|
||||||
|
# child.animations = animations
|
||||||
|
# child.move_component = move_component
|
||||||
|
## child.modifier_stack_ref = state_modifiers
|
||||||
|
# if debug_state_machine:
|
||||||
|
# child.debug_state = true
|
||||||
|
#states["default"] = StateAnimatedActor.new()
|
||||||
|
for s in states.keys():
|
||||||
|
var child = states[s]
|
||||||
if child is StateAnimatedActor:
|
if child is StateAnimatedActor:
|
||||||
if debug_state_machine:
|
if debug_state_machine:
|
||||||
print("Initializing State Node for ", parent.name, ": ", child.name)
|
print("Initializing State Node for ", parent.name, ": ", s)
|
||||||
|
child.debug_state = true
|
||||||
child.parent = parent
|
child.parent = parent
|
||||||
child.animations = animations
|
child.animations = animations
|
||||||
child.move_component = move_component
|
child.move_component = move_component
|
||||||
# child.modifier_stack_ref = state_modifiers
|
child.name = s
|
||||||
if debug_state_machine:
|
|
||||||
child.debug_state = true
|
if states.has("default"):
|
||||||
|
print("I still haz default state")
|
||||||
|
change_state(states.default)
|
||||||
|
# current_state = states.default
|
||||||
|
# if current_state is StateAnimatedActor:
|
||||||
|
# current_state.animations = animations
|
||||||
|
# current_state.parent = parent
|
||||||
|
# current_state.move_component = move_component
|
||||||
|
# current_state.enter()
|
||||||
|
# #current_state.set_script("res://lib/templates/Actor/states/idle.gd")
|
||||||
|
|
||||||
# Initialize to the default state
|
# Initialize to the default state
|
||||||
change_state(get_node(starting_state))
|
#change_state(get_node(starting_state))
|
||||||
|
|
||||||
|
#change_state(states.default)
|
||||||
|
|
||||||
|
|
||||||
func process_frame(delta: float) -> void:
|
func process_frame(delta: float) -> void:
|
||||||
|
|
@ -89,10 +111,8 @@ func process_frame(delta: float) -> void:
|
||||||
# state_modifiers.pop_at(i)
|
# state_modifiers.pop_at(i)
|
||||||
if current_state is StateAnimatedActor:
|
if current_state is StateAnimatedActor:
|
||||||
current_state.process_animations()
|
current_state.process_animations()
|
||||||
var new_state = current_state.process_frame(delta)
|
change_to_known_state( current_state.process_frame(delta) )
|
||||||
if new_state:
|
|
||||||
change_state(new_state)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_AnimatedSprite_animation_finished():
|
func _on_AnimatedSprite_animation_finished():
|
||||||
# if debug_state_machine:
|
# if debug_state_machine:
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,44 @@
|
||||||
[gd_scene load_steps=17 format=2]
|
[gd_scene load_steps=15 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://lib/components/Hurtbox_Component.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/components/Hurtbox_Component.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://lib/classes/state_machine_animated_actor.gd" type="Script" id=2]
|
[ext_resource path="res://lib/classes/state_machine_animated_actor.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://lib/templates/Actor/states/fall.gd" type="Script" id=3]
|
[ext_resource path="res://lib/templates/Actor/states/idle.tres" type="Resource" id=4]
|
||||||
[ext_resource path="res://lib/templates/Actor/states/idle.gd" type="Script" id=4]
|
|
||||||
[ext_resource path="res://src/classes/movement_component.gd" type="Script" id=5]
|
[ext_resource path="res://src/classes/movement_component.gd" type="Script" id=5]
|
||||||
[ext_resource path="res://lib/templates/Actor/resources/Smiley.png" type="Texture" id=6]
|
|
||||||
[ext_resource path="res://lib/templates/Actor/states/move.gd" type="Script" id=7]
|
|
||||||
[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="AtlasTexture" id=76]
|
[sub_resource type="StreamTexture" id=83]
|
||||||
atlas = ExtResource( 6 )
|
load_path = "res://.import/Player Idle 48x48.png-eec2a2bcc99a731fac49b2105239676a.stex"
|
||||||
region = Rect2( 0, 0, 32, 32 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=77]
|
[sub_resource type="AtlasTexture" id=84]
|
||||||
atlas = ExtResource( 6 )
|
atlas = SubResource( 83 )
|
||||||
region = Rect2( 32, 0, 32, 32 )
|
region = Rect2( 0, 0, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=78]
|
[sub_resource type="AtlasTexture" id=85]
|
||||||
atlas = ExtResource( 6 )
|
atlas = SubResource( 83 )
|
||||||
region = Rect2( 64, 0, 32, 32 )
|
region = Rect2( 48, 0, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=79]
|
[sub_resource type="AtlasTexture" id=86]
|
||||||
atlas = ExtResource( 6 )
|
atlas = SubResource( 83 )
|
||||||
region = Rect2( 0, 32, 32, 32 )
|
region = Rect2( 96, 0, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=80]
|
[sub_resource type="AtlasTexture" id=87]
|
||||||
atlas = ExtResource( 6 )
|
atlas = SubResource( 83 )
|
||||||
region = Rect2( 32, 32, 32, 32 )
|
region = Rect2( 0, 48, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=81]
|
[sub_resource type="AtlasTexture" id=88]
|
||||||
atlas = ExtResource( 6 )
|
atlas = SubResource( 83 )
|
||||||
region = Rect2( 64, 32, 32, 32 )
|
region = Rect2( 48, 48, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id=75]
|
[sub_resource type="AtlasTexture" id=89]
|
||||||
|
atlas = SubResource( 83 )
|
||||||
|
region = Rect2( 96, 48, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=90]
|
||||||
animations = [ {
|
animations = [ {
|
||||||
"frames": [ SubResource( 76 ), SubResource( 77 ), SubResource( 78 ), SubResource( 79 ), SubResource( 80 ), SubResource( 81 ) ],
|
"frames": [ SubResource( 84 ), SubResource( 85 ), SubResource( 86 ), SubResource( 87 ), SubResource( 87 ), SubResource( 88 ), SubResource( 84 ), SubResource( 89 ), SubResource( 89 ), SubResource( 89 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"speed": 5.0
|
"speed": 11.0
|
||||||
} ]
|
} ]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id=82]
|
[sub_resource type="CircleShape2D" id=82]
|
||||||
|
|
@ -48,20 +48,18 @@ collision_layer = 2
|
||||||
script = ExtResource( 8 )
|
script = ExtResource( 8 )
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
frames = SubResource( 75 )
|
frames = SubResource( 90 )
|
||||||
frame = 3
|
|
||||||
playing = true
|
playing = true
|
||||||
flip_h = true
|
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_aseprite_wizard_config_": {
|
"_aseprite_wizard_config_": {
|
||||||
"layer": "",
|
"layer": "",
|
||||||
"o_ex_p": "",
|
"o_ex_p": "BG",
|
||||||
"o_folder": "res://assets",
|
"o_folder": "res://assets/actors/players/playerE",
|
||||||
"o_name": "",
|
"o_name": "",
|
||||||
"only_visible": true,
|
"only_visible": true,
|
||||||
"op_exp": false,
|
"op_exp": true,
|
||||||
"slice": "",
|
"slice": "",
|
||||||
"source": "E:/Godot/Art/MegaMan.aseprite"
|
"source": "/home/relay01/Assets/Library/Asset Packs 1-5/Asset Packs 1-4 (final)/Asset Pack-V1/Player Idle/Player Idle 48x48.aseprite"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,24 +68,10 @@ script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="movement_state_machine" type="Node" parent="."]
|
[node name="movement_state_machine" type="Node" parent="."]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
starting_state = NodePath("idle")
|
debug_state_machine = true
|
||||||
|
states = {
|
||||||
[node name="idle" type="Node" parent="movement_state_machine"]
|
"default": ExtResource( 4 )
|
||||||
script = ExtResource( 4 )
|
}
|
||||||
animation_sequence = [ "default" ]
|
|
||||||
fall_node = NodePath("../fall")
|
|
||||||
move_node = NodePath("../move")
|
|
||||||
|
|
||||||
[node name="fall" type="Node" parent="movement_state_machine"]
|
|
||||||
script = ExtResource( 3 )
|
|
||||||
animation_sequence = [ "default" ]
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
|
|
||||||
[node name="move" type="Node" parent="movement_state_machine"]
|
|
||||||
script = ExtResource( 7 )
|
|
||||||
animation_sequence = [ "default" ]
|
|
||||||
fall_node = NodePath("../fall")
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
|
|
||||||
[node name="Hurtbox_Component" parent="." instance=ExtResource( 1 )]
|
[node name="Hurtbox_Component" parent="." instance=ExtResource( 1 )]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,18 @@
|
||||||
extends StateAnimatedActor
|
extends StateAnimatedActor
|
||||||
|
|
||||||
export (NodePath) var fall_node
|
# Do states need to have references to the states they want to transition
|
||||||
export (NodePath) var move_node
|
# to? I suppose if on exit/entrance we needed to do something
|
||||||
|
|
||||||
onready var fall_state: State = get_node(fall_node)
|
|
||||||
onready var move_state: State = get_node(move_node)
|
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
.enter()
|
#.enter()
|
||||||
# parent.set_hurtbox(true)
|
# parent.set_hurtbox(true)
|
||||||
move_component.velocity.x = 0
|
move_component.velocity.x = 0
|
||||||
if debug_state:
|
print ("this doesn't work does it? ")
|
||||||
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
|
# if debug_state:
|
||||||
|
# print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
|
||||||
func process_physics(delta: float) -> State:
|
|
||||||
|
|
||||||
|
func process_physics(delta: float) -> String:
|
||||||
|
return ''
|
||||||
# parent.velocity.y += gravity * delta
|
# parent.velocity.y += gravity * delta
|
||||||
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||||
# parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
# parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||||
|
|
@ -23,8 +21,8 @@ func process_physics(delta: float) -> State:
|
||||||
move_actor_as_desired(delta)
|
move_actor_as_desired(delta)
|
||||||
|
|
||||||
if move_component.velocity.x != 0.0:
|
if move_component.velocity.x != 0.0:
|
||||||
return move_state
|
return 'move'
|
||||||
|
|
||||||
if !parent.is_on_floor():
|
if !parent.is_on_floor():
|
||||||
return fall_state
|
return 'fall'
|
||||||
return null
|
return ''
|
||||||
|
|
|
||||||
17
lib/templates/Actor/states/idle.tres
Normal file
17
lib/templates/Actor/states/idle.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://lib/templates/Actor/states/idle.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
move_speed = 60.0
|
||||||
|
move_acceleration = 20.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "idle" ]
|
||||||
|
emitter_frame_subscriptions = {
|
||||||
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://src/classes/movement_component.gd"
|
"path": "res://src/classes/movement_component.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Node",
|
"base": "Resource",
|
||||||
"class": "State",
|
"class": "State",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://lib/classes/state.gd"
|
"path": "res://lib/classes/state.gd"
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,11 @@
|
||||||
[gd_scene load_steps=126 format=2]
|
[gd_scene load_steps=116 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://src/actors/players/playerD/movement_component.gd" type="Script" id=2]
|
[ext_resource path="res://src/actors/players/playerD/movement_component.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://src/actors/players/playerD/Player.gd" type="Script" id=3]
|
[ext_resource path="res://src/actors/players/playerD/Player.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/idle.gd" type="Script" id=4]
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/move.gd" type="Script" id=5]
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/fall.gd" type="Script" id=6]
|
|
||||||
[ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/jump.gd" type="Script" id=8]
|
|
||||||
[ext_resource path="res://lib/components/Modifier_Receiver.tscn" type="PackedScene" id=9]
|
[ext_resource path="res://lib/components/Modifier_Receiver.tscn" type="PackedScene" id=9]
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/attack.gd" type="Script" id=10]
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/dash.gd" type="Script" id=11]
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/hurt.gd" type="Script" id=12]
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/roll.gd" type="Script" id=14]
|
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/die.gd" type="Script" id=15]
|
|
||||||
[ext_resource path="res://lib/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16]
|
[ext_resource path="res://lib/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16]
|
||||||
[ext_resource path="res://src/actors/players/playerD/states/climb.gd" type="Script" id=17]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=197]
|
[sub_resource type="RectangleShape2D" id=197]
|
||||||
extents = Vector2( 13, 18.5 )
|
extents = Vector2( 13, 18.5 )
|
||||||
|
|
@ -557,7 +547,6 @@ shape = SubResource( 197 )
|
||||||
position = Vector2( -1, -51 )
|
position = Vector2( -1, -51 )
|
||||||
frames = SubResource( 196 )
|
frames = SubResource( 196 )
|
||||||
animation = "idle_shoot"
|
animation = "idle_shoot"
|
||||||
flip_h = false
|
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_aseprite_wizard_config_": {
|
"_aseprite_wizard_config_": {
|
||||||
"layer": "",
|
"layer": "",
|
||||||
|
|
@ -576,89 +565,6 @@ script = ExtResource( 2 )
|
||||||
player_number = 1
|
player_number = 1
|
||||||
interactable_node = NodePath("../Interactable_Receiver")
|
interactable_node = NodePath("../Interactable_Receiver")
|
||||||
|
|
||||||
[node name="idle" parent="movement_state_machine" index="0"]
|
|
||||||
script = ExtResource( 4 )
|
|
||||||
debug_state = true
|
|
||||||
move_speed = 0.0
|
|
||||||
animation_sequence = [ "idle" ]
|
|
||||||
jump_node = NodePath("../jump")
|
|
||||||
attack_node = NodePath("../attack")
|
|
||||||
dash_node = NodePath("../dash")
|
|
||||||
roll_node = NodePath("../roll")
|
|
||||||
climb_node = NodePath("../climb")
|
|
||||||
|
|
||||||
[node name="fall" parent="movement_state_machine" index="1"]
|
|
||||||
script = ExtResource( 6 )
|
|
||||||
move_speed = 90.0
|
|
||||||
animation_sequence = [ "jump" ]
|
|
||||||
landing_node = NodePath("")
|
|
||||||
|
|
||||||
[node name="move" parent="movement_state_machine" index="2"]
|
|
||||||
script = ExtResource( 5 )
|
|
||||||
move_speed = 90.0
|
|
||||||
animation_sequence = [ "step", "run" ]
|
|
||||||
jump_node = NodePath("../jump")
|
|
||||||
attack_node = NodePath("../attack")
|
|
||||||
|
|
||||||
[node name="jump" type="Node" parent="movement_state_machine" index="3"]
|
|
||||||
script = ExtResource( 8 )
|
|
||||||
move_speed = 90.0
|
|
||||||
move_modifier_move_acceleration = -100.0
|
|
||||||
animation_sequence = [ "jump" ]
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
fall_node = NodePath("../fall")
|
|
||||||
attack_node = NodePath("../attack")
|
|
||||||
jump_force = 250.0
|
|
||||||
|
|
||||||
[node name="attack" type="Node" parent="movement_state_machine" index="4"]
|
|
||||||
script = ExtResource( 10 )
|
|
||||||
timeout_seconds = 1.5
|
|
||||||
move_speed = 90.0
|
|
||||||
animation_sequence = [ "shoot" ]
|
|
||||||
jump_node = NodePath("../jump")
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
fall_node = NodePath("../fall")
|
|
||||||
move_node = NodePath("../move")
|
|
||||||
|
|
||||||
[node name="hurt" type="Node" parent="movement_state_machine" index="5"]
|
|
||||||
script = ExtResource( 12 )
|
|
||||||
timeout_seconds = 2.0
|
|
||||||
move_speed = -10.0
|
|
||||||
animation_sequence = [ "hurt" ]
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
|
|
||||||
[node name="dash" type="Node" parent="movement_state_machine" index="6"]
|
|
||||||
script = ExtResource( 11 )
|
|
||||||
move_speed = 90.0
|
|
||||||
move_speed_modifier = 90.0
|
|
||||||
move_modifier_move_acceleration = -100.0
|
|
||||||
jerk_factor = -20.0
|
|
||||||
animation_sequence = [ "dash" ]
|
|
||||||
fall_node = NodePath("../fall")
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
attack_node = NodePath("../attack")
|
|
||||||
jump_node = NodePath("../jump")
|
|
||||||
|
|
||||||
[node name="roll" type="Node" parent="movement_state_machine" index="7"]
|
|
||||||
script = ExtResource( 14 )
|
|
||||||
move_speed = 150.0
|
|
||||||
animation_sequence = [ "roll" ]
|
|
||||||
emitter_frame_subscriptions = {
|
|
||||||
2: "roll"
|
|
||||||
}
|
|
||||||
fall_node = NodePath("../fall")
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
|
|
||||||
[node name="die" type="Node" parent="movement_state_machine" index="8"]
|
|
||||||
script = ExtResource( 15 )
|
|
||||||
animation_sequence = [ "die" ]
|
|
||||||
|
|
||||||
[node name="climb" type="Node" parent="movement_state_machine" index="9"]
|
|
||||||
script = ExtResource( 17 )
|
|
||||||
debug_state = true
|
|
||||||
animation_sequence = [ "climb_step", "climb", "climb_upstep" ]
|
|
||||||
idle_node = NodePath("../idle")
|
|
||||||
|
|
||||||
[node name="Hurtbox_Component" parent="." index="4"]
|
[node name="Hurtbox_Component" parent="." index="4"]
|
||||||
collision_layer = 16
|
collision_layer = 16
|
||||||
collision_mask = 128
|
collision_mask = 128
|
||||||
|
|
@ -688,8 +594,4 @@ collision_mask = 1024
|
||||||
collide_with_areas = true
|
collide_with_areas = true
|
||||||
collide_with_bodies = false
|
collide_with_bodies = false
|
||||||
|
|
||||||
[connection signal="do_attack" from="movement_state_machine/attack" to="." method="_on_attack_do_attack"]
|
|
||||||
[connection signal="frame_reached" from="movement_state_machine/roll" to="." method="_on_roll_frame_reached"]
|
|
||||||
[connection signal="state_exited" from="movement_state_machine/roll" to="." method="_on_roll_state_exited"]
|
|
||||||
[connection signal="state_entered" from="movement_state_machine/die" to="." method="_on_die_state_entered"]
|
|
||||||
[connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"]
|
[connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user