commit ba969866c411b08f0ad935251872d2bc2abd8e99
parent 8f18935ae43e1dd9646e69296504010643fd5c37
Author: PlutoTank <qwolkensperg@gmail.com>
Date: Thu, 16 Apr 2020 15:17:57 -0400
triggers can now take input context
Diffstat:
4 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/Assets/Scripts/Slimecing/Triggers/TriggerInput.cs b/Assets/Scripts/Slimecing/Triggers/TriggerInput.cs
@@ -19,9 +19,9 @@ namespace Slimecing.Triggers
foreach (var action in currentPlayerInput.actions)
{
if (!currentActionReference.action.name.Equals(action.name)) continue;
- action.started += ctx => TriggerStarted(player);
- action.performed += ctx => TriggerPerformed(player);
- action.canceled += ctx => TriggerCanceled(player);
+ action.started += ctx => TriggerStarted(player, ctx);
+ action.performed += ctx => TriggerPerformed(player, ctx);
+ action.canceled += ctx => TriggerCanceled(player, ctx);
action.Enable();
}
}
@@ -35,8 +35,8 @@ namespace Slimecing.Triggers
action.Disable();
}
}
- protected abstract void TriggerStarted(GameObject player);
- protected abstract void TriggerPerformed(GameObject player);
- protected abstract void TriggerCanceled(GameObject player);
+ protected abstract void TriggerStarted(GameObject player, InputAction.CallbackContext ctx);
+ protected abstract void TriggerPerformed(GameObject player, InputAction.CallbackContext ctx);
+ protected abstract void TriggerCanceled(GameObject player,InputAction.CallbackContext ctx);
}
}
diff --git a/Assets/Scripts/Slimecing/Triggers/TriggerLogic/HoldButtonInputTrigger.cs b/Assets/Scripts/Slimecing/Triggers/TriggerLogic/HoldButtonInputTrigger.cs
@@ -1,28 +1,27 @@
-using Slimecing.Abilities;
-using Slimecing.Characters;
-using UnityEngine;
+using UnityEngine;
+using UnityEngine.InputSystem;
namespace Slimecing.Triggers.TriggerLogic
{
[CreateAssetMenu(fileName = "HoldButtonInputTrigger", menuName = "Triggers/InputTriggers/HoldButtonInputTrigger")]
public class HoldButtonInputTrigger : TriggerInput
{
- protected override void TriggerStarted(GameObject player)
+ protected override void TriggerStarted(GameObject player, InputAction.CallbackContext ctx)
{
currentTriggerState = TriggerState.Started;
- OnTriggerStateChange(new TriggerPackage(TriggerState.Started, player));
+ OnTriggerStateChange(new TriggerPackage(TriggerState.Started, player, ctx));
}
- protected override void TriggerPerformed(GameObject player)
+ protected override void TriggerPerformed(GameObject player, InputAction.CallbackContext ctx)
{
currentTriggerState = TriggerState.Performed;
- OnTriggerStateChange(new TriggerPackage(TriggerState.Performed, player));
+ OnTriggerStateChange(new TriggerPackage(TriggerState.Performed, player, ctx));
}
- protected override void TriggerCanceled(GameObject player)
+ protected override void TriggerCanceled(GameObject player, InputAction.CallbackContext ctx)
{
currentTriggerState = TriggerState.Canceled;
- OnTriggerStateChange(new TriggerPackage(TriggerState.Canceled, player));
+ OnTriggerStateChange(new TriggerPackage(TriggerState.Canceled, player, ctx));
}
}
}
diff --git a/Assets/Scripts/Slimecing/Triggers/TriggerLogic/SimpleButtonInputTrigger.cs b/Assets/Scripts/Slimecing/Triggers/TriggerLogic/SimpleButtonInputTrigger.cs
@@ -1,24 +1,23 @@
-using Slimecing.Abilities;
-using Slimecing.Characters;
-using UnityEngine;
+using UnityEngine;
+using UnityEngine.InputSystem;
namespace Slimecing.Triggers.TriggerLogic
{
[CreateAssetMenu(fileName = "SimpleButtonInputTrigger", menuName = "Triggers/InputTriggers/SimpleButtonInputTrigger")]
public class SimpleButtonInputTrigger : TriggerInput
{
- protected override void TriggerStarted(GameObject player)
+ protected override void TriggerStarted(GameObject player, InputAction.CallbackContext ctx)
{
currentTriggerState = TriggerState.Performed;
- OnTriggerStateChange(new TriggerPackage(TriggerState.Performed, player));
+ OnTriggerStateChange(new TriggerPackage(TriggerState.Performed, player, ctx));
}
- protected override void TriggerPerformed(GameObject player) { }
+ protected override void TriggerPerformed(GameObject player, InputAction.CallbackContext ctx) { }
- protected override void TriggerCanceled(GameObject player)
+ protected override void TriggerCanceled(GameObject player, InputAction.CallbackContext ctx)
{
currentTriggerState = TriggerState.Canceled;
- OnTriggerStateChange(new TriggerPackage(TriggerState.Canceled, player));
+ OnTriggerStateChange(new TriggerPackage(TriggerState.Canceled, player, ctx));
}
}
}
diff --git a/Assets/Scripts/Slimecing/Triggers/TriggerPackage.cs b/Assets/Scripts/Slimecing/Triggers/TriggerPackage.cs
@@ -1,16 +1,27 @@
using UnityEngine;
+using UnityEngine.InputSystem;
namespace Slimecing.Triggers
{
public struct TriggerPackage
{
+
public TriggerState triggerState { get; set; }
public GameObject user { get; set; }
-
+ public InputAction.CallbackContext? ctx { get; set; }
+
public TriggerPackage(TriggerState triggerState, GameObject user)
{
this.triggerState = triggerState;
this.user = user;
+ this.ctx = null;
+ }
+ public TriggerPackage(TriggerState triggerState, GameObject user, InputAction.CallbackContext ctx)
+ {
+ this.triggerState = triggerState;
+ this.user = user;
+ this.ctx = ctx;
}
+
}
}