mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-15 08:53:47 +00:00
Chest animation, alarm box entity
This commit is contained in:
parent
f28a3b70fd
commit
164c186201
25 changed files with 177 additions and 23 deletions
62
Scripts/Activables/DialogueActor3D.cs
Normal file
62
Scripts/Activables/DialogueActor3D.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using Cirno.Scripts.Interactables;
|
||||
using Cirno.Scripts.Misc;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
||||
[Tool]
|
||||
public partial class DialogueActor3D : Area3D, IInteractable
|
||||
{
|
||||
[Export] public StringName TimelineName = "";
|
||||
private DialogueTools _dialogueInstance;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
if (string.IsNullOrWhiteSpace(TimelineName))
|
||||
{
|
||||
this.RemoveFromGroup("Interactable");
|
||||
|
||||
return;
|
||||
}
|
||||
_dialogueInstance = new DialogueTools();
|
||||
_dialogueInstance.Init(this, TimelineName);
|
||||
}
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, string> props)
|
||||
{
|
||||
TimelineName = props["timeline"];
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return false;
|
||||
if (string.IsNullOrWhiteSpace(TimelineName)) return false;
|
||||
_dialogueInstance.Start(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanActivate()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector2 GetGlobalPosition2D()
|
||||
{
|
||||
return new Vector2(this.GlobalPosition.X, this.GlobalPosition.Z);
|
||||
}
|
||||
|
||||
public Vector2 GetScreenPosition()
|
||||
{
|
||||
if (CameraController3D.Instance is null)
|
||||
{
|
||||
return this.GetGlobalPosition2D();
|
||||
}
|
||||
|
||||
return CameraController3D.Instance.UnprojectPosition(this.GlobalPosition);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue