Cleanup, delete unused files. Standardize TODOs

This commit is contained in:
Dustin 2025-04-21 20:29:13 -07:00
parent 742db5ee8c
commit 3ffcf7ca59
14 changed files with 24 additions and 133 deletions

View File

@ -62,7 +62,7 @@ func _on_animation_finished():
if animation_index >= current_state.animation_sequence.size(): if animation_index >= current_state.animation_sequence.size():
#print("Stop!!!!!") #print("Stop!!!!!")
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
# 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
@ -90,7 +90,7 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
current_animation_sequence = animation_index current_animation_sequence = animation_index
if modifier: if modifier:
#TODO: Apply the animation starting frame ##TODO: Apply the animation starting frame
#modifier.animation_starting_frame #modifier.animation_starting_frame
match modifier.modifier_type: match modifier.modifier_type:
modifier.TYPE.ANIMATION_SUFFIX: modifier.TYPE.ANIMATION_SUFFIX:
@ -157,7 +157,7 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
play(mod_animation_sequence[animation_index] + '-' + animation_suffix) play(mod_animation_sequence[animation_index] + '-' + animation_suffix)
else: else:
play(mod_animation_sequence[animation_index]) play(mod_animation_sequence[animation_index])
#TODO: maybe check current animatio has this frame ##TODO: maybe check current animation has this frame
if enter_frame != 0: if enter_frame != 0:
print ("alternate starting frame:", enter_frame) print ("alternate starting frame:", enter_frame)
frame = enter_frame frame = enter_frame
@ -197,7 +197,7 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
stop() stop()
#animation_finished = true #animation_finished = true
elif mod_animation_sequence.size() > animation_index and current_animation_sequence != animation_index: elif mod_animation_sequence.size() > animation_index and current_animation_sequence != animation_index:
#TODO: why was I doing this ##TODO: why was I doing this before? Firgure out why?
# if animation_index >= mod_animation_sequence.size(): # if animation_index >= mod_animation_sequence.size():
# animation_index = 0 # animation_index = 0
##TODO: Add a safety check here. ##TODO: Add a safety check here.
@ -209,7 +209,7 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
##TODO: Could probably add some more checks here. ##TODO: Could probably add some more checks here.
# Singal based frame call. # Singal based frame call.
#TODO: reimplement this later. ##TODO: reimplement frame subscriptions like this later.
# if emitter_frame_subscriptions.has(animations.frame): # if emitter_frame_subscriptions.has(animations.frame):
# if emitter_frame_subscriptions[animations.frame] == animations.animation: # if emitter_frame_subscriptions[animations.frame] == animations.animation:
# if frame_signal_emitted == false: # if frame_signal_emitted == false:
@ -225,7 +225,9 @@ func _on_state_change(old_state_name:String, new_state :State):
#print ("1? got the state change signal ", new_state.name) #print ("1? got the state change signal ", new_state.name)
# set current state to new_state # set current state to new_state
previous_state_name = old_state_name previous_state_name = old_state_name
#TODO: Confirm that this is a reference to the state in the ##TODO: Confirm theres no need to keep resetting the state
## because it is always a reference to the state machine's current_state.
## this has been working fine but could cause issues if I assume otherwise.
###### State machine ###### State machine
if new_state is StateAnimatedActor: #Testing this. Update: It works if new_state is StateAnimatedActor: #Testing this. Update: It works
current_state = new_state current_state = new_state

View File

@ -33,7 +33,8 @@ func _ready():
parent = get_parent() parent = get_parent()
default_shape = shape.duplicate() default_shape = shape.duplicate()
##TODO: Are transforms primitives? Do they get passed by value? ##DONE: Are transforms primitives? Do they get passed by value?
## Transforms are passed by value.
default_transform = transform default_transform = transform

View File

@ -125,9 +125,6 @@ func get_climb_shape_location() -> Vector2:
return Vector2(-1,-1) return Vector2(-1,-1)
func _on_state_change(old_state_name:String, new_state :State): func _on_state_change(old_state_name:String, new_state :State):
#print ("got the state change signal (MC) ", new_state.name)
# set current state to new_state
#TODO: Confirm that this is a reference to the state in the
###### State machine ###### State machine
if new_state is StateAnimatedActor: #Testing this. Update: It works if new_state is StateAnimatedActor: #Testing this. Update: It works
current_state = new_state current_state = new_state

View File

@ -35,7 +35,7 @@ func setup():
state_timeout.autostart = false state_timeout.autostart = false
#add_child(state_timeout) #add_child(state_timeout)
#get_tree().get_root().add_child(state_timeout) #get_tree().get_root().add_child(state_timeout)
#TODO: Need to figure out how to add this to tree ##DONE: Need to figure out how to add this to tree
#modifier = StateModifier.new() #modifier = StateModifier.new()
#Hopefully this passes by reference. #Hopefully this passes by reference.

View File

@ -3,14 +3,12 @@ extends State
## Animation and movement state class ## Animation and movement state class
## ##
## A state intended to control the movement and animation ## A state intended to control the movement and animation
## functions of a KinimaticBody2D node. Initialized with a ## functions of a KinimaticBody2D node.
## player, movement node, and kinematicbody2d
## I think if we also had modifier states that transfered along with the enter and entrance of nodes, that would be helpful.
## ##
## @WIP ## @WIP
# Movement Speed in Pixels Per Second # Movement Speed in Pixels Per Second
# The b # The base movement speed and accelleration
export var horizontal_speed: float = 60 export var horizontal_speed: float = 60
export var horizontal_acceleration: float = 0 export var horizontal_acceleration: float = 0
## Movement Speed Offsets (Positive or Negative) ## Movement Speed Offsets (Positive or Negative)
@ -19,9 +17,9 @@ export var horizontal_speed_offset: float = 0
export var horizontal_speed_offset_acceleration: float = 0 export var horizontal_speed_offset_acceleration: float = 0
export var jerk_factor: float = 0 export var jerk_factor: float = 0
## Default state gravity is the project's gravity
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity") var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
#var adjusted_move_speed: float
var jerk: float var jerk: float
## Variables intended to allow state receivers to communicate ## Variables intended to allow state receivers to communicate
@ -43,16 +41,3 @@ func enter() -> void:
return 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...")

View File

@ -1,12 +1,7 @@
class_name StateMachine extends Node class_name StateMachine extends Node
#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
signal state_changed(old_state_name, new_state) signal state_changed(old_state_name, new_state)
signal modifiers_updated(modifier_type, modifier_eventid) signal modifiers_updated(modifier_type, modifier_eventid)
@ -19,10 +14,6 @@ export var starting_state_name = 'default'
export(Array,Resource) var states export(Array,Resource) var states
var states_index :Dictionary 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 _ready(): func _ready():
if debug_state_machine: if debug_state_machine:
@ -102,7 +93,7 @@ func change_to_known_state(new_state_name: String) -> void:
rpc("puppet_change_to_known_state", new_state_name) rpc("puppet_change_to_known_state", new_state_name)
#func check_parent_before_state_change(new_state_name: String) -> bool: #func check_parent_before_state_change(new_state_name: String) -> bool:
# ##TODO: Make this a verifiable funcref or something # ##CANCELLED: Make this a verifiable funcref or something
# if get_parent().has_method("check_state_change"): # if get_parent().has_method("check_state_change"):
# var _check_result = get_parent().check_state_change(new_state_name) # var _check_result = get_parent().check_state_change(new_state_name)
# if _check_result: # if _check_result:

View File

@ -38,7 +38,7 @@ func copy_StateModifierAnimatedActor(_copy_state: StateModifierAnimatedActor):
_copy_state.animation_starting_frame = animation_starting_frame _copy_state.animation_starting_frame = animation_starting_frame
_copy_state.animation_speed = animation_speed _copy_state.animation_speed = animation_speed
#TODO: finish these ##TODO: finish these
_copy_state.horizontal_speed = horizontal_speed _copy_state.horizontal_speed = horizontal_speed
_copy_state.horizontal_acceleration = horizontal_acceleration _copy_state.horizontal_acceleration = horizontal_acceleration

View File

@ -1,19 +0,0 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: State = get_node(idle_node)
func process_physics(delta: float) -> State:
#parent.velocity.y += gravity * delta
move_component.velocity.y += gravity * delta
move_component.velocity.x = move_component.desired_movement_vector.x * move_speed
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
return idle_state
return null

View File

@ -1,28 +0,0 @@
extends StateAnimatedActor
# Do states need to have references to the states they want to transition
# to? I suppose if on exit/entrance we needed to do something
func enter() -> void:
#.enter()
# parent.set_hurtbox(true)
move_component.velocity.x = 0
print ("this doesn't work does it? ")
# if debug_state:
# print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
func process_physics(delta: float) -> String:
return ''
# parent.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# parent.velocity.x = move_component.desired_movement_vector.x * move_speed
# parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
move_actor_as_desired(delta)
if move_component.velocity.x != 0.0:
return 'move'
if !parent.is_on_floor():
return 'fall'
return ''

View File

@ -1,17 +0,0 @@
[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 = {
}

View File

@ -1,21 +0,0 @@
extends StateAnimatedActor
export (NodePath) var fall_node
export (NodePath) var idle_node
onready var fall_state: State = get_node(fall_node)
onready var idle_state: State = get_node(idle_node)
func process_physics(delta: float) -> State:
move_actor_as_desired(delta)
if move_component.velocity.x == 0.0:
return idle_state
#Flip the character before tha actual move maybe.
parent.transform.x.x = move_component.get_movement_direction()
if !parent.is_on_floor():
return fall_state
return null

View File

@ -15,7 +15,7 @@ func _ready():
var state_name :String var state_name :String
state_name = 'jump' state_name = 'jump'
state_ref = get_node(callable_state_machine).get_state_reference(state_name) state_ref = get_node(callable_state_machine).get_state_reference(state_name)
#TODO Should probably assert here or something. ##TODO Should probably assert here or something.
state_ref.connect("state_entered", self, "_on_state_entered_" + state_name) state_ref.connect("state_entered", self, "_on_state_entered_" + state_name)
parent_request_state_change = funcref(get_node(callable_state_machine), 'check_parent_before_state_change') parent_request_state_change = funcref(get_node(callable_state_machine), 'check_parent_before_state_change')
@ -101,7 +101,7 @@ func wants_climb() -> bool:
_wants_climb = false _wants_climb = false
return false return false
#TODO: This is probably not a good way to do this. ##DONE: This is probably not a good way to do this.
# we want to check input once and make decisions based on # we want to check input once and make decisions based on
# velocity and desired movement. # velocity and desired movement.
#func _state_process_physics_input_idle(): #func _state_process_physics_input_idle():
@ -137,7 +137,7 @@ func _state_process_physics_idle():
if _wants_crouch == true: if _wants_crouch == true:
request_state_change.call_func('crouch') request_state_change.call_func('crouch')
#TODO: May need that 'bump' logic to make velocity work. ##TODO: May need that 'bump' logic to make velocity work.
if desired_movement_vector.x != 0: # and velocity.x != 0: if desired_movement_vector.x != 0: # and velocity.x != 0:
request_state_change.call_func('move') request_state_change.call_func('move')
@ -431,7 +431,7 @@ func _state_process_physics_crouch_move():
func _on_state_entered_jump(): func _on_state_entered_jump():
print ("how many times do I get called?") print ("how many times do I get called?")
#TODO: Make this a state variable ##TODO: Make this a state export variable
# I used to call it 'jump_force' like an idiot. # I used to call it 'jump_force' like an idiot.
velocity.y = -200 velocity.y = -200

View File

@ -131,7 +131,7 @@ func enough_stamina_for(_state_name :String) -> bool:
##TODO: We need to find a way to 'use' the item. ##DONE: We need to find a way to 'use' the item.
func use_primary_item() -> String: func use_primary_item() -> String:
if player_inventory.primary_selection != null: # Have to make sure we even have a second if player_inventory.primary_selection != null: # Have to make sure we even have a second
var _item_name :String = player_inventory.primary_selection.name var _item_name :String = player_inventory.primary_selection.name