Compare commits
No commits in common. "f54f49704b4ccf5f839586f68f38778c9049b7cf" and "a09be453da5358ee20688652bf77407ef70d61ce" have entirely different histories.
f54f49704b
...
a09be453da
|
|
@ -54,37 +54,6 @@ region = Rect2( 0, 48, 48, 48 )
|
||||||
atlas = SubResource( 145 )
|
atlas = SubResource( 145 )
|
||||||
region = Rect2( 48, 48, 48, 48 )
|
region = Rect2( 48, 48, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="StreamTexture" id=151]
|
|
||||||
load_path = "res://.import/run-shoot.png-04896385acb8306189f1c45bb616220c.stex"
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=152]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 0, 0, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=153]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 48, 0, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=154]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 96, 0, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=155]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 144, 0, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=156]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 0, 48, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=157]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 48, 48, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=158]
|
|
||||||
atlas = SubResource( 151 )
|
|
||||||
region = Rect2( 96, 48, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="StreamTexture" id=133]
|
[sub_resource type="StreamTexture" id=133]
|
||||||
load_path = "res://.import/attack-stab.png-ef2ad659f974ce3d43d446e90b7c2f86.stex"
|
load_path = "res://.import/attack-stab.png-ef2ad659f974ce3d43d446e90b7c2f86.stex"
|
||||||
|
|
||||||
|
|
@ -496,37 +465,40 @@ region = Rect2( 0, 96, 48, 48 )
|
||||||
atlas = SubResource( 18 )
|
atlas = SubResource( 18 )
|
||||||
region = Rect2( 48, 96, 48, 48 )
|
region = Rect2( 48, 96, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=162]
|
[sub_resource type="StreamTexture" id=151]
|
||||||
atlas = SubResource( 151 )
|
load_path = "res://.import/run-shoot.png-04896385acb8306189f1c45bb616220c.stex"
|
||||||
region = Rect2( 96, 96, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=163]
|
[sub_resource type="AtlasTexture" id=152]
|
||||||
atlas = SubResource( 151 )
|
atlas = SubResource( 151 )
|
||||||
region = Rect2( 144, 96, 48, 48 )
|
region = Rect2( 0, 0, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=159]
|
[sub_resource type="AtlasTexture" id=153]
|
||||||
atlas = SubResource( 151 )
|
atlas = SubResource( 151 )
|
||||||
region = Rect2( 144, 48, 48, 48 )
|
region = Rect2( 48, 0, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=160]
|
[sub_resource type="AtlasTexture" id=154]
|
||||||
atlas = SubResource( 151 )
|
atlas = SubResource( 151 )
|
||||||
region = Rect2( 0, 96, 48, 48 )
|
region = Rect2( 96, 0, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=161]
|
[sub_resource type="AtlasTexture" id=155]
|
||||||
atlas = SubResource( 151 )
|
atlas = SubResource( 151 )
|
||||||
region = Rect2( 48, 96, 48, 48 )
|
region = Rect2( 144, 0, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=156]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 0, 48, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=157]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 48, 48, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=158]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 96, 48, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="StreamTexture" id=111]
|
[sub_resource type="StreamTexture" id=111]
|
||||||
load_path = "res://.import/run-sword.png-6e6a5a9983f4110cdd5e02e00d67da69.stex"
|
load_path = "res://.import/run-sword.png-6e6a5a9983f4110cdd5e02e00d67da69.stex"
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=118]
|
|
||||||
atlas = SubResource( 111 )
|
|
||||||
region = Rect2( 0, 96, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=119]
|
|
||||||
atlas = SubResource( 111 )
|
|
||||||
region = Rect2( 48, 96, 48, 48 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=112]
|
[sub_resource type="AtlasTexture" id=112]
|
||||||
atlas = SubResource( 111 )
|
atlas = SubResource( 111 )
|
||||||
region = Rect2( 0, 0, 48, 48 )
|
region = Rect2( 0, 0, 48, 48 )
|
||||||
|
|
@ -551,6 +523,14 @@ region = Rect2( 48, 48, 48, 48 )
|
||||||
atlas = SubResource( 111 )
|
atlas = SubResource( 111 )
|
||||||
region = Rect2( 96, 48, 48, 48 )
|
region = Rect2( 96, 48, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=118]
|
||||||
|
atlas = SubResource( 111 )
|
||||||
|
region = Rect2( 0, 96, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=119]
|
||||||
|
atlas = SubResource( 111 )
|
||||||
|
region = Rect2( 48, 96, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="StreamTexture" id=38]
|
[sub_resource type="StreamTexture" id=38]
|
||||||
load_path = "res://.import/run-crouch.png-13dd70dd30935cf28b601677cc96319e.stex"
|
load_path = "res://.import/run-crouch.png-13dd70dd30935cf28b601677cc96319e.stex"
|
||||||
|
|
||||||
|
|
@ -594,6 +574,26 @@ region = Rect2( 0, 96, 48, 48 )
|
||||||
atlas = SubResource( 38 )
|
atlas = SubResource( 38 )
|
||||||
region = Rect2( 48, 96, 48, 48 )
|
region = Rect2( 48, 96, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=159]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 144, 48, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=160]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 0, 96, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=161]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 48, 96, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=162]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 96, 96, 48, 48 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=163]
|
||||||
|
atlas = SubResource( 151 )
|
||||||
|
region = Rect2( 144, 96, 48, 48 )
|
||||||
|
|
||||||
[sub_resource type="StreamTexture" id=124]
|
[sub_resource type="StreamTexture" id=124]
|
||||||
load_path = "res://.import/walk.png-0d536fc31ef445aa94a97fccd3c71be9.stex"
|
load_path = "res://.import/walk.png-0d536fc31ef445aa94a97fccd3c71be9.stex"
|
||||||
|
|
||||||
|
|
@ -642,11 +642,6 @@ animations = [ {
|
||||||
"name": "attack-shoot",
|
"name": "attack-shoot",
|
||||||
"speed": 15.0
|
"speed": 15.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ), SubResource( 158 ), SubResource( 152 ) ],
|
|
||||||
"loop": false,
|
|
||||||
"name": "attack-shoot-run",
|
|
||||||
"speed": 13.0
|
|
||||||
}, {
|
|
||||||
"frames": [ SubResource( 134 ), SubResource( 135 ), SubResource( 136 ), SubResource( 136 ), SubResource( 137 ), SubResource( 138 ), SubResource( 139 ) ],
|
"frames": [ SubResource( 134 ), SubResource( 135 ), SubResource( 136 ), SubResource( 136 ), SubResource( 137 ), SubResource( 138 ), SubResource( 139 ) ],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": "attack-stab",
|
"name": "attack-stab",
|
||||||
|
|
@ -737,21 +732,26 @@ animations = [ {
|
||||||
"name": "run",
|
"name": "run",
|
||||||
"speed": 13.0
|
"speed": 13.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 162 ), SubResource( 152 ), SubResource( 163 ), SubResource( 153 ), SubResource( 154 ), SubResource( 159 ), SubResource( 160 ), SubResource( 161 ) ],
|
"frames": [ SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ), SubResource( 158 ), SubResource( 152 ) ],
|
||||||
"loop": true,
|
"loop": false,
|
||||||
"name": "run-attack-shoot",
|
"name": "run-attack-shoot",
|
||||||
"speed": 13.0
|
"speed": 13.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 118 ), SubResource( 119 ), SubResource( 112 ), SubResource( 113 ), SubResource( 114 ), SubResource( 115 ), SubResource( 116 ), SubResource( 117 ) ],
|
"frames": [ SubResource( 112 ), SubResource( 113 ), SubResource( 114 ), SubResource( 115 ), SubResource( 116 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "run-attack-sword",
|
"name": "run-attack-sword",
|
||||||
"speed": 13.0
|
"speed": 13.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ) ],
|
"frames": [ SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "run_crouch",
|
"name": "run-crouch",
|
||||||
"speed": 10.0
|
"speed": 10.0
|
||||||
}, {
|
}, {
|
||||||
|
"frames": [ SubResource( 153 ), SubResource( 154 ), SubResource( 159 ), SubResource( 160 ), SubResource( 161 ), SubResource( 162 ), SubResource( 152 ), SubResource( 163 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "run-shoot",
|
||||||
|
"speed": 13.0
|
||||||
|
}, {
|
||||||
"frames": [ SubResource( 125 ), SubResource( 126 ), SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 131 ), SubResource( 132 ) ],
|
"frames": [ SubResource( 125 ), SubResource( 126 ), SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 131 ), SubResource( 132 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "walk",
|
"name": "walk",
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,26 @@
|
||||||
class_name AnimatedSprite_StateReceiver
|
class_name AnimatedSprite_StateReceiver
|
||||||
extends AnimatedSprite
|
extends AnimatedSprite
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
|
||||||
export var callable_state_machine :NodePath
|
export var callable_state_machine :NodePath
|
||||||
|
|
||||||
onready var current_state = StateAnimatedActor.new()
|
onready var current_state = StateAnimatedActor.new()
|
||||||
|
|
||||||
|
#var state_machine_modifiers: Array
|
||||||
var modifier: StateModifierAnimatedActor
|
var modifier: StateModifierAnimatedActor
|
||||||
|
|
||||||
|
#var animation_finished: bool = false
|
||||||
var request_state_change: FuncRef
|
var request_state_change: FuncRef
|
||||||
var add_state_modifier: FuncRef
|
var add_state_modifier: FuncRef
|
||||||
|
|
||||||
|
# this just wouldn't work well. Maybe I can try a resource
|
||||||
|
# export(Array, NodePath) var transition_state_nodes
|
||||||
|
|
||||||
|
#TODO: I think these two variables accidentally serve the same purpose
|
||||||
|
# I think one was intended to be a string of the current animation name.
|
||||||
var animation_index: int = 0
|
var animation_index: int = 0
|
||||||
var current_animation_sequence: int = 0
|
var current_animation_sequence: int = 0
|
||||||
var animation_suffix: String = '';
|
var animation_suffix: String = '';
|
||||||
|
|
@ -21,8 +32,6 @@ var previous_state_frame_number : int
|
||||||
var previous_state_name: String
|
var previous_state_name: String
|
||||||
var previous_speed_multiplier: float
|
var previous_speed_multiplier: float
|
||||||
|
|
||||||
var _frame_switch_tracker := -1
|
|
||||||
var _index_tracker := -1
|
|
||||||
|
|
||||||
# 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():
|
func _ready():
|
||||||
|
|
@ -30,7 +39,6 @@ func _ready():
|
||||||
add_state_modifier = funcref(get_node(callable_state_machine),'push_state_modifier')
|
add_state_modifier = funcref(get_node(callable_state_machine),'push_state_modifier')
|
||||||
|
|
||||||
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
|
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
|
||||||
get_node(callable_state_machine).connect("modifiers_updated",self,"_on_modifiers_updated")
|
|
||||||
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
|
#set current state since State machine might have set state before this
|
||||||
|
|
@ -42,10 +50,15 @@ func _ready():
|
||||||
# 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):
|
||||||
##TODO: Put in to try to buffer animation switches on frame change
|
# Shouldn't need this anymore!
|
||||||
if _frame_switch_tracker != -1 and frame == _frame_switch_tracker:
|
# if current_state.state_timeout != null:
|
||||||
print ("time to switch", _frame_switch_tracker)
|
# if current_state.state_timeout.time_left == 0:
|
||||||
change_animation(_frame_switch_tracker, _index_tracker)
|
# print("You're out of time! I saw it!")
|
||||||
|
# request_state_change.call_func('idle')
|
||||||
|
# #play()
|
||||||
|
# else:
|
||||||
|
# print("what, no current_state?")
|
||||||
|
|
||||||
# Not sure what should be called first here.
|
# Not sure what should be called first here.
|
||||||
if has_method('_state_process_' + current_state.name):
|
if has_method('_state_process_' + current_state.name):
|
||||||
call('_state_process_' + current_state.name)
|
call('_state_process_' + current_state.name)
|
||||||
|
|
@ -63,19 +76,28 @@ func _on_animation_finished():
|
||||||
current_state.animation_finished = true
|
current_state.animation_finished = true
|
||||||
# TODO: Allow a way to stop animation even if in a looped sequence
|
# TODO: Allow a way to stop animation even if in a looped sequence
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
||||||
# 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
|
||||||
# modifier being applied/removed outside of enter/exit transitions.
|
# modifier being applied/removed outside of enter/exit transitions.
|
||||||
func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
## TODO:
|
## TODO:
|
||||||
# Need to find a way to attempt to keep and transfer the Index or frame
|
# Need to find a way to attempt to keep and transfer the Index or frame
|
||||||
|
#
|
||||||
|
# if clear_modifier:
|
||||||
|
# print("Goodbye Modifiers!")
|
||||||
|
# modifier = null
|
||||||
|
# if modifier:
|
||||||
|
# if modifier.state_timeout and modifier.timeout_seconds == 0:
|
||||||
|
# modifier = null
|
||||||
|
|
||||||
if modifier:
|
if modifier:
|
||||||
#print("hey you got one! -> ", modifier.animation_name)
|
#print("hey you got one! -> ", modifier.animation_name)
|
||||||
match modifier.modifier_type:
|
match modifier.modifier_type:
|
||||||
StateModifier.TYPE.ANIMATION_SUFFIX:
|
StateModifier.TYPE.ANIMATION_SUFFIX:
|
||||||
print("hey you got one! -> ", modifier.animation_suffix)
|
print("hey you got one! -> ", modifier.animation_suffix)
|
||||||
_frame_switch_tracker = -1
|
|
||||||
_index_tracker = -1
|
|
||||||
|
|
||||||
# By Default, we build an animation sequence off of this state's before checking
|
# By Default, we build an animation sequence off of this state's before checking
|
||||||
# for modifiers
|
# for modifiers
|
||||||
|
|
@ -87,23 +109,6 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
animation_suffix = suffix
|
animation_suffix = suffix
|
||||||
animation_index = index
|
animation_index = index
|
||||||
current_animation_sequence = animation_index
|
current_animation_sequence = animation_index
|
||||||
|
|
||||||
if modifier:
|
|
||||||
#TODO: Apply the animation starting frame
|
|
||||||
#modifier.animation_starting_frame
|
|
||||||
match modifier.modifier_type:
|
|
||||||
modifier.TYPE.ANIMATION_SUFFIX:
|
|
||||||
# Check that this animation actually exists
|
|
||||||
if frames.has_animation(mod_animation_sequence[animation_index] + '-' + modifier.animation_suffix):
|
|
||||||
animation_suffix = modifier.animation_suffix
|
|
||||||
else:
|
|
||||||
push_warning("Modifier attempting to apply suffix that doesn't exist" +
|
|
||||||
(mod_animation_sequence[animation_index] + '-' + modifier.animation_suffix))
|
|
||||||
modifier.TYPE.REPLACE_ANIMATION:
|
|
||||||
if frames.has_animation(modifier.animation_name):
|
|
||||||
mod_animation_sequence.clear()
|
|
||||||
mod_animation_sequence.push_back(modifier.animation_name)
|
|
||||||
enter_frame = modifier.animation_starting_frame
|
|
||||||
#var enter_animation = ''
|
#var enter_animation = ''
|
||||||
#var enter_frame = 0
|
#var enter_frame = 0
|
||||||
# var modifier :StateModifier = current_state.modifier
|
# var modifier :StateModifier = current_state.modifier
|
||||||
|
|
@ -152,14 +157,9 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
if mod_animation_sequence.size() > 0:
|
if mod_animation_sequence.size() > 0:
|
||||||
if current_state.debug_state:
|
if current_state.debug_state:
|
||||||
print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix)
|
print("Starting Animation: " , mod_animation_sequence[animation_index] + animation_suffix)
|
||||||
if animation_suffix != '':
|
play(mod_animation_sequence[animation_index] + animation_suffix)
|
||||||
play(mod_animation_sequence[animation_index] + '-' + animation_suffix)
|
|
||||||
else:
|
|
||||||
play(mod_animation_sequence[animation_index])
|
|
||||||
#TODO: maybe check current animatio has this frame
|
#TODO: maybe check current animatio has this frame
|
||||||
if enter_frame != 0:
|
frame = enter_frame
|
||||||
print ("alternate starting frame:", enter_frame)
|
|
||||||
frame = enter_frame
|
|
||||||
else:
|
else:
|
||||||
print("Error! Resolved to empty animation sequence!?")
|
print("Error! Resolved to empty animation sequence!?")
|
||||||
return
|
return
|
||||||
|
|
@ -218,15 +218,15 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
# else:
|
# else:
|
||||||
# frame_signal_emitted = false
|
# frame_signal_emitted = false
|
||||||
|
|
||||||
#func set_previous_animation( old_state: StateAnimatedActor, new_state: StateAnimatedActor ) -> void:
|
func set_previous_animation( old_state: StateAnimatedActor, new_state: StateAnimatedActor ) -> void:
|
||||||
# # added this to help prevent nul index crashes. (Usually because of signal based state changes.)
|
# added this to help prevent nul index crashes. (Usually because of signal based state changes.)
|
||||||
# if old_state.mod_animation_sequence:
|
if old_state.mod_animation_sequence:
|
||||||
# new_state.previous_animation_name = old_state.mod_animation_sequence[old_state.current_animation_sequence]
|
new_state.previous_animation_name = old_state.mod_animation_sequence[old_state.current_animation_sequence]
|
||||||
# new_state.previous_state_frame_number = old_state.animations.frame
|
new_state.previous_state_frame_number = old_state.animations.frame
|
||||||
# new_state.previous_state_name = old_state.name
|
new_state.previous_state_name = old_state.name
|
||||||
# new_state.previous_speed_multiplier = old_state.speed_multiplier
|
new_state.previous_speed_multiplier = old_state.speed_multiplier
|
||||||
# #animation_name :String, frame_number : int, animation_sequence :Array
|
#animation_name :String, frame_number : int, animation_sequence :Array
|
||||||
# return
|
return
|
||||||
|
|
||||||
# Handle state change from subscribed state machine.
|
# Handle state change from subscribed state machine.
|
||||||
#From signal state_changed(old_state_name, new_state)
|
#From signal state_changed(old_state_name, new_state)
|
||||||
|
|
@ -247,20 +247,3 @@ func _on_state_change(old_state_name:String, new_state :State):
|
||||||
push_warning("Received non animated Actor state.")
|
push_warning("Received non animated Actor state.")
|
||||||
#current_state = new_state
|
#current_state = new_state
|
||||||
|
|
||||||
func _on_modifiers_updated(_modifier_type :int, _modifier_action :int):
|
|
||||||
##TODO: There's so many things I could maybe do here but lets target the
|
|
||||||
## current use case.
|
|
||||||
if _modifier_type == StateModifierAnimatedActor.TYPE.ANIMATION_SUFFIX:
|
|
||||||
print("A: ", animation, " F: ", frame, " -Modifier Changed Signal")
|
|
||||||
# Wait for frame to finish before doing anything.
|
|
||||||
#yield(self, "frame_changed")
|
|
||||||
if _modifier_action == StateModifierAnimatedActor.EVENT_ID.DEACTIVATED:
|
|
||||||
if frame != 0 and frame != frames.get_frame_count(animation):
|
|
||||||
print ("lets change the animation suffix frame:", frame)
|
|
||||||
var current_frame = frame
|
|
||||||
#yield(self, "frame_changed")
|
|
||||||
#while current_frame == frame:
|
|
||||||
# print("waiting...")
|
|
||||||
#change_animation(frame + 1 ,animation_index)
|
|
||||||
_frame_switch_tracker = frame + 1
|
|
||||||
_index_tracker = animation_index
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export var debug_state_machine: bool = false
|
||||||
#var starting_state: State
|
#var starting_state: State
|
||||||
|
|
||||||
signal state_changed(old_state_name, new_state)
|
signal state_changed(old_state_name, new_state)
|
||||||
signal modifiers_updated(modifier_type, modifier_eventid)
|
|
||||||
|
|
||||||
var current_state: State
|
var current_state: State
|
||||||
var state_modifiers: Array
|
var state_modifiers: Array
|
||||||
|
|
@ -61,7 +61,6 @@ func _physics_process(delta):
|
||||||
merge_modifiers()
|
merge_modifiers()
|
||||||
|
|
||||||
func merge_modifiers():
|
func merge_modifiers():
|
||||||
merged_animation_state_modifiers.reset()
|
|
||||||
for m in state_modifiers:
|
for m in state_modifiers:
|
||||||
if m is StateModifierAnimatedActor:
|
if m is StateModifierAnimatedActor:
|
||||||
#print(m.name)
|
#print(m.name)
|
||||||
|
|
@ -78,7 +77,6 @@ func change_state(new_state: State) -> void:
|
||||||
current_state = new_state
|
current_state = new_state
|
||||||
current_state.enter()
|
current_state.enter()
|
||||||
|
|
||||||
# Seems like I don't have to do this every state change!
|
|
||||||
# if(state_modifiers.size() > 0):
|
# if(state_modifiers.size() > 0):
|
||||||
# print("Active Modifiers:")
|
# print("Active Modifiers:")
|
||||||
# for mods in state_modifiers:
|
# for mods in state_modifiers:
|
||||||
|
|
@ -112,11 +110,6 @@ func handle_modifier_events(eventID :int):
|
||||||
if eventID == StateModifier.EVENT_ID.ACTIVATED:
|
if eventID == StateModifier.EVENT_ID.ACTIVATED:
|
||||||
print ("A mod activated! Which one though?")
|
print ("A mod activated! Which one though?")
|
||||||
merge_modifiers()
|
merge_modifiers()
|
||||||
emit_signal("modifiers_updated",merged_animation_state_modifiers.modifier_type, eventID)
|
|
||||||
elif eventID == StateModifier.EVENT_ID.DEACTIVATED:
|
|
||||||
merge_modifiers()
|
|
||||||
emit_signal("modifiers_updated",merged_animation_state_modifiers.modifier_type, eventID)
|
|
||||||
|
|
||||||
|
|
||||||
# Disable to test whether actually needed.
|
# Disable to test whether actually needed.
|
||||||
## Pass through functions for the Player to call,
|
## Pass through functions for the Player to call,
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,12 @@ func _ready():
|
||||||
state_ref.connect("state_exited", self, "_on_state_exited_attack_sword")
|
state_ref.connect("state_exited", self, "_on_state_exited_attack_sword")
|
||||||
|
|
||||||
attack_sword = StateModifierAnimatedActor.new()
|
attack_sword = StateModifierAnimatedActor.new()
|
||||||
attack_sword.setup('sword_drawn',StateModifier.TYPE.ANIMATION_SUFFIX,2.0)
|
attack_sword.setup('sword_drawn',StateModifier.TYPE.ANIMATION_SUFFIX,5.0)
|
||||||
add_child(attack_sword.timeout)
|
add_child(attack_sword.timeout)
|
||||||
#attack_sword.animation_name = 'PoopenStein'
|
attack_sword.animation_name = 'PoopenStein'
|
||||||
attack_sword.animation_suffix = 'attack-sword'
|
attack_sword.animation_suffix = '-attack_sword'
|
||||||
add_state_modifier.call_func(attack_sword)
|
add_state_modifier.call_func(attack_sword)
|
||||||
|
|
||||||
# Testing
|
|
||||||
#speed_scale = .1
|
|
||||||
|
|
||||||
|
|
||||||
# I don't need this right now but I proved it can be done!
|
# I don't need this right now but I proved it can be done!
|
||||||
#func _state_process_idle():
|
#func _state_process_idle():
|
||||||
# print("I got called!")
|
# print("I got called!")
|
||||||
|
|
@ -45,10 +41,10 @@ func _ready():
|
||||||
# frame = 2
|
# frame = 2
|
||||||
# stop()
|
# stop()
|
||||||
|
|
||||||
#func _on_state_change_idle():
|
func _on_state_change_idle():
|
||||||
# change_animation()
|
change_animation()
|
||||||
# if previous_state_name == 'attack_sword':
|
if previous_state_name == 'attack_sword':
|
||||||
# animation = 'idle-attack-sword'
|
animation = 'idle-attack-sword'
|
||||||
|
|
||||||
func _on_state_change_fall():
|
func _on_state_change_fall():
|
||||||
change_animation()
|
change_animation()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user