Added Dohya
This commit is contained in:
@@ -45,6 +45,7 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
NetworkVariableWritePermission.Server);
|
||||
|
||||
private bool hasSnapTarget;
|
||||
private bool maximumEndpointLatched;
|
||||
private float snapTargetValue;
|
||||
private float automaticReturnTime = -1f;
|
||||
|
||||
@@ -57,6 +58,7 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
|
||||
public event Action<float> ValueChanged;
|
||||
public event Action<bool> StateChanged;
|
||||
public event Action MaximumReached;
|
||||
|
||||
public override string InteractionPrompt => IsControlledByLocalPlayer
|
||||
? ReleasePrompt
|
||||
@@ -96,6 +98,7 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
{
|
||||
synchronizedValue.Value = InitialPositionValue;
|
||||
isActivated.Value = initialPositionIsMaximum;
|
||||
maximumEndpointLatched = initialPositionIsMaximum;
|
||||
}
|
||||
|
||||
synchronizedValue.OnValueChanged += HandleValueChanged;
|
||||
@@ -220,9 +223,24 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
const float endpointTolerance = 0.001f;
|
||||
|
||||
if (synchronizedValue.Value >= 1f - endpointTolerance)
|
||||
{
|
||||
SetActivation(true);
|
||||
else if (synchronizedValue.Value <= endpointTolerance)
|
||||
if (!maximumEndpointLatched)
|
||||
{
|
||||
maximumEndpointLatched = true;
|
||||
MaximumReached?.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
maximumEndpointLatched = false;
|
||||
}
|
||||
|
||||
if (synchronizedValue.Value <= endpointTolerance)
|
||||
{
|
||||
maximumEndpointLatched = false;
|
||||
SetActivation(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActivation(bool activated)
|
||||
|
||||
Reference in New Issue
Block a user