mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
72 lines
No EOL
1.4 KiB
C#
72 lines
No EOL
1.4 KiB
C#
using Godot;
|
|
|
|
namespace Cirno.Scripts.Actors;
|
|
|
|
[Tool]
|
|
public partial class Elevator3D : PathFollow3D, IActivable
|
|
{
|
|
[Export] public float Speed { get; set; }
|
|
|
|
private bool _isMoving = false;
|
|
private float _multiplier = 1f;
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (Engine.IsEditorHint()) return;
|
|
if (!_isMoving) return;
|
|
|
|
ProgressRatio += (Speed * (float)delta) * _multiplier;
|
|
|
|
if (ProgressRatio is >= 1 or <= 0)
|
|
{
|
|
_isMoving = false;
|
|
}
|
|
|
|
}
|
|
|
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
|
{
|
|
if (Engine.IsEditorHint()) return false;
|
|
if (_isMoving) return false;
|
|
|
|
StartMoving();
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Toggle()
|
|
{
|
|
this.Activate();
|
|
}
|
|
|
|
public void StartMoving()
|
|
{
|
|
if (_isMoving) return;
|
|
_isMoving = true;
|
|
|
|
if (ProgressRatio <= 0)
|
|
{
|
|
_multiplier = 1f;
|
|
}
|
|
else if (ProgressRatio >= 1)
|
|
{
|
|
_multiplier = -1f;
|
|
}
|
|
}
|
|
|
|
public void OnActorCollision(Area3D actor)
|
|
{
|
|
|
|
}
|
|
|
|
public void OnBodyCollision(Node3D node)
|
|
{
|
|
//GD.Print($"{Name} Body Entered: {node.Name}");
|
|
ReverseUp();
|
|
}
|
|
|
|
private void ReverseUp()
|
|
{
|
|
_multiplier = 1f;
|
|
}
|
|
} |