38 lines
880 B
C#
38 lines
880 B
C#
using Godot;
|
|
using MaxEffort.Code.Core;
|
|
|
|
namespace MaxEffort.Code.Systems;
|
|
|
|
[GlobalClass]
|
|
public partial class BenchPressSystem : BaseLiftSystem
|
|
{
|
|
protected override void HandleEffort(float effortDelta)
|
|
{
|
|
CurrentProgress += PowerPerClick * effortDelta;
|
|
CheckWin();
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
if (IsLiftComplete) return;
|
|
|
|
if (CurrentProgress > 0)
|
|
{
|
|
CurrentProgress -= Gravity * (float)delta;
|
|
CurrentProgress = Mathf.Max(0, CurrentProgress);
|
|
}
|
|
|
|
var ratio = CurrentProgress / TargetValue;
|
|
|
|
EventBus.PublishLiftProgress(ratio);
|
|
EventBus.PublishLiftVisualHeight(ratio);
|
|
}
|
|
|
|
private void CheckWin()
|
|
{
|
|
if (CurrentProgress >= TargetValue)
|
|
{
|
|
EventBus.PublishLiftCompleted(true);
|
|
}
|
|
}
|
|
} |