BREAKING CHANGE: State 0.2.0
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using Syntriax.Modules.ToggleState;
|
||||
using Syntriax.Modules.State;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Action.Samples
|
||||
{
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public class PlatformerJump : ActionBaseWithDeactivation
|
||||
public class PlatformerJump : ActionWithDeactivation
|
||||
{
|
||||
[SerializeField] private float jumpSpeed = 10f;
|
||||
public float JumpSpeed { get => jumpSpeed; set => jumpSpeed = value; }
|
||||
@@ -25,22 +25,25 @@ namespace Syntriax.Modules.Action.Samples
|
||||
set => suspensionMultiplier = value * Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
protected IToggleState gameObjectToggleState = null;
|
||||
protected IStateEnable gameObjectStateEnable = null;
|
||||
protected bool airSuspension = false;
|
||||
protected Rigidbody2D rigid = null;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
rigid = GetComponent<Rigidbody2D>();
|
||||
gameObjectToggleState = GetComponent<IToggleState>();
|
||||
gameObjectStateEnable = GetComponent<IStateEnable>();
|
||||
|
||||
FallMultiplier = fallMultiplier;
|
||||
SuspensionMultiplier = suspensionMultiplier;
|
||||
|
||||
OnActivated += _ => OnActionDeactivated();
|
||||
OnDeactivated += _ => OnActionActivated();
|
||||
}
|
||||
|
||||
protected virtual void FixedUpdate()
|
||||
{
|
||||
if (!MemberToggleState.IsToggledNullChecked() || !gameObjectToggleState.IsToggledNullChecked())
|
||||
if (!StateEnable.IsEnabledNullChecked() || !gameObjectStateEnable.IsEnabledNullChecked())
|
||||
return;
|
||||
|
||||
if (rigid.velocity.y < FallThreshold)
|
||||
@@ -59,17 +62,17 @@ namespace Syntriax.Modules.Action.Samples
|
||||
rigid.velocity = velocity;
|
||||
}
|
||||
|
||||
protected override void OnActionDeactivated()
|
||||
protected void OnActionDeactivated()
|
||||
{
|
||||
if (!gameObjectToggleState.IsToggledNullChecked())
|
||||
if (!gameObjectStateEnable.IsEnabledNullChecked())
|
||||
return;
|
||||
|
||||
airSuspension = false;
|
||||
}
|
||||
|
||||
protected override void OnActionActivated()
|
||||
protected void OnActionActivated()
|
||||
{
|
||||
if (!gameObjectToggleState.IsToggledNullChecked())
|
||||
if (!gameObjectStateEnable.IsEnabledNullChecked())
|
||||
return;
|
||||
|
||||
Jump();
|
||||
|
Reference in New Issue
Block a user