mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Teleporter visualizer
This commit is contained in:
parent
ba481a5914
commit
1a8e88f719
6 changed files with 78 additions and 17 deletions
|
|
@ -8,6 +8,7 @@ using GTweensGodot.Extensions;
|
|||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
||||
[Tool]
|
||||
public partial class Teleporter : Activable
|
||||
{
|
||||
[Export]
|
||||
|
|
@ -41,30 +42,25 @@ public partial class Teleporter : Activable
|
|||
|
||||
public override void _Ready()
|
||||
{
|
||||
_particles = GetNode<GpuParticles2D>("./Particles");
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
|
||||
|
||||
_animatedSprite.Play(IsEnabled ? "Active" : "Default");
|
||||
if (Engine.IsEditorHint()) return;
|
||||
|
||||
_particles = GetNode<GpuParticles2D>("./Particles");
|
||||
|
||||
IsPrimed = true;
|
||||
_particles.Emitting = false;
|
||||
_particleTimer = 0;
|
||||
|
||||
this.Visible = !Invisible;
|
||||
|
||||
if (IsEnabled)
|
||||
{
|
||||
_animatedSprite.Play("Active");
|
||||
}
|
||||
else
|
||||
{
|
||||
_animatedSprite.Play("Default");
|
||||
}
|
||||
|
||||
|
||||
_teleportStartSound = GetNodeOrNull<AudioStreamPlayer2D>("TeleportStart");
|
||||
_teleportEndSound = GetNodeOrNull<AudioStreamPlayer2D>("TeleportEnd");
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
if (!_particles.Emitting) return;
|
||||
|
||||
_particleTimer += delta;
|
||||
|
|
|
|||
41
Scripts/Utils/TeleporterLinker.cs
Normal file
41
Scripts/Utils/TeleporterLinker.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Cirno.Scripts.Activables;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Utils;
|
||||
|
||||
[Tool]
|
||||
public partial class TeleporterLinker : Node2D
|
||||
{
|
||||
private Teleporter _teleporter;
|
||||
|
||||
[Export] public Color Color { get; set; } = Colors.Blue;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_teleporter = GetParentOrNull<Teleporter>();
|
||||
}
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
if (!Engine.IsEditorHint())
|
||||
return;
|
||||
if (_teleporter is null) return;
|
||||
if (!_teleporter.IsEnabled) return;
|
||||
if (_teleporter.Target is null) return;
|
||||
|
||||
Vector2 start = _teleporter.GlobalPosition;
|
||||
Vector2 end = _teleporter.Target.GlobalPosition;
|
||||
|
||||
DrawLine(ToLocal(start), ToLocal(end), Color, 2.0f);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1
Scripts/Utils/TeleporterLinker.cs.uid
Normal file
1
Scripts/Utils/TeleporterLinker.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://3jcfdfymcvxu
|
||||
Loading…
Add table
Add a link
Reference in a new issue