45 lines
987 B
C#
45 lines
987 B
C#
using KitsuneCafe.SOAP;
|
|
using R3;
|
|
using UnityEngine;
|
|
|
|
namespace KitsuneCafe.Entities
|
|
{
|
|
public class SprintFeature : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Motor motor;
|
|
|
|
[SerializeField]
|
|
private ReactiveSource<bool> sprint;
|
|
|
|
[SerializeField]
|
|
private float adjustedMaxSpeed = 3f;
|
|
public float SprintSpeed => adjustedMaxSpeed;
|
|
|
|
public readonly ReactiveProperty<bool> IsSprinting = new(false);
|
|
|
|
private void Reset()
|
|
{
|
|
motor = GetComponent<Motor>();
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
sprint.AsObservable().Subscribe(Sprint);
|
|
}
|
|
|
|
public void Sprint(bool shouldSprint = true)
|
|
{
|
|
if (shouldSprint)
|
|
{
|
|
motor.ChangeMaxSpeed(adjustedMaxSpeed);
|
|
}
|
|
else
|
|
{
|
|
motor.ResetMaxSpeed();
|
|
}
|
|
|
|
IsSprinting.Value = shouldSprint;
|
|
}
|
|
}
|
|
}
|