Before overhauling modifiers.

This commit is contained in:
Dustin 2025-03-22 18:43:19 -07:00
parent bb2c59f7d9
commit ab0d2ac5b7
7 changed files with 95 additions and 92 deletions

View File

@ -6,6 +6,9 @@
[node name="Main" type="Node2D"]
[node name="TestBox" parent="." instance=ExtResource( 2 )]
__meta__ = {
"_edit_lock_": true
}
[node name="PlayerE" parent="." instance=ExtResource( 1 )]
position = Vector2( 112, 56 )

View File

@ -97,30 +97,30 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
current_animation_sequence = animation_index
#var enter_animation = ''
#var enter_frame = 0
var modifier :StateModifier = current_state.modifier
if modifier != null:
# if modifier.modifier_type == modifier.TYPE.EXIT_ANIMATION:
# #print("OHHH Modifier Applies! ", modifier.animation_name)
# var modifier :StateModifier = current_state.modifier
# if modifier != null:
## if modifier.modifier_type == modifier.TYPE.EXIT_ANIMATION:
## #print("OHHH Modifier Applies! ", modifier.animation_name)
## mod_animation_sequence.push_front(modifier.animation_name)
## enter_frame = modifier.starting_frame
# match modifier.modifier_type:
# modifier.TYPE.EXIT_ANIMATION:
# mod_animation_sequence.push_front(modifier.animation_name)
# enter_frame = modifier.starting_frame
match modifier.modifier_type:
modifier.TYPE.EXIT_ANIMATION:
mod_animation_sequence.push_front(modifier.animation_name)
enter_frame = modifier.starting_frame
modifier.TYPE.ANIMATION_SUFFIX:
if frames.has_animation(mod_animation_sequence[animation_index] + modifier.animation_name):
animation_suffix = modifier.animation_name
else:
print("Warning!: Modifier attempting to apply suffix that doesn't exist ",
mod_animation_sequence[animation_index] + modifier.animation_name)
modifier.TYPE.REPLACE_ANIMATION:
#animations.play(modifier_stack_ref[i].animation_name)
#animations.frame = modifier_stack_ref[i].starting_frame
mod_animation_sequence.clear()
mod_animation_sequence.push_back(modifier.animation_name)
enter_frame = modifier.starting_frame
#
# modifier.TYPE.ANIMATION_SUFFIX:
# if frames.has_animation(mod_animation_sequence[animation_index] + modifier.animation_name):
# animation_suffix = modifier.animation_name
# else:
# print("Warning!: Modifier attempting to apply suffix that doesn't exist ",
# mod_animation_sequence[animation_index] + modifier.animation_name)
#
# modifier.TYPE.REPLACE_ANIMATION:
# #animations.play(modifier_stack_ref[i].animation_name)
# #animations.frame = modifier_stack_ref[i].starting_frame
# mod_animation_sequence.clear()
# mod_animation_sequence.push_back(modifier.animation_name)
# enter_frame = modifier.starting_frame
# Some safety checks with supplied update parameters
if animation_index != 0:
@ -150,27 +150,27 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
print("Error! Resolved to empty animation sequence!?")
return
func process_state_modifier():
var modifier :StateModifier = current_state.modifier
if modifier != null:
if modifier.state_timeout and modifier.state_timeout.time_left == 0:
print("Expired Modifier, updating animation.")
#func process_state_modifier():
# var modifier :StateModifier = current_state.modifier
# if modifier != null:
# if modifier.state_timeout and modifier.state_timeout.time_left == 0:
# print("Expired Modifier, updating animation.")
# #modifier = null
# match modifier.modifier_type:
#
# modifier.TYPE.ANIMATION_SUFFIX:
# # Attempt to seemlessly transition animations.
# modifier = null
match modifier.modifier_type:
modifier.TYPE.ANIMATION_SUFFIX:
# Attempt to seemlessly transition animations.
modifier = null
change_animation(frame,animation_index)
modifier.TYPE.REPLACE_ANIMATION:
if current_state.debug_state:
print("I don't have anything for replacements yet.")
modifier = null
change_animation()
_:
modifier = null
return
# change_animation(frame,animation_index)
#
# modifier.TYPE.REPLACE_ANIMATION:
# if current_state.debug_state:
# print("I don't have anything for replacements yet.")
# modifier = null
# change_animation()
# _:
# modifier = null
# return
# We have no more sequence animations and the current one doesn't loop

View File

@ -141,17 +141,17 @@ func move_actor_as_desired( x_move_direction_override: float = 0):
var _jerk_factor = current_state.jerk_factor
var _gravity = current_state.gravity
if current_state.physics_modifier:
#physics_modifier.modifier_properties.jerk_factor
#print(physics_modifier.name)
#UiManager.debug_text = physics_modifier.name + str(round(adjusted_move_speed))
var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
if mod_props.move_speed != 0 and mod_props.directional_modifier == false:
_move_speed = mod_props.move_speed
_move_speed_modifier += mod_props.move_speed_modifier
_move_acceleration += mod_props.move_acceleration
_move_modifier_move_acceleration += mod_props.move_modifier_move_acceleration
_jerk_factor += mod_props.jerk_factor
# if current_state.physics_modifier:
# #physics_modifier.modifier_properties.jerk_factor
# #print(physics_modifier.name)
# #UiManager.debug_text = physics_modifier.name + str(round(adjusted_move_speed))
# var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
# if mod_props.move_speed != 0 and mod_props.directional_modifier == false:
# _move_speed = mod_props.move_speed
# _move_speed_modifier += mod_props.move_speed_modifier
# _move_acceleration += mod_props.move_acceleration
# _move_modifier_move_acceleration += mod_props.move_modifier_move_acceleration
# _jerk_factor += mod_props.jerk_factor
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
## TODO: I hate that I have to do this check again.
if current_state.physics_modifier:
var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
if mod_props.move_speed != 0 and mod_props.directional_modifier == true:
# Since move_direction is always positive
if sign(move_direction) == sign(mod_props.move_speed):
_move_speed += mod_props.move_speed
else:
_move_speed -= mod_props.move_speed
if sign(move_direction) == 0:
move_direction = sign(mod_props.move_speed) * -1
#print("doing this? ")
# if current_state.physics_modifier:
# var mod_props :ModifierProperties = current_state.physics_modifier.get_modifier_properties()
# if mod_props.move_speed != 0 and mod_props.directional_modifier == true:
# # Since move_direction is always positive
# if sign(move_direction) == sign(mod_props.move_speed):
# _move_speed += mod_props.move_speed
# else:
# _move_speed -= mod_props.move_speed
# if sign(move_direction) == 0:
# move_direction = sign(mod_props.move_speed) * -1
# #print("doing this? ")

View File

@ -27,9 +27,9 @@ var animation_finished: bool = false
# Not sure if this should be here. probably not
export(Array, String) var animation_sequence
# Modifiers may not be needed anymore.
var modifier: StateModifier
var physics_modifier :StateModifier
## Modifiers may not be needed anymore.
#var modifier: StateModifier
#var physics_modifier :StateModifier
func enter() -> void:
@ -41,16 +41,16 @@ func enter() -> void:
return
func transfer_modifiers(exiting_state_modifier : StateModifier):
if modifier == null: # We have no existing modifier applied.
match exiting_state_modifier.modifier_type:
exiting_state_modifier.TYPE.ANIMATION_SUFFIX:
if debug_state:
print("Transferring Animation Suffix")
modifier = exiting_state_modifier
exiting_state_modifier.TYPE.EXIT_ANIMATION:
if debug_state:
print("Exit Animation: well this was useless.")
else:
print("Insert modifier merge function here...")
#func transfer_modifiers(exiting_state_modifier : StateModifier):
# if modifier == null: # We have no existing modifier applied.
# match exiting_state_modifier.modifier_type:
# exiting_state_modifier.TYPE.ANIMATION_SUFFIX:
# if debug_state:
# print("Transferring Animation Suffix")
# modifier = exiting_state_modifier
# exiting_state_modifier.TYPE.EXIT_ANIMATION:
# if debug_state:
# print("Exit Animation: well this was useless.")
# else:
# print("Insert modifier merge function here...")

View File

@ -18,8 +18,8 @@ var states_index :Dictionary
# Initialize the state machine by giving each child state a reference to the
# parent object it belongs to and enter the default starting_state.
func _init() -> void:
print ("init state machine.")
#func _init() -> void:
# print ("init state machine.")
func _ready():
print ("ready state machine.")

View File

@ -1,4 +1,4 @@
class_name StateModifier
class_name DumbOldStateModifier
extends Reference
## State modification
##

View File

@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://lib/classes/animated_sprite_state_receiver.gd"
}, {
"base": "Reference",
"class": "DumbOldStateModifier",
"language": "GDScript",
"path": "res://lib/classes/state_modifier.gd"
}, {
"base": "",
"class": "GitAPI",
"language": "NativeScript",
@ -88,15 +93,11 @@ _global_script_classes=[ {
"class": "StateMachineAnimatedActor",
"language": "GDScript",
"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={
"Actor": "",
"AnimatedSprite_StateReceiver": "",
"DumbOldStateModifier": "",
"GitAPI": "",
"HealthComponent": "",
"HealthPickup": "",
@ -110,8 +111,7 @@ _global_script_class_icons={
"State": "",
"StateAnimatedActor": "",
"StateMachine": "",
"StateMachineAnimatedActor": "",
"StateModifier": ""
"StateMachineAnimatedActor": ""
}
[application]