31 lines
745 B
GDScript
31 lines
745 B
GDScript
class_name NPC
|
|
extends Node2D
|
|
|
|
var id_path: Array[Vector2i]
|
|
|
|
func is_walking() -> bool:
|
|
return not id_path.is_empty()
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
randomize()
|
|
$Sprite2D.set_nation(randi()%$Sprite2D.Nations.max)
|
|
set_spacesuit(false)
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _physics_process(delta: float) -> void:
|
|
if id_path.is_empty(): return
|
|
|
|
var target_pos = Vector2(id_path.front()*World.tile_size)
|
|
|
|
global_position = global_position.move_toward(target_pos, 1)
|
|
|
|
if global_position == target_pos:
|
|
id_path.pop_front()
|
|
|
|
func set_spacesuit(suit: bool) -> void:
|
|
$Sprite2D.set_spacesuit(suit)
|
|
|