add initial project files and configurations, including EventBus, systems, and resources
This commit is contained in:
38
Code/Systems/BenchPressSystem.cs
Normal file
38
Code/Systems/BenchPressSystem.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user