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 = $AudioStreamPlayer_StateReceiver #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 onready var animated_sprite : AnimatedSprite = $AnimatedSprite_StateReceiver ## Multiplayer Variables puppet var puppet_pos = Vector2() #puppet var puppet_anim_sprite_frame :int #puppet var puppet_anim_sprite_name :String puppet var puppet_transform: Transform2D ##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: # puppet_anim_sprite_name = animated_sprite.animation # puppet_anim_sprite_frame = animated_sprite.frame puppet_transform = transform ## Disable Process and Physics on puppets # if not is_network_master(): # animated_sprite.set_process(false) # animated_sprite.set_physics_process(false) #movement_state_machine.init_animated_actor(self) #movement_component.attack_function = funcref(self, "attack") # movement_component.player_number = player_number #func _process(delta): # if is_network_master(): # rset("puppet_anim_sprite_name", animated_sprite.animation) # rset("puppet_anim_sprite_frame", animated_sprite.frame) # else: # animated_sprite.animation = puppet_anim_sprite_name # animated_sprite.frame = puppet_anim_sprite_frame func _unhandled_input(event: InputEvent) -> void: if is_network_master(): 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 is_network_master(): if actor_type == "Player": movement_component.process_physics_input(delta) movement_component.process_physics(delta) rset("puppet_pos", position) rset("puppet_transform", transform) else: position = puppet_pos transform = puppet_transform #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