Files
slapstick/Abilities/Sword/Sword.cs
2026-01-17 18:33:45 -06:00

35 lines
717 B
C#

using Godot;
using System;
public partial class Sword : MeleeBase
{
[Export] public float SweepArcDegrees { get; set; } = 90f;
[Export] public float Lifetime { get; set; } = 0.25f;
float _elapsedTime = 0f;
float _startRotation, _endRotation;
public override void _Ready()
{
base._Ready();
_startRotation = Rotation + Mathf.DegToRad(-SweepArcDegrees * 0.5f);
_endRotation = Rotation + Mathf.DegToRad(SweepArcDegrees * 0.5f);
Rotation = _startRotation;
}
public override void _PhysicsProcess(double delta)
{
_elapsedTime += (float)delta;
var t = _elapsedTime / Lifetime;
Rotation = Mathf.Lerp(_startRotation, _endRotation, t);
if (_elapsedTime >= Lifetime)
{
QueueFree();
}
}
}