added: item pickups with online persistency
This commit is contained in:
@@ -10,13 +10,15 @@ using ParadoxNotion;
|
||||
using Reset;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Cinemachine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public class PlayerControls : MonoBehaviour{
|
||||
// References
|
||||
private Player thisPlayer;
|
||||
|
||||
private PlayerInput input;
|
||||
public SignalDefinition inputSignal;
|
||||
private SignalDefinition inputSignal;
|
||||
private SignalDefinition blockSignal;
|
||||
|
||||
// TODO: Turn these into accessors
|
||||
public Vector2 rawMoveInput;
|
||||
@@ -25,6 +27,21 @@ public class PlayerControls : MonoBehaviour{
|
||||
public GraphOwner graph;
|
||||
|
||||
void Awake(){
|
||||
|
||||
try {
|
||||
inputSignal = Resources.Load<SignalDefinition>("InputSignal");
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Error finding the Input Signal defintion: {e.Message}");
|
||||
throw;
|
||||
}
|
||||
|
||||
try {
|
||||
blockSignal = Resources.Load<SignalDefinition>("BlockInputSignal");
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Error finding the Input Signal defintion: {e.Message}");
|
||||
throw;
|
||||
}
|
||||
|
||||
thisPlayer = GetComponent<Player>();
|
||||
graph = GetComponent<GraphOwner>();
|
||||
input = GetComponent<PlayerInput>();
|
||||
@@ -34,29 +51,34 @@ public class PlayerControls : MonoBehaviour{
|
||||
|
||||
// Add the delegates for each method
|
||||
foreach (InputAction action in input.actions) {
|
||||
action.started += SendToGraph;
|
||||
action.canceled += SendToGraph;
|
||||
action.performed += SendToGraph;
|
||||
action.started += SendInputSignal;
|
||||
action.canceled += SendInputSignal;
|
||||
action.performed += SendInputSignal;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the delegates for each method
|
||||
void OnDisable(){
|
||||
foreach (InputAction action in input.actions) {
|
||||
action.started -= SendToGraph;
|
||||
action.canceled -= SendToGraph;
|
||||
action.performed -= SendToGraph;
|
||||
action.started -= SendInputSignal;
|
||||
action.canceled -= SendInputSignal;
|
||||
action.performed -= SendInputSignal;
|
||||
}
|
||||
}
|
||||
|
||||
// This will call the OnSignalInvoke for this type of Signal Defintion. CheckInput is the recieving end.
|
||||
public void SendToGraph(InputAction.CallbackContext ctx){
|
||||
// This will call the SignalInvoke for this type of Signal Defintion. CheckInput is the recieving end.
|
||||
public void SendInputSignal(InputAction.CallbackContext ctx){
|
||||
inputSignal.Invoke(transform, transform, false, new object[]{
|
||||
ctx.action,
|
||||
ctx.phase
|
||||
});
|
||||
}
|
||||
|
||||
public void SendInputBlock(string actionName){
|
||||
Debug.Log($"Sending block request...");
|
||||
blockSignal.Invoke(transform, transform, false, new object[]{actionName});
|
||||
}
|
||||
|
||||
public void OnMove(InputValue value){
|
||||
rawMoveInput.x = value.Get<Vector2>().x;
|
||||
rawMoveInput.y = value.Get<Vector2>().y;
|
||||
|
||||
Reference in New Issue
Block a user