Cleanup Actor class.
This commit is contained in:
parent
07e98d0736
commit
5ba9c972e6
|
|
@ -1,63 +1,32 @@
|
|||
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)
|
||||
movement_component.process_unhandled_input(event)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Input based or polling input is not done in _unhandled_input
|
||||
|
|
@ -71,24 +40,10 @@ func _physics_process(delta: float) -> void:
|
|||
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 _process(delta: float) -> void:
|
||||
if actor_type == "NPC" or actor_type == "Enemy":
|
||||
if is_network_master():
|
||||
movement_component.process(delta)
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func process(delta):
|
|||
call('_state_process_' + current_state.name)
|
||||
|
||||
# For event based input polling (Hadouken?)
|
||||
func process_input(event: InputEvent):
|
||||
func process_unhandled_input(event: InputEvent):
|
||||
# Reset desired movement vector
|
||||
desired_movement_vector = Vector2(0,0)
|
||||
if has_method('_state_process_input_' + current_state.name):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user