added modular animation system for drones
This commit is contained in:
@@ -7,8 +7,10 @@ extends CharacterBody2D
|
||||
@export var hit_points : float
|
||||
@export var fuel_tank_capacity : float
|
||||
@export var movement_speed : float
|
||||
signal change_animation(anim_to_change_to)
|
||||
var animation_state_machine : MachineGlobals.regular_states
|
||||
var look_dir : MachineGlobals.look_direction
|
||||
var states : Array
|
||||
var effects : Array
|
||||
var add_on_slots : int
|
||||
var machine_upgrades : Dictionary
|
||||
var ability_timer : Timer
|
||||
@@ -21,6 +23,11 @@ var current_fuel_in_tank : float
|
||||
@abstract func model_ability() -> float
|
||||
@abstract func class_ability() -> float
|
||||
|
||||
@abstract func listen_to_animation_signals(next_anim_state : MachineGlobals.regular_states) -> void
|
||||
|
||||
func _ready() -> void:
|
||||
connect("change_animation",listen_to_animation_signals)
|
||||
|
||||
func interact() -> void :
|
||||
pass
|
||||
|
||||
@@ -31,8 +38,21 @@ func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
func _movement(delta: float) -> void :
|
||||
DebugGlobal.set_debug_info("Velocity", self.velocity )
|
||||
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
self.velocity = input_direction * movement_speed
|
||||
if self.velocity != Vector2.ZERO && animation_state_machine in [MachineGlobals.regular_states.IDLING,MachineGlobals.regular_states.INTERACTING] :
|
||||
animation_state_machine = MachineGlobals.regular_states.WALKING
|
||||
if self.velocity.y < 0 :
|
||||
look_dir = MachineGlobals.look_direction.UP
|
||||
elif self.velocity.y > 0 :
|
||||
look_dir = MachineGlobals.look_direction.DOWN
|
||||
elif self.velocity.x > 0 :
|
||||
look_dir = MachineGlobals.look_direction.RIGHT
|
||||
elif self.velocity.x < 0 :
|
||||
look_dir = MachineGlobals.look_direction.LEFT
|
||||
else :
|
||||
animation_state_machine = MachineGlobals.regular_states.IDLING
|
||||
|
||||
func _action_process(delta:float) -> void :
|
||||
if action_timer != null && action_timer.is_stopped():
|
||||
@@ -47,3 +67,10 @@ func _ability_process(delta:float) -> void :
|
||||
ability_timer.start(class_ability())
|
||||
elif Input.is_action_just_pressed("model_ability") :
|
||||
ability_timer.start(model_ability())
|
||||
|
||||
func _get_body_parts() -> Array :
|
||||
var clist : Array
|
||||
for a in self.get_children() :
|
||||
if a is AnimatedSprite2D :
|
||||
clist.append(a)
|
||||
return clist
|
||||
|
||||
Reference in New Issue
Block a user