mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:55:35 +00:00
52 lines
No EOL
1.2 KiB
C#
52 lines
No EOL
1.2 KiB
C#
using Cirno.Scripts.Interactables;
|
|
using Cirno.Scripts.Misc;
|
|
using Cirno.Scripts.Resources.Events;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Activables;
|
|
|
|
public partial class NPC : Area2D, IInteractable
|
|
{
|
|
|
|
[Export] public Array<EventResource> Events;
|
|
|
|
private ScriptableBase _scriptable;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_scriptable = new ScriptableBase();
|
|
_scriptable.Events = Events;
|
|
|
|
// Add as sibling so relative paths still work
|
|
GetParent().CallDeferred("add_child", _scriptable);
|
|
}
|
|
|
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
|
{
|
|
_scriptable?.Activate(activationType);
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool CanActivate()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public Vector2 GetScreenPosition()
|
|
{
|
|
if (CameraController.Instance is null)
|
|
{
|
|
return this.GlobalPosition;
|
|
}
|
|
|
|
return this.GlobalPosition - CameraController.Instance.GlobalPosition +
|
|
(GetViewport().GetVisibleRect().Size / 2);
|
|
}
|
|
|
|
public Vector2 GetGlobalPosition2D()
|
|
{
|
|
return GetGlobalPosition();
|
|
}
|
|
} |