Before overhauling modifiers.
This commit is contained in:
parent
bb2c59f7d9
commit
ab0d2ac5b7
|
|
@ -6,6 +6,9 @@
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
|
|
||||||
[node name="TestBox" parent="." instance=ExtResource( 2 )]
|
[node name="TestBox" parent="." instance=ExtResource( 2 )]
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_lock_": true
|
||||||
|
}
|
||||||
|
|
||||||
[node name="PlayerE" parent="." instance=ExtResource( 1 )]
|
[node name="PlayerE" parent="." instance=ExtResource( 1 )]
|
||||||
position = Vector2( 112, 56 )
|
position = Vector2( 112, 56 )
|
||||||
|
|
|
||||||
|
|
@ -97,30 +97,30 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
current_animation_sequence = animation_index
|
current_animation_sequence = animation_index
|
||||||
#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
|
||||||
if modifier != null:
|
# if modifier != null:
|
||||||
# if modifier.modifier_type == modifier.TYPE.EXIT_ANIMATION:
|
## if modifier.modifier_type == modifier.TYPE.EXIT_ANIMATION:
|
||||||
# #print("OHHH Modifier Applies! ", modifier.animation_name)
|
## #print("OHHH Modifier Applies! ", modifier.animation_name)
|
||||||
# mod_animation_sequence.push_front(modifier.animation_name)
|
## mod_animation_sequence.push_front(modifier.animation_name)
|
||||||
# enter_frame = modifier.starting_frame
|
## enter_frame = modifier.starting_frame
|
||||||
match modifier.modifier_type:
|
# match modifier.modifier_type:
|
||||||
modifier.TYPE.EXIT_ANIMATION:
|
# modifier.TYPE.EXIT_ANIMATION:
|
||||||
mod_animation_sequence.push_front(modifier.animation_name)
|
# mod_animation_sequence.push_front(modifier.animation_name)
|
||||||
enter_frame = modifier.starting_frame
|
# enter_frame = modifier.starting_frame
|
||||||
|
#
|
||||||
modifier.TYPE.ANIMATION_SUFFIX:
|
# modifier.TYPE.ANIMATION_SUFFIX:
|
||||||
if frames.has_animation(mod_animation_sequence[animation_index] + modifier.animation_name):
|
# if frames.has_animation(mod_animation_sequence[animation_index] + modifier.animation_name):
|
||||||
animation_suffix = modifier.animation_name
|
# animation_suffix = modifier.animation_name
|
||||||
else:
|
# else:
|
||||||
print("Warning!: Modifier attempting to apply suffix that doesn't exist ",
|
# print("Warning!: Modifier attempting to apply suffix that doesn't exist ",
|
||||||
mod_animation_sequence[animation_index] + modifier.animation_name)
|
# mod_animation_sequence[animation_index] + modifier.animation_name)
|
||||||
|
#
|
||||||
modifier.TYPE.REPLACE_ANIMATION:
|
# modifier.TYPE.REPLACE_ANIMATION:
|
||||||
#animations.play(modifier_stack_ref[i].animation_name)
|
# #animations.play(modifier_stack_ref[i].animation_name)
|
||||||
#animations.frame = modifier_stack_ref[i].starting_frame
|
# #animations.frame = modifier_stack_ref[i].starting_frame
|
||||||
mod_animation_sequence.clear()
|
# mod_animation_sequence.clear()
|
||||||
mod_animation_sequence.push_back(modifier.animation_name)
|
# mod_animation_sequence.push_back(modifier.animation_name)
|
||||||
enter_frame = modifier.starting_frame
|
# enter_frame = modifier.starting_frame
|
||||||
|
|
||||||
# Some safety checks with supplied update parameters
|
# Some safety checks with supplied update parameters
|
||||||
if animation_index != 0:
|
if animation_index != 0:
|
||||||
|
|
@ -150,27 +150,27 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
print("Error! Resolved to empty animation sequence!?")
|
print("Error! Resolved to empty animation sequence!?")
|
||||||
return
|
return
|
||||||
|
|
||||||
func process_state_modifier():
|
#func process_state_modifier():
|
||||||
var modifier :StateModifier = current_state.modifier
|
# var modifier :StateModifier = current_state.modifier
|
||||||
if modifier != null:
|
# if modifier != null:
|
||||||
if modifier.state_timeout and modifier.state_timeout.time_left == 0:
|
# if modifier.state_timeout and modifier.state_timeout.time_left == 0:
|
||||||
print("Expired Modifier, updating animation.")
|
# print("Expired Modifier, updating animation.")
|
||||||
#modifier = null
|
# #modifier = null
|
||||||
match modifier.modifier_type:
|
# match modifier.modifier_type:
|
||||||
|
#
|
||||||
modifier.TYPE.ANIMATION_SUFFIX:
|
# modifier.TYPE.ANIMATION_SUFFIX:
|
||||||
# Attempt to seemlessly transition animations.
|
# # Attempt to seemlessly transition animations.
|
||||||
modifier = null
|
# modifier = null
|
||||||
change_animation(frame,animation_index)
|
# change_animation(frame,animation_index)
|
||||||
|
#
|
||||||
modifier.TYPE.REPLACE_ANIMATION:
|
# modifier.TYPE.REPLACE_ANIMATION:
|
||||||
if current_state.debug_state:
|
# if current_state.debug_state:
|
||||||
print("I don't have anything for replacements yet.")
|
# print("I don't have anything for replacements yet.")
|
||||||
modifier = null
|
# modifier = null
|
||||||
change_animation()
|
# change_animation()
|
||||||
_:
|
# _:
|
||||||
modifier = null
|
# modifier = null
|
||||||
return
|
# return
|
||||||
|
|
||||||
|
|
||||||
# We have no more sequence animations and the current one doesn't loop
|
# We have no more sequence animations and the current one doesn't loop
|
||||||
|
|
|
||||||
|
|
@ -141,17 +141,17 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
|
||||||
var _jerk_factor = current_state.jerk_factor
|
var _jerk_factor = current_state.jerk_factor
|
||||||
var _gravity = current_state.gravity
|
var _gravity = current_state.gravity
|
||||||
|
|
||||||
if current_state.physics_modifier:
|
# if current_state.physics_modifier:
|
||||||
#physics_modifier.modifier_properties.jerk_factor
|
# #physics_modifier.modifier_properties.jerk_factor
|
||||||
#print(physics_modifier.name)
|
# #print(physics_modifier.name)
|
||||||
#UiManager.debug_text = physics_modifier.name + str(round(adjusted_move_speed))
|
# #UiManager.debug_text = physics_modifier.name + str(round(adjusted_move_speed))
|
||||||
var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
|
# var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
|
||||||
if mod_props.move_speed != 0 and mod_props.directional_modifier == false:
|
# if mod_props.move_speed != 0 and mod_props.directional_modifier == false:
|
||||||
_move_speed = mod_props.move_speed
|
# _move_speed = mod_props.move_speed
|
||||||
_move_speed_modifier += mod_props.move_speed_modifier
|
# _move_speed_modifier += mod_props.move_speed_modifier
|
||||||
_move_acceleration += mod_props.move_acceleration
|
# _move_acceleration += mod_props.move_acceleration
|
||||||
_move_modifier_move_acceleration += mod_props.move_modifier_move_acceleration
|
# _move_modifier_move_acceleration += mod_props.move_modifier_move_acceleration
|
||||||
_jerk_factor += mod_props.jerk_factor
|
# _jerk_factor += mod_props.jerk_factor
|
||||||
|
|
||||||
var help_me_not_be_dumb = ''
|
var help_me_not_be_dumb = ''
|
||||||
|
|
||||||
|
|
@ -181,17 +181,17 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
|
||||||
move_direction = x_move_direction_override
|
move_direction = x_move_direction_override
|
||||||
|
|
||||||
## TODO: I hate that I have to do this check again.
|
## TODO: I hate that I have to do this check again.
|
||||||
if current_state.physics_modifier:
|
# if current_state.physics_modifier:
|
||||||
var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
|
# var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
|
||||||
if mod_props.move_speed != 0 and mod_props.directional_modifier == true:
|
# if mod_props.move_speed != 0 and mod_props.directional_modifier == true:
|
||||||
# Since move_direction is always positive
|
# # Since move_direction is always positive
|
||||||
if sign(move_direction) == sign(mod_props.move_speed):
|
# if sign(move_direction) == sign(mod_props.move_speed):
|
||||||
_move_speed += mod_props.move_speed
|
# _move_speed += mod_props.move_speed
|
||||||
else:
|
# else:
|
||||||
_move_speed -= mod_props.move_speed
|
# _move_speed -= mod_props.move_speed
|
||||||
if sign(move_direction) == 0:
|
# if sign(move_direction) == 0:
|
||||||
move_direction = sign(mod_props.move_speed) * -1
|
# move_direction = sign(mod_props.move_speed) * -1
|
||||||
#print("doing this? ")
|
# #print("doing this? ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ var animation_finished: bool = false
|
||||||
# Not sure if this should be here. probably not
|
# Not sure if this should be here. probably not
|
||||||
export(Array, String) var animation_sequence
|
export(Array, String) var animation_sequence
|
||||||
|
|
||||||
# Modifiers may not be needed anymore.
|
## Modifiers may not be needed anymore.
|
||||||
var modifier: StateModifier
|
#var modifier: StateModifier
|
||||||
var physics_modifier :StateModifier
|
#var physics_modifier :StateModifier
|
||||||
|
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
|
|
@ -41,16 +41,16 @@ func enter() -> void:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
func transfer_modifiers(exiting_state_modifier : StateModifier):
|
#func transfer_modifiers(exiting_state_modifier : StateModifier):
|
||||||
if modifier == null: # We have no existing modifier applied.
|
# if modifier == null: # We have no existing modifier applied.
|
||||||
match exiting_state_modifier.modifier_type:
|
# match exiting_state_modifier.modifier_type:
|
||||||
exiting_state_modifier.TYPE.ANIMATION_SUFFIX:
|
# exiting_state_modifier.TYPE.ANIMATION_SUFFIX:
|
||||||
if debug_state:
|
# if debug_state:
|
||||||
print("Transferring Animation Suffix")
|
# print("Transferring Animation Suffix")
|
||||||
modifier = exiting_state_modifier
|
# modifier = exiting_state_modifier
|
||||||
exiting_state_modifier.TYPE.EXIT_ANIMATION:
|
# exiting_state_modifier.TYPE.EXIT_ANIMATION:
|
||||||
if debug_state:
|
# if debug_state:
|
||||||
print("Exit Animation: well this was useless.")
|
# print("Exit Animation: well this was useless.")
|
||||||
else:
|
# else:
|
||||||
print("Insert modifier merge function here...")
|
# print("Insert modifier merge function here...")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ var states_index :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:
|
||||||
print ("init state machine.")
|
# print ("init state machine.")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
print ("ready state machine.")
|
print ("ready state machine.")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
class_name StateModifier
|
class_name DumbOldStateModifier
|
||||||
extends Reference
|
extends Reference
|
||||||
## State modification
|
## State modification
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://lib/classes/animated_sprite_state_receiver.gd"
|
"path": "res://lib/classes/animated_sprite_state_receiver.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Reference",
|
||||||
|
"class": "DumbOldStateModifier",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://lib/classes/state_modifier.gd"
|
||||||
|
}, {
|
||||||
"base": "",
|
"base": "",
|
||||||
"class": "GitAPI",
|
"class": "GitAPI",
|
||||||
"language": "NativeScript",
|
"language": "NativeScript",
|
||||||
|
|
@ -88,15 +93,11 @@ _global_script_classes=[ {
|
||||||
"class": "StateMachineAnimatedActor",
|
"class": "StateMachineAnimatedActor",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://lib/classes/state_machine_animated_actor.gd"
|
"path": "res://lib/classes/state_machine_animated_actor.gd"
|
||||||
}, {
|
|
||||||
"base": "Reference",
|
|
||||||
"class": "StateModifier",
|
|
||||||
"language": "GDScript",
|
|
||||||
"path": "res://lib/classes/state_modifier.gd"
|
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"Actor": "",
|
"Actor": "",
|
||||||
"AnimatedSprite_StateReceiver": "",
|
"AnimatedSprite_StateReceiver": "",
|
||||||
|
"DumbOldStateModifier": "",
|
||||||
"GitAPI": "",
|
"GitAPI": "",
|
||||||
"HealthComponent": "",
|
"HealthComponent": "",
|
||||||
"HealthPickup": "",
|
"HealthPickup": "",
|
||||||
|
|
@ -110,8 +111,7 @@ _global_script_class_icons={
|
||||||
"State": "",
|
"State": "",
|
||||||
"StateAnimatedActor": "",
|
"StateAnimatedActor": "",
|
||||||
"StateMachine": "",
|
"StateMachine": "",
|
||||||
"StateMachineAnimatedActor": "",
|
"StateMachineAnimatedActor": ""
|
||||||
"StateModifier": ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user