Compare commits
2 Commits
ec869ed1cc
...
d5818f1c17
| Author | SHA1 | Date | |
|---|---|---|---|
| d5818f1c17 | |||
| 6d51eaffb0 |
|
|
@ -39,7 +39,8 @@ func _ready():
|
|||
# processed
|
||||
current_state = get_node(callable_state_machine).current_state
|
||||
#state_machine_modifiers = get_node(callable_state_machine).state_modifiers
|
||||
modifier = get_node(callable_state_machine).merged_animation_state_modifiers
|
||||
## Not doing it this way anymore modifier is applied when one arrives by signal.
|
||||
#modifier = get_node(callable_state_machine).merged_animation_state_modifiers
|
||||
|
||||
# Sprites should only have a process function
|
||||
# but if I have this will the sprite still animate?
|
||||
|
|
@ -89,6 +90,7 @@ func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
|||
animation_index = index
|
||||
current_animation_sequence = animation_index
|
||||
|
||||
## TODO: this runs everytime since the modifier will apply once and stay referenced.
|
||||
if modifier:
|
||||
##TODO: Apply the animation starting frame
|
||||
#modifier.animation_starting_frame
|
||||
|
|
@ -240,9 +242,14 @@ func _on_state_change(old_state_name:String, new_state :State):
|
|||
else:
|
||||
push_warning("Received non animated Actor state.")
|
||||
|
||||
func _on_modifiers_updated(_modifier_type :int, _modifier_action :int):
|
||||
func _on_modifiers_updated(_modifier_type :int, _modifier_action :int, _merged_modifier :StateModifier):
|
||||
##TODO: There's so many things I could maybe do here but lets target the
|
||||
## current use case.
|
||||
# current use case.
|
||||
##
|
||||
## If the signalled merged modifier is a Animation one set it
|
||||
if _merged_modifier is StateModifierAnimatedActor:
|
||||
modifier = _merged_modifier
|
||||
print("<<--- >> is active? ", modifier.is_active)
|
||||
if _modifier_type == StateModifierAnimatedActor.TYPE.ANIMATION_SUFFIX:
|
||||
print("A: ", animation, " F: ", frame, " -Modifier Changed Signal")
|
||||
# Wait for frame to finish before doing anything.
|
||||
|
|
|
|||
32
lib/classes/movement_parameters.gd
Normal file
32
lib/classes/movement_parameters.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
class_name MovementParameters
|
||||
extends Reference
|
||||
|
||||
## Vector based ones for x and y
|
||||
export var base_move_speed :Vector2
|
||||
export var base_move_acceleration :Vector2
|
||||
export var move_speed_modifier :Vector2
|
||||
export var move_speed_modifier_acceleration :Vector2
|
||||
|
||||
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
var jerk: float = 0.0
|
||||
# export var base_h_move_speed :float
|
||||
# export var base_h_move_acceleration :float
|
||||
# export var h_move_speed_modifier :float
|
||||
# export var h_move_modifier_move_acceleration :float
|
||||
|
||||
# export var base_v_move_speed :float
|
||||
# export var base_v_move_acceleration :float
|
||||
# export var v_move_speed_modifier :float
|
||||
# export var v_move_modifier_move_acceleration :float
|
||||
|
||||
func modify(_movement_parameters :MovementParameters):
|
||||
pass
|
||||
|
||||
# var movement_params :Dictionary = {
|
||||
# "_base_h_move_speed" : _state.horizontal_speed,
|
||||
# "_base_h_move_acceleration" : _state.horizontal_acceleration,
|
||||
# "_base_h_move_speed_modifier" : _state.horizontal_speed_offset,
|
||||
# "_base_h_move_modifier_move_acceleration" : _state.horizontal_speed_offset_acceleration,
|
||||
# "_jerk_factor" : _state.jerk_factor,
|
||||
# "_gravity" : _state.gravity
|
||||
# }
|
||||
|
|
@ -32,7 +32,7 @@ var acceleration = Vector2(0,0)
|
|||
var physics_delta:float
|
||||
var process_delta:float
|
||||
|
||||
var modifier: StateModifierAnimatedActor
|
||||
var modifier: StateModifierMovement
|
||||
|
||||
#Removing Probably not used
|
||||
#var attack_function: FuncRef
|
||||
|
|
@ -50,7 +50,7 @@ func _ready():
|
|||
## A reference to the current state machine state
|
||||
current_state = get_node(callable_state_machine).current_state
|
||||
## A reference to the state machine merged modifiers
|
||||
modifier = get_node(callable_state_machine).merged_animation_state_modifiers
|
||||
#modifier = get_node(callable_state_machine).merged_animation_state_modifiers
|
||||
|
||||
############
|
||||
## These get called by the parent
|
||||
|
|
@ -149,14 +149,16 @@ func new_move_actor_as_desired(_delta :float,
|
|||
_movement_override_normal := Vector2(0,0),
|
||||
_velocity_override := Vector2(0,0)) -> Vector2:
|
||||
## Calculated movement speed.
|
||||
var movement_params :Dictionary = {
|
||||
"_base_h_move_speed" : _state.horizontal_speed,
|
||||
"_base_h_move_acceleration" : _state.horizontal_acceleration,
|
||||
"_base_h_move_speed_modifier" : _state.horizontal_speed_offset,
|
||||
"_base_h_move_modifier_move_acceleration" : _state.horizontal_speed_offset_acceleration,
|
||||
"_jerk_factor" : _state.jerk_factor,
|
||||
"_gravity" : _state.gravity
|
||||
}
|
||||
# var movement_params :Dictionary = {
|
||||
# "_base_h_move_speed" : _state.horizontal_speed,
|
||||
# "_base_h_move_acceleration" : _state.horizontal_acceleration,
|
||||
# "_base_h_move_speed_modifier" : _state.horizontal_speed_offset,
|
||||
# "_base_h_move_modifier_move_acceleration" : _state.horizontal_speed_offset_acceleration,
|
||||
# "_jerk_factor" : _state.jerk_factor,
|
||||
# "_gravity" : _state.gravity
|
||||
# }
|
||||
var movement_parameters :MovementParameters = _state.get_movement_parameters()
|
||||
|
||||
var calc_velocity = Vector2.ZERO
|
||||
if _velocity_override.x != 0.0:
|
||||
calc_velocity.x = _velocity_override.x
|
||||
|
|
@ -181,7 +183,7 @@ func new_move_actor_as_desired(_delta :float,
|
|||
# but if a modifier applies, or an accelleration is given.
|
||||
# an entirely differant process occurs.
|
||||
##
|
||||
var h_speed = resolve_h_speed(movement_params)
|
||||
var h_speed = resolve_h_speed(movement_parameters)
|
||||
#if h_speed != Vector2.ZERO:
|
||||
# pass
|
||||
## If an override has been passed (we're ignoring input direction
|
||||
|
|
@ -192,7 +194,7 @@ func new_move_actor_as_desired(_delta :float,
|
|||
move_direction = resolve_move_direction(calc_inertial_dir, desired_movement_vector)
|
||||
|
||||
## Which direction will acceleration be applied.
|
||||
calc_acceleration.x = resolve_h_acceleration(movement_params, calc_velocity, move_direction.x)
|
||||
calc_acceleration.x = resolve_h_acceleration(movement_parameters, calc_velocity, move_direction.x)
|
||||
|
||||
## Direction of inertia not equal to move direction
|
||||
## If inertia is applying in a direction
|
||||
|
|
@ -258,7 +260,7 @@ func new_move_actor_as_desired(_delta :float,
|
|||
## Neutralize the inertia? but how?
|
||||
## Recalc the acceleration with inertia
|
||||
#var friction :Vector2
|
||||
calc_friction.x = resolve_h_acceleration(movement_params,Vector2(calc_inertia.x, h_speed.x), move_direction.x)
|
||||
calc_friction.x = resolve_h_acceleration(movement_parameters,Vector2(calc_inertia.x, h_speed.x), move_direction.x)
|
||||
if calc_friction.x != 0.0: ## No dapening acceleration applies
|
||||
#calc_inertia.x = move_toward(calc_inertia.x, h_speed.x, ( calc_friction.x * _delta))
|
||||
## Apply friction
|
||||
|
|
@ -282,7 +284,7 @@ func new_move_actor_as_desired(_delta :float,
|
|||
## For now, y component of velocity is just gravity
|
||||
#calc_velocity.y = movement_params["_gravity"] * Vector2.DOWN.y
|
||||
|
||||
calc_inertia.y += movement_params["_gravity"] * _delta
|
||||
calc_inertia.y += movement_parameters.gravity * _delta
|
||||
calc_velocity.y = calc_inertia.y
|
||||
|
||||
## calc x component of felicty
|
||||
|
|
@ -321,23 +323,23 @@ func apply_movement_to_parent( _velocity :Vector2) -> void:
|
|||
|
||||
|
||||
## Returns an Vector where x is MIN_SPEED and y is MAX_SPEED
|
||||
func resolve_h_speed(_params :Dictionary) -> Vector2:
|
||||
var base_speed :float = _params["_base_h_move_speed"]
|
||||
func resolve_h_speed(_params :MovementParameters) -> Vector2:
|
||||
var base_speed :float = _params.base_move_speed.x
|
||||
## if a speed difference applies
|
||||
if _params["_base_h_move_speed_modifier"] != 0:
|
||||
var speed_differance = base_speed + _params["_base_h_move_speed_modifier"]
|
||||
if _params.move_speed_modifier.x != 0:
|
||||
var speed_differance = base_speed + _params.move_speed_modifier.x
|
||||
|
||||
return(Vector2(base_speed, speed_differance))
|
||||
return Vector2(base_speed,base_speed)
|
||||
|
||||
func resolve_h_acceleration(_params :Dictionary, _inertia :Vector2, _move_direction :float) -> float:
|
||||
func resolve_h_acceleration(_params :MovementParameters, _inertia :Vector2, _move_direction :float) -> float:
|
||||
## TODO: Adjust for jerk, determine if we're currently experiencing accel
|
||||
## if a speed difference applies
|
||||
var _acceleration :float = 0.0
|
||||
var base_speed :float = _params["_base_h_move_speed"]
|
||||
if _params["_base_h_move_speed_modifier"] != 0:
|
||||
var speed_differance = base_speed + _params["_base_h_move_speed_modifier"]
|
||||
_acceleration = _params["_base_h_move_acceleration"] + _params["_base_h_move_modifier_move_acceleration"]
|
||||
var base_speed :float = _params.base_move_speed.x
|
||||
if _params.move_speed_modifier.x != 0:
|
||||
var speed_differance = base_speed + _params.move_speed_modifier.x
|
||||
_acceleration = _params.base_move_acceleration.x + _params.move_speed_modifier_acceleration.x
|
||||
##WIP: Add part where offset acceleration only applies until the inertia equals the offset or whatever
|
||||
# if sign(_params["_base_h_move_modifier_move_acceleration"]) == -1 and abs(_inertia.x) >= speed_differance:
|
||||
# #print("I should add the modifier acceleration maybe?")
|
||||
|
|
@ -345,7 +347,7 @@ func resolve_h_acceleration(_params :Dictionary, _inertia :Vector2, _move_direct
|
|||
# else:
|
||||
# print ("not yet.")
|
||||
else:
|
||||
_acceleration = _params["_base_h_move_acceleration"]
|
||||
_acceleration = _params.base_move_acceleration.x
|
||||
|
||||
## This works but I want to try something differant.
|
||||
# if _inertia.x != 0.0 and sign(_inertia.x) != sign(_move_direction):
|
||||
|
|
|
|||
|
|
@ -41,3 +41,12 @@ func enter() -> void:
|
|||
|
||||
return
|
||||
|
||||
func get_movement_parameters() -> MovementParameters:
|
||||
var movement_parameters = MovementParameters.new()
|
||||
movement_parameters.base_move_speed.x = horizontal_speed
|
||||
movement_parameters.base_move_acceleration.x = horizontal_acceleration
|
||||
movement_parameters.move_speed_modifier.x = horizontal_speed_offset
|
||||
movement_parameters.move_speed_modifier_acceleration.x = horizontal_speed_offset_acceleration
|
||||
|
||||
return movement_parameters
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ class_name StateMachine extends Node
|
|||
export var debug_state_machine: bool = false
|
||||
|
||||
signal state_changed(old_state_name, new_state)
|
||||
signal modifiers_updated(modifier_type, modifier_eventid)
|
||||
signal modifiers_updated(modifier_type, modifier_eventid, _merged_modifier)
|
||||
|
||||
|
||||
var current_state: State
|
||||
var state_modifiers: Array
|
||||
onready var merged_animation_state_modifiers :StateModifierAnimatedActor = StateModifierAnimatedActor.new()
|
||||
var merged_modifiers : Dictionary
|
||||
#onready var merged_animation_state_modifiers :StateModifierAnimatedActor = StateModifierAnimatedActor.new()
|
||||
|
||||
export var starting_state_name = 'default'
|
||||
export(Array,Resource) var states
|
||||
|
|
@ -48,19 +49,25 @@ func _ready():
|
|||
push_error("State machine cannot find starting state: " + starting_state_name)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
if(state_modifiers.size() > 0):
|
||||
merged_animation_state_modifiers.reset()
|
||||
merged_animation_state_modifiers.animation_name = 'floopy doo,'
|
||||
merge_modifiers()
|
||||
#func _physics_process(delta):
|
||||
# if(state_modifiers.size() > 0):
|
||||
# merged_animation_state_modifiers.reset()
|
||||
# merged_animation_state_modifiers.animation_name = 'floopy doo,'
|
||||
# #merge_modifiers()
|
||||
|
||||
func merge_modifiers():
|
||||
merged_animation_state_modifiers.reset()
|
||||
#merged_animation_state_modifiers.reset()
|
||||
for modgroup in merged_modifiers.keys():
|
||||
merged_modifiers["StateModifierAnimatedActor"].reset()
|
||||
for m in state_modifiers:
|
||||
if m is StateModifierAnimatedActor:
|
||||
if merged_modifiers.has("StateModifierAnimatedActor") == false:
|
||||
merged_modifiers["StateModifierAnimatedActor"] = StateModifierAnimatedActor.new()
|
||||
#print(m.name)
|
||||
var this_mod_type :StateModifierAnimatedActor = merged_modifiers["StateModifierAnimatedActor"]
|
||||
if m.is_active:
|
||||
merged_animation_state_modifiers.merge_StateModifierAnimatedActor(m)
|
||||
#merged_animation_state_modifiers.merge(m)
|
||||
this_mod_type.merge(m)
|
||||
|
||||
# Change to the new state by first calling any exit logic on the current state.
|
||||
func change_state(new_state: State) -> void:
|
||||
|
|
@ -113,13 +120,16 @@ func push_state_modifier(_state_modifier: StateModifier) -> void:
|
|||
if debug_state_machine:
|
||||
print("Add State Modifier: ", _state_modifier.name, " now size ", state_modifiers.size())
|
||||
|
||||
func handle_modifier_events(eventID :int):
|
||||
func handle_modifier_events(eventID :int, modifier_class_name :String):
|
||||
##TODO: why did I care about the events? they both do the same thing
|
||||
if eventID == StateModifier.EVENT_ID.ACTIVATED:
|
||||
if debug_state_machine:
|
||||
print ("A mod activated! Which one though?")
|
||||
print ("A mod activated! Which one though?", modifier_class_name)
|
||||
merge_modifiers()
|
||||
emit_signal("modifiers_updated",merged_animation_state_modifiers.modifier_type, eventID)
|
||||
emit_signal("modifiers_updated",merged_modifiers[modifier_class_name].modifier_type,
|
||||
eventID,
|
||||
merged_modifiers[modifier_class_name] )
|
||||
elif eventID == StateModifier.EVENT_ID.DEACTIVATED:
|
||||
merge_modifiers()
|
||||
emit_signal("modifiers_updated",merged_animation_state_modifiers.modifier_type, eventID)
|
||||
emit_signal("modifiers_updated",merged_modifiers[modifier_class_name].modifier_type, eventID, merged_modifiers[modifier_class_name])
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ var state_call_function: FuncRef
|
|||
# mp.directional_modifier = modifier_properties.directional_modifier
|
||||
# return mp
|
||||
|
||||
## Because I've tried a few ways to identify the object without a CR error
|
||||
func _to_string():
|
||||
return "StateModifier"
|
||||
|
||||
func setup(modifier_name:String, type = TYPE.NONE,_timeout_seconds : float = 0):
|
||||
name = modifier_name
|
||||
modifier_type = type
|
||||
|
|
@ -102,8 +106,11 @@ func reset():
|
|||
modifier_type = TYPE.NONE
|
||||
|
||||
func copy(_copy_state: StateModifier):
|
||||
_copy_state.name = name
|
||||
_copy_state.modifier_type = modifier_type
|
||||
## This should really be the other way.
|
||||
# _copy_state.name = name
|
||||
# _copy_state.modifier_type = modifier_type
|
||||
name = _copy_state.name
|
||||
modifier_type = _copy_state.modifier_type
|
||||
|
||||
|
||||
func merge(_merge_from_modifier: StateModifier):
|
||||
|
|
@ -113,12 +120,12 @@ func activate():
|
|||
is_active = true
|
||||
if timeout != null:
|
||||
timeout.start()
|
||||
emit_signal("modifier_event",EVENT_ID.ACTIVATED)
|
||||
emit_signal("modifier_event",EVENT_ID.ACTIVATED, to_string())
|
||||
|
||||
func deactivate():
|
||||
is_active = false
|
||||
print(name," <- Got call to deactivate.")
|
||||
emit_signal("modifier_event",EVENT_ID.DEACTIVATED)
|
||||
emit_signal("modifier_event",EVENT_ID.DEACTIVATED, to_string())
|
||||
|
||||
#func ready(modifier_name:String, anim_name:String = '', type = TYPE.NONE, timeout : float = 0, parent:Node = null, function_name : String = "") -> Timer:
|
||||
# name = modifier_name
|
||||
|
|
|
|||
|
|
@ -8,15 +8,8 @@ var animation_suffix: String = ''
|
|||
var animation_starting_frame: int = 0
|
||||
var animation_speed: float
|
||||
|
||||
var horizontal_speed: float = 0
|
||||
var horizontal_acceleration: float = 0
|
||||
## Movement Speed Offsets (Positive or Negative)
|
||||
var horizontal_speed_offset: float = 0
|
||||
## Applies only if offset applies
|
||||
var horizontal_speed_offset_acceleration: float = 0
|
||||
var jerk_factor: float = 0
|
||||
|
||||
var gravity: int = 0
|
||||
func _to_string():
|
||||
return "StateModifierAnimatedActor"
|
||||
|
||||
func reset():
|
||||
.reset()
|
||||
|
|
@ -24,45 +17,64 @@ func reset():
|
|||
animation_suffix = ''
|
||||
animation_starting_frame = 0
|
||||
|
||||
horizontal_speed = 0
|
||||
horizontal_acceleration = 0
|
||||
## Movement Speed Offsets (Positive or Negative)
|
||||
horizontal_speed_offset = 0
|
||||
## Applies only if offset applies
|
||||
horizontal_speed_offset_acceleration = 0
|
||||
jerk_factor = 0
|
||||
|
||||
func copy_StateModifierAnimatedActor(_copy_state: StateModifierAnimatedActor):
|
||||
func copy(_copy_state: StateModifier):
|
||||
.copy(_copy_state)
|
||||
_copy_state.animation_name = animation_name
|
||||
_copy_state.animation_starting_frame = animation_starting_frame
|
||||
_copy_state.animation_speed = animation_speed
|
||||
|
||||
##TODO: finish these
|
||||
_copy_state.horizontal_speed = horizontal_speed
|
||||
_copy_state.horizontal_acceleration = horizontal_acceleration
|
||||
## Using is gives me cyclic redundancy problems
|
||||
#if _copy_state is StateModifierAnimatedActor:
|
||||
#if _copy_state.is_class("StateModifierAnimatedActor"):
|
||||
if _copy_state.to_string() == "StateModifierAnimatedActor":
|
||||
_copy_state.animation_name = animation_name
|
||||
_copy_state.animation_starting_frame = animation_starting_frame
|
||||
_copy_state.animation_speed = animation_speed
|
||||
else:
|
||||
print_debug("Non AnimatedActor modifier passed into this modifier")
|
||||
|
||||
func merge_StateModifierAnimatedActor(_merge_from_modifier: StateModifierAnimatedActor):
|
||||
##DEPR: Need to remove this
|
||||
#func copy_StateModifierAnimatedActor(_copy_state: StateModifierAnimatedActor):
|
||||
# .copy(_copy_state)
|
||||
# _copy_state.animation_name = animation_name
|
||||
# _copy_state.animation_starting_frame = animation_starting_frame
|
||||
# _copy_state.animation_speed = animation_speed
|
||||
|
||||
func merge(_merge_from_modifier: StateModifier):
|
||||
.merge(_merge_from_modifier)
|
||||
if modifier_type == TYPE.NONE and _merge_from_modifier.modifier_type != TYPE.NONE:
|
||||
modifier_type = _merge_from_modifier.modifier_type
|
||||
|
||||
#_copy_state.animation_name += animation_name
|
||||
match _merge_from_modifier.modifier_type:
|
||||
TYPE.ANIMATION_SUFFIX:
|
||||
# Attempt to seemlessly transition animations.
|
||||
if _merge_from_modifier.animation_suffix != '':
|
||||
animation_suffix = _merge_from_modifier.animation_suffix
|
||||
TYPE.REPLACE_ANIMATION:
|
||||
if _merge_from_modifier.animation_name != '':
|
||||
animation_name = _merge_from_modifier.animation_name
|
||||
_: # None
|
||||
#print ('physics?')
|
||||
horizontal_speed += _merge_from_modifier.horizontal_speed
|
||||
horizontal_acceleration += _merge_from_modifier.horizontal_acceleration
|
||||
horizontal_speed_offset += _merge_from_modifier.horizontal_speed_offset
|
||||
horizontal_speed_offset_acceleration += _merge_from_modifier.horizontal_speed_offset_acceleration
|
||||
|
||||
#print(_merge_from_modifier.to_string(), " I'm a mod named: ", _merge_from_modifier.get_class())
|
||||
#if _merge_from_modifier is StateModifierAnimatedActor:
|
||||
if _merge_from_modifier.to_string() == "StateModifierAnimatedActor":
|
||||
if modifier_type == TYPE.NONE and _merge_from_modifier.modifier_type != TYPE.NONE:
|
||||
modifier_type = _merge_from_modifier.modifier_type
|
||||
|
||||
#_copy_state.animation_name += animation_name
|
||||
match _merge_from_modifier.modifier_type:
|
||||
TYPE.ANIMATION_SUFFIX:
|
||||
# Attempt to seemlessly transition animations.
|
||||
if _merge_from_modifier.animation_suffix != '':
|
||||
animation_suffix = _merge_from_modifier.animation_suffix
|
||||
TYPE.REPLACE_ANIMATION:
|
||||
if _merge_from_modifier.animation_name != '':
|
||||
animation_name = _merge_from_modifier.animation_name
|
||||
# _: # None
|
||||
# print ('physics?')
|
||||
|
||||
##DEPR: Need to remove this
|
||||
#func merge_StateModifierAnimatedActor(_merge_from_modifier: StateModifierAnimatedActor):
|
||||
# .merge(_merge_from_modifier)
|
||||
# if modifier_type == TYPE.NONE and _merge_from_modifier.modifier_type != TYPE.NONE:
|
||||
# modifier_type = _merge_from_modifier.modifier_type
|
||||
#
|
||||
# #_copy_state.animation_name += animation_name
|
||||
# match _merge_from_modifier.modifier_type:
|
||||
# TYPE.ANIMATION_SUFFIX:
|
||||
# # Attempt to seemlessly transition animations.
|
||||
# if _merge_from_modifier.animation_suffix != '':
|
||||
# animation_suffix = _merge_from_modifier.animation_suffix
|
||||
# TYPE.REPLACE_ANIMATION:
|
||||
# if _merge_from_modifier.animation_name != '':
|
||||
# animation_name = _merge_from_modifier.animation_name
|
||||
# _: # None
|
||||
# print ('physics?')
|
||||
#
|
||||
#
|
||||
|
||||
#_copy_state.animation_starting_frame = animation_starting_frame
|
||||
#_copy_state.animation_speed = animation_speed
|
||||
|
|
|
|||
41
lib/classes/state_modifier_movement.gd
Normal file
41
lib/classes/state_modifier_movement.gd
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
class_name StateModifierMovement
|
||||
extends StateModifier
|
||||
|
||||
## Movement Modifiers
|
||||
var horizontal_speed: float = 0
|
||||
var horizontal_acceleration: float = 0
|
||||
## Movement Speed Offsets (Positive or Negative)
|
||||
var horizontal_speed_offset: float = 0
|
||||
## Applies only if offset applies
|
||||
var horizontal_speed_offset_acceleration: float = 0
|
||||
var jerk_factor: float = 0
|
||||
|
||||
var gravity: int = 0
|
||||
|
||||
func _to_string():
|
||||
return "StateModifierMovement"
|
||||
|
||||
func reset():
|
||||
.reset()
|
||||
|
||||
horizontal_speed = 0
|
||||
horizontal_acceleration = 0
|
||||
## Movement Speed Offsets (Positive or Negative)
|
||||
horizontal_speed_offset = 0
|
||||
## Applies only if offset applies
|
||||
horizontal_speed_offset_acceleration = 0
|
||||
jerk_factor = 0
|
||||
|
||||
func copy(_copy_state: StateModifier):
|
||||
.copy(_copy_state)
|
||||
if _copy_state.to_string() == "StateModifierMovement":
|
||||
_copy_state.horizontal_speed = horizontal_speed
|
||||
_copy_state.horizontal_acceleration = horizontal_acceleration
|
||||
|
||||
func merge(_merge_from_modifier: StateModifier):
|
||||
.merge(_merge_from_modifier)
|
||||
if _merge_from_modifier.to_string() == "StateModifierMovement":
|
||||
horizontal_speed += _merge_from_modifier.horizontal_speed
|
||||
horizontal_acceleration += _merge_from_modifier.horizontal_acceleration
|
||||
horizontal_speed_offset += _merge_from_modifier.horizontal_speed_offset
|
||||
horizontal_speed_offset_acceleration += _merge_from_modifier.horizontal_speed_offset_acceleration
|
||||
|
|
@ -89,6 +89,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://src/classes/movement_component.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "MovementParameters",
|
||||
"language": "GDScript",
|
||||
"path": "res://lib/classes/movement_parameters.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "Movement_StateReceiver",
|
||||
"language": "GDScript",
|
||||
|
|
@ -149,6 +154,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://lib/classes/state_modifier_animation.gd"
|
||||
}, {
|
||||
"base": "StateModifier",
|
||||
"class": "StateModifierMovement",
|
||||
"language": "GDScript",
|
||||
"path": "res://lib/classes/state_modifier_movement.gd"
|
||||
}, {
|
||||
"base": "CanvasLayer",
|
||||
"class": "UIComponent",
|
||||
"language": "GDScript",
|
||||
|
|
@ -171,6 +181,7 @@ _global_script_class_icons={
|
|||
"LevelTransition": "",
|
||||
"Modifier_Receiver": "",
|
||||
"MovementComponent": "",
|
||||
"MovementParameters": "",
|
||||
"Movement_StateReceiver": "",
|
||||
"PlayerData": "",
|
||||
"Projectile": "",
|
||||
|
|
@ -183,6 +194,7 @@ _global_script_class_icons={
|
|||
"StateMachineAnimatedActor": "",
|
||||
"StateModifier": "",
|
||||
"StateModifierAnimatedActor": "",
|
||||
"StateModifierMovement": "",
|
||||
"UIComponent": ""
|
||||
}
|
||||
|
||||
|
|
@ -401,6 +413,10 @@ dash_2={
|
|||
common/enable_pause_aware_picking=true
|
||||
2d/default_gravity=600
|
||||
|
||||
[mono]
|
||||
|
||||
project/assembly_name="Attempt 2"
|
||||
|
||||
[physics]
|
||||
|
||||
2d/default_gravity=280
|
||||
|
|
|
|||
|
|
@ -76,5 +76,5 @@ func _on_state_exited_attack_sword():
|
|||
print("you just swung your sword, you should get a modifier.")
|
||||
#attack_sword.timeout.start()
|
||||
attack_sword.activate()
|
||||
print ("you has merged as? :" ,modifier.animation_name)
|
||||
print ("you has merged as? :" ,modifier.animation_suffix)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user