chill-jam-10-2024/scripts/NPC.cs

55 lines
1 KiB
C#

using Godot;
using System;
using Godot.Collections;
[Tool]
public partial class NPC : Node2D
{
[Export] public string NPCName;
[Export] public SpriteFrames Frames;
[Export] public Array<string> DialogLines = new Array<string>();
private AnimatedSprite2D _sprite;
public override void _Ready()
{
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
if (Frames is not null) _sprite.SpriteFrames = Frames;
_sprite.Play("default");
}
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
if (Engine.IsEditorHint())
{
if (Frames is not null && _sprite.SpriteFrames != Frames) _sprite.SpriteFrames = Frames;
}
}
public void test()
{
if (_sprite.Animation == "walk")
{
_sprite.Play("default");
}
else
{
_sprite.Play("walk");
}
}
private void _on_interactable_player_near_by(Player player)
{
player.InteractableObjects.Add(this);
}
private void _on_interactable_player_left(Player player)
{
player.InteractableObjects.Remove(this);
}
}