class_name Actor extends KinematicBody2D #var velocity = Vector2(0,0) #var direction = Vector2(-1,0) export(String, "Player", "Enemy", "NPC", "Object") var actor_type #export var sprite_facing_right: bool = true export var debug_actor: bool = false #onready var movement_animations: AnimatedSprite = $AnimatedSprite onready var sound_effect_player: AudioStreamPlayer = $SE_Player #onready var movement_component: MovementComponent = $movement_component onready var movement_component: Movement_StateReceiver = $Movement_StateReceiver #onready var movement_state_machine: StateMachineAnimatedActor = $movement_state_machine onready var movement_state_machine: StateMachine = $Movement_StateMachine ##TODO: # Can't seem to implement the ready and process node functions # without causing a double run somehow. Not sure why. # not a huge deal because this is mostly to help with # interfaces for the state machines. func _ready() -> void: pass #movement_state_machine.init_animated_actor(self) #movement_component.attack_function = funcref(self, "attack") # movement_component.player_number = player_number func _unhandled_input(event: InputEvent) -> void: if actor_type == "Player": movement_component.process_input(event) #movement_state_machine.process_input(event) func _physics_process(delta: float) -> void: # Input based or polling input is not done in _unhandled_input # gives us the ability to turn off polling this way if actor_type == "Player": movement_component.process_physics_input(delta) movement_component.process_physics(delta) #movement_state_machine.process_physics(delta) # #func _process(delta: float) -> void: # if actor_type == "NPC" or actor_type == "Enemy": # movement_component.process(delta) # movement_state_machine.process_frame(delta) ## PlayerInfo.player_position = global_position # #play_sound_frame(movement_animations.animation , movement_animations.frame) func attack(): #print(self.name, ": It's not inheritence, it's funcrefs") # if movement_state_machine.current_state.name != 'attack': # if($movement_state_machine/attack): # movement_state_machine.change_state($movement_state_machine/attack) # if ($Hitbox_Component/CollisionShape2D): # #print(self.name, ": Found a hitbox") # var hit_box = $Hitbox_Component # hit_box.set_hitbox(true) pass