added: task to check and save input values
This commit is contained in:
42
Assets/Scripts/Core/Graph Tasks/CheckInputValue.cs
Normal file
42
Assets/Scripts/Core/Graph Tasks/CheckInputValue.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions {
|
||||
[Category("Reset/Input")]
|
||||
[Description("Check if input condition was matched this frame by phase.")]
|
||||
public class CheckInputValue<T> : ActionTask<PlayerInput> where T : struct{
|
||||
public BBParameter<string> actionName;
|
||||
public BBParameter<T> outputTo;
|
||||
|
||||
private T value;
|
||||
|
||||
private SignalDefinition signalDefinition;
|
||||
protected override string info {
|
||||
get { return $"Get Value of <b>Input:</b> \"{actionName.value}\""; }
|
||||
}
|
||||
|
||||
protected override string OnInit(){
|
||||
try {
|
||||
signalDefinition = Resources.Load<SignalDefinition>("InputSignal");
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Error finding the Input Signal defintion: {e.Message}");
|
||||
throw;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnExecute(){
|
||||
Debug.Log($"{outputTo.value}, {agent.actions[actionName.value].ReadValue<T>()}");
|
||||
|
||||
outputTo.value = agent.actions[actionName.value].ReadValue<T>();
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user