Files
project-reset/Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs

86 lines
3.5 KiB
C#

using NodeCanvas.Framework;
using ParadoxNotion.Design;
using Reset.Core;
using Unity.Cinemachine;
using UnityEditor;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions {
[Category("Reset")]
[Description("Change Cinemachine camera settings for the player")]
public class ChangeCameraSettings : ActionTask{
[ParadoxNotion.Design.Header("Main Settings"), Space(8)]
public FloatValueGroup fieldOfView = new (newLabel: "FOV");
public Vector3ValueGroup orbitTargetOffset = new(newLabel: "Target Offset");
[Space(5)]public Vector3ValueGroup orbitPositionDamping = new(newLabel: "Position Damping");
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top Ring");
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Top Ring");
[Space(8)]
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Top Ring");
public BoolValueGroup enableXAxis = new (newLabel: "Input Axis X Enabled");
public BoolValueGroup enableYAxis = new (newLabel: "Input Axis Y Enabled");
public FloatValueGroup axisLookXGain = new (newLabel: "Look Orbit X Gain");
public FloatValueGroup axisLookYGain = new (newLabel: "Look Orbit Y Gain");
[ParadoxNotion.Design.Header("Rotation Composer Settings"), Space(8)]
public Vector2ValueGroup screenPosition = new (newLabel: "Screen Position");
[ParadoxNotion.Design.Header("Camera Offset Settings"), Space(8)]
public Vector3ValueGroup cameraOffset = new (newLabel: "Offset");
private CameraSettingsProcessor processor;
//Use for initialization. This is called only once in the lifetime of the task.
//Return null if init was successfull. Return an error string otherwise
protected override string OnInit(){
processor = CameraSettingsProcessor.Instance;
return null;
}
//This is called once each time the task is enabled.
//Call EndAction() to mark the action as finished, either in success or failure.
//EndAction can be called from anywhere.
protected override void OnExecute(){
OrbitalFollowValueGroup.UpdateValue(orbitFollowTop, processor.data.orbitFollowTopHeight, processor.data.orbitFollowTopRadius);
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, processor.data.orbitFollowCenterHeight, processor.data.orbitFollowCenterRadius);
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, processor.data.orbitFollowBottomHeight, processor.data.orbitFollowBottomRadius);
Vector3ValueGroup.UpdateValue(cameraOffset, processor.data.cameraOffsetOffset);
Vector3ValueGroup.UpdateValue(orbitPositionDamping, processor.data.orbitPositionDamping);
Vector3ValueGroup.UpdateValue(orbitTargetOffset, processor.data.orbitTargetOffset);
Vector2ValueGroup.UpdateValue(screenPosition, processor.data.rotationComposerScreenPos);
FloatValueGroup.UpdateValue(fieldOfView, processor.data.mainFieldOfView);
FloatValueGroup.UpdateValue(axisLookXGain, processor.data.axisLookGainX);
FloatValueGroup.UpdateValue(axisLookYGain, processor.data.axisLookGainY);
BoolValueGroup.UpdateValue(enableXAxis, processor.data.axisLookEnabledX);
BoolValueGroup.UpdateValue(enableYAxis, processor.data.axisLookEnabledY);
EndAction(true);
}
//Called once per frame while the action is active.
protected override void OnUpdate() {
}
//Called when the task is disabled.
protected override void OnStop() {
}
//Called when the task is paused.
protected override void OnPause() {
}
}
}