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

84 lines
4.2 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")]
public FloatValueGroup fieldOfView = new (newLabel: "FOV");
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
public Vector3ValueGroup orbitTargetOffset = new(newLabel: "Target Offset");
[Space(5)]public Vector3ValueGroup orbitPositionDamping = new(newLabel: "Position Damping");
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top");
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Center");
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Bottom");
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")]
public Vector2ValueGroup screenPosition = new (newLabel: "Screen Position");
[ParadoxNotion.Design.Header("Camera Offset Settings")]
public Vector3ValueGroup cameraOffset = new (newLabel: "Offset");
//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(){
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, ref CameraSettingsProcessor.data.orbitFollowTopHeight.value, ref CameraSettingsProcessor.original.orbitFollowTopRadius.value);
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, ref CameraSettingsProcessor.data.orbitFollowCenterHeight.value, ref CameraSettingsProcessor.original.orbitFollowCenterRadius.value);
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, ref CameraSettingsProcessor.data.orbitFollowBottomHeight.value, ref CameraSettingsProcessor.original.orbitFollowBottomRadius.value);
Vector3ValueGroup.UpdateValue(cameraOffset, ref CameraSettingsProcessor.data.cameraOffsetOffset.value, ref CameraSettingsProcessor.original.cameraOffsetOffset.value);
Vector3ValueGroup.UpdateValue(orbitPositionDamping, ref CameraSettingsProcessor.data.orbitPositionDamping.value, ref CameraSettingsProcessor.original.cameraOffsetOffset.value);
Vector3ValueGroup.UpdateValue(orbitTargetOffset, ref CameraSettingsProcessor.data.orbitTargetOffset.value, ref CameraSettingsProcessor.original.cameraOffsetOffset.value);
Vector2ValueGroup.UpdateValue(screenPosition, ref CameraSettingsProcessor.data.rotationComposerScreenPos.value, ref CameraSettingsProcessor.original.rotationComposerScreenPos.value);
FloatValueGroup.UpdateValue(fieldOfView, ref CameraSettingsProcessor.data.mainFieldOfView.value, ref CameraSettingsProcessor.original.mainFieldOfView.value);
FloatValueGroup.UpdateValue(axisLookXGain, ref CameraSettingsProcessor.data.axisLookGainX.value, ref CameraSettingsProcessor.original.axisLookGainX.value);
FloatValueGroup.UpdateValue(axisLookYGain, ref CameraSettingsProcessor.data.axisLookGainY.value, ref CameraSettingsProcessor.original.axisLookGainY.value);
BoolValueGroup.UpdateValue(enableXAxis, ref CameraSettingsProcessor.data.axisLookEnabledX.value, ref CameraSettingsProcessor.original.axisLookEnabledX.value);
BoolValueGroup.UpdateValue(enableYAxis, ref CameraSettingsProcessor.data.axisLookEnabledY.value, ref CameraSettingsProcessor.original.axisLookEnabledY.value);
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() {
}
}
}