using Godot;

namespace Movementtests.player_controller.Scripts;

public partial class Gravity: Node3D
{
	[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
	public float Weight        { get; set; } = 3.0f;
	[Export(PropertyHint.Range, "0,2,0.01,or_greater")]
	public float StartVelocity { get; set; } = 1.0f;
	[Export(PropertyHint.Range, "0.1,10,0.1,or_greater")]
	public float DoubleJumpSpeedFactor { get; set; } = 2f;
	[Export(PropertyHint.Range, "0.1,10,0.1,or_greater")]
	public float JumpFromDashSpeedFactor { get; set; } = 2f;
	[Export(PropertyHint.Range, "0.1,10,0.1,or_greater")]
	public float JumpFromWallSpeedFactor { get; set; } = 2f;
	[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
	public float AdditionalGravityPower { get; set; } = 1f;

	private float _gravity;

	public void Init(float gravitySetting)
	{
		_gravity = gravitySetting;
	}

	public float CalculateJumpForce() => _gravity * (StartVelocity / AdditionalGravityPower);
	public float CalculateJumpFromDashForce() => CalculateJumpForce() * JumpFromDashSpeedFactor;
	public float CalculateJumpFromWallForce() => CalculateJumpForce() * JumpFromWallSpeedFactor;
	public float CalculateDoubleJumpForce() => CalculateJumpForce() * DoubleJumpSpeedFactor;
	public float CalculateGravityForce() => _gravity * Weight;
}
