changed: rebuilt player input management

This commit is contained in:
Chris
2025-08-01 16:50:05 -04:00
parent 6ebfd4ef2b
commit f2df9a6910
7 changed files with 106 additions and 41 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
@@ -6,11 +7,15 @@ using UnityEngine.UIElements;
using NodeCanvas;
using NodeCanvas.Framework;
using ParadoxNotion;
using Sirenix.OdinInspector;
public class PlayerControls : MonoBehaviour{
// References
private Player thisPlayer;
private PlayerInput input;
public SignalDefinition inputSignal;
// TODO: Turn these into accessors
public Vector2 rawMoveInput;
public Vector2 rawLookInput;
@@ -20,6 +25,31 @@ public class PlayerControls : MonoBehaviour{
void Awake(){
thisPlayer = GetComponent<Player>();
graph = GetComponent<GraphOwner>();
input = GetComponent<PlayerInput>();
// Add the delegates for each method
foreach (InputAction action in input.actions) {
action.started += SendToGraph;
action.canceled += SendToGraph;
action.performed += SendToGraph;
}
}
// Remove the delegates for each method
void OnDisable(){
foreach (InputAction action in input.actions) {
action.started -= SendToGraph;
action.canceled -= SendToGraph;
action.performed -= SendToGraph;
}
}
// This will call the OnSignalInvoke for this type of Signal Defintion. CheckInput is the recieving end.
public void SendToGraph(InputAction.CallbackContext ctx){
inputSignal.Invoke(transform, transform, false, new object[]{
ctx.action,
ctx.phase
});
}
public void OnMove(InputValue value){