mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 10:55:54 +00:00
Elevators
This commit is contained in:
parent
929d993f99
commit
4fc136e5d7
39 changed files with 4471 additions and 264 deletions
48
Scripts/Actors/Elevator3D.cs
Normal file
48
Scripts/Actors/Elevator3D.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
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 (!_isMoving) return;
|
||||
|
||||
ProgressRatio += (Speed * (float)delta) * _multiplier;
|
||||
|
||||
if (ProgressRatio is >= 1 or <= 0)
|
||||
{
|
||||
_isMoving = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (_isMoving) return false;
|
||||
|
||||
StartMoving();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void StartMoving()
|
||||
{
|
||||
if (_isMoving) return;
|
||||
_isMoving = true;
|
||||
|
||||
if (ProgressRatio <= 0)
|
||||
{
|
||||
_multiplier = 1f;
|
||||
}
|
||||
else if (ProgressRatio >= 1)
|
||||
{
|
||||
_multiplier = -1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/Actors/Elevator3D.cs.uid
Normal file
1
Scripts/Actors/Elevator3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cyr7ypanl8drq
|
||||
Loading…
Add table
Add a link
Reference in a new issue