change: all movement separated into invidividual tasks, a lot of shuffling value groups and related stuff around

This commit is contained in:
Chris
2025-09-16 17:07:20 -04:00
parent 7a0499f36a
commit aad8b78c22
17 changed files with 1507 additions and 1036 deletions

View File

@@ -1,496 +1,311 @@
using System;
#if UNITY_EDITOR
using NodeCanvas.Editor;
#endif
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEditor;
using UnityEngine;
namespace Reset.Core{
// Individual bool setting for each ring. Three of these will be used.
public struct OrbitalFollowValueGroup{
public string label;
public ValueChangeAction changeHeight;
public float height;
public ValueChangeAction changeRadius;
public float radius;
public abstract class ValueGroup{
public interface ISmoothable{
public BBParameter<ValueChangeAction> changeEasing{ get; set; }
public BBParameter<ValueChangeAction> changeSmoothing{ get; set; }
public OrbitalFollowValueGroup(string newLabel){
label = newLabel;
changeHeight = ValueChangeAction.NoChange;
height = 0f;
changeRadius = ValueChangeAction.NoChange;
radius = 0f;
public BBParameter<float> smoothing { get; set; }
public BBParameter<float> easing{ get; set; }
}
public static void ChangeSmoothingEasing(ISmoothable valueGroup, ref float targetSmoothing,
ref float targetEasing, ref float defaultSmoothing, ref float defaultEasing){
switch (valueGroup.changeSmoothing.value) {
case ValueChangeAction.NewValue:
targetSmoothing = valueGroup.smoothing.value;
break;
case ValueChangeAction.ResetValue:
targetSmoothing = defaultSmoothing;
break;
}
switch (valueGroup.changeEasing.value) {
case ValueChangeAction.NewValue:
targetEasing = valueGroup.easing.value;
break;
case ValueChangeAction.ResetValue:
targetEasing = defaultEasing;
break;
}
}
}
// Enum options for individual camera settings
// Enum options for individual settings
public enum ValueChangeAction{
NoChange,
NewValue,
ResetValue,
RelativeValue, // Placeholder for using as altering existing value
}
public struct CurveValueGroup{
// Individual bool setting for each ring. Three of these will be used.
public struct OrbitalFollowValueGroup : ValueGroup.ISmoothable{
public string label;
public AnimationCurve newValue;
public ValueChangeAction changeValue;
public BBParameter<ValueChangeAction> changeHeight;
public BBParameter<float> height;
public BBParameter<ValueChangeAction> changeRadius;
public BBParameter<float> radius;
public BBParameter<ValueChangeAction> changeEasing{ get; set; }
public BBParameter<ValueChangeAction> changeSmoothing{ get; set; }
public BBParameter<float> smoothing{ get; set; }
public BBParameter<float> easing{ get; set; }
public OrbitalFollowValueGroup(string newLabel){
label = newLabel;
changeHeight = ValueChangeAction.NoChange;
height = 0f;
changeRadius = ValueChangeAction.NoChange;
radius = 0f;
changeSmoothing = ValueChangeAction.NoChange;
smoothing = .1f;
changeEasing = ValueChangeAction.NoChange;
easing = 1f;
}
public static void UpdateValue(OrbitalFollowValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
switch (valueGroup.changeHeight.value) {
case ValueChangeAction.NewValue:
targetProperty = valueGroup.height.value;
break;
case ValueChangeAction.ResetValue:
targetProperty = defaultProperty;
break;
}
switch (valueGroup.changeRadius.value) {
case ValueChangeAction.NewValue:
targetProperty = valueGroup.radius.value;
break;
case ValueChangeAction.ResetValue:
targetProperty = defaultProperty;
break;
}
}
}
public struct CurveValueGroup{ // Done
public string label;
public BBParameter<AnimationCurve> value;
public BBParameter<ValueChangeAction> changeValue;
public CurveValueGroup(string newLabel){
changeValue = ValueChangeAction.NoChange;
newValue = new AnimationCurve();
value = new AnimationCurve();
label = newLabel;
}
public static void UpdateValue(CurveValueGroup valueGroup, ref AnimationCurve targetProperty, ref AnimationCurve defaultProperty){
switch (valueGroup.changeValue.value) {
case ValueChangeAction.NewValue:
targetProperty = valueGroup.value.value;
break;
case ValueChangeAction.ResetValue:
targetProperty = defaultProperty;
break;
}
}
}
public struct EnumValueGroup{
public struct EnumValueGroup{ // Done
public string label;
public Enum newValue;
public BBParameter<Enum> value;
public ValueChangeAction changeValue;
public BBParameter<ValueChangeAction> changeValue;
public EnumValueGroup(string newLabel, Enum enumType){
changeValue = ValueChangeAction.NoChange;
newValue = enumType;
value = enumType;
label = newLabel;
}
public static void UpdateValue(EnumValueGroup valueGroup, ref Enum targetProperty, ref Enum defaultProperty){
switch (valueGroup.changeValue.value) {
case ValueChangeAction.NewValue:
targetProperty = valueGroup.value.value;
break;
case ValueChangeAction.ResetValue:
targetProperty = defaultProperty;
break;
}
}
}
public struct Vector3ValueGroup{
public struct Vector3ValueGroup{ // Done
public string label;
public Vector3 newValue;
public ValueChangeAction changeX;
public ValueChangeAction changeY;
public ValueChangeAction changeZ;
public BBParameter<Vector3> value;
public BBParameter<ValueChangeAction> changeX;
public BBParameter<ValueChangeAction> changeY;
public BBParameter<ValueChangeAction> changeZ;
public Vector3ValueGroup(string newLabel){
changeX = ValueChangeAction.NoChange;
changeY = ValueChangeAction.NoChange;
changeZ = ValueChangeAction.NoChange;
newValue = Vector3.zero;
value = new BBParameter<Vector3>{
value = Vector3.zero
};
label = newLabel;
}
public static void UpdateValue(Vector3ValueGroup valueGroup, ref Vector3 targetProperty, ref Vector3 defaultProperty){
switch (valueGroup.changeX.value) {
case ValueChangeAction.NewValue:
targetProperty.x = valueGroup.value.value.x;
break;
case ValueChangeAction.ResetValue:
targetProperty.x = defaultProperty.x;
break;
}
switch (valueGroup.changeY.value) {
case ValueChangeAction.NewValue:
targetProperty.y = valueGroup.value.value.y;
break;
case ValueChangeAction.ResetValue:
targetProperty.y = defaultProperty.y;
break;
}
switch (valueGroup.changeZ.value) {
case ValueChangeAction.NewValue:
targetProperty.z = valueGroup.value.value.z;
break;
case ValueChangeAction.ResetValue:
targetProperty.z = defaultProperty.z;
break;
}
}
}
public struct Vector2ValueGroup{
public struct Vector2ValueGroup : ValueGroup.ISmoothable{ // Done
public string label;
public Vector2 newValue;
public BBParameter<Vector2> value;
public ValueChangeAction changeX;
public ValueChangeAction changeY;
public BBParameter<ValueChangeAction> changeEasing{ get; set; }
public BBParameter<ValueChangeAction> changeSmoothing{ get; set; }
public BBParameter<float> smoothing{ get; set; }
public BBParameter<float> easing{ get; set; }
public BBParameter<ValueChangeAction> changeX;
public BBParameter<ValueChangeAction> changeY;
public Vector2ValueGroup(string newLabel){
changeX = ValueChangeAction.NoChange;
changeY = ValueChangeAction.NoChange;
newValue = Vector2.zero;
value = new BBParameter<Vector2>{
value = Vector2.zero
};
label = newLabel;
changeEasing = ValueChangeAction.NoChange;
changeSmoothing = ValueChangeAction.NoChange;
smoothing = 0;
easing = 0;
}
public static void UpdateValue(Vector2ValueGroup valueGroup, ref Vector2 targetProperty, ref Vector2 defaultProperty){
switch (valueGroup.changeX.value) {
case ValueChangeAction.NewValue:
targetProperty.x = valueGroup.value.value.x;
break;
case ValueChangeAction.ResetValue:
targetProperty.x = defaultProperty.x;
break;
}
switch (valueGroup.changeY.value) {
case ValueChangeAction.NewValue:
targetProperty.y = valueGroup.value.value.y;
break;
case ValueChangeAction.ResetValue:
targetProperty.y = defaultProperty.y;
break;
}
}
}
public struct FloatValueGroup{
public string label;
// public float value;
public BBParameter<float> value;
public ValueChangeAction changeValue;
public class FloatValueGroup : ValueGroup.ISmoothable{ // Done
public string label;
public BBParameter<ValueChangeAction> changeValue;
public BBParameter<float> value;
public BBParameter<ValueChangeAction> changeEasing{ get; set; }
public BBParameter<ValueChangeAction> changeSmoothing{ get; set; }
public BBParameter<float> smoothing { get; set; }
public BBParameter<float> easing{ get; set; }
public FloatValueGroup(string newLabel){
label = newLabel;
value = new BBParameter<float>().value = 0f;
changeValue = ValueChangeAction.NoChange;
changeSmoothing = ValueChangeAction.NoChange;
smoothing = 0f;
changeEasing = ValueChangeAction.NoChange;
easing = 0f;
}
public static void UpdateValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
switch (valueGroup.changeValue.value) {
case ValueChangeAction.NewValue:
targetProperty = valueGroup.value.value;
break;
case ValueChangeAction.ResetValue:
targetProperty = defaultProperty;
break;
}
}
}
public struct BoolValueGroup{
public string label;
public bool value;
public BBParameter<bool> value;
public ValueChangeAction changeValue;
public BBParameter<ValueChangeAction> changeValue;
public BoolValueGroup(string newLabel){
label = newLabel;
value = true;
changeValue = ValueChangeAction.NoChange;
}
}
#if UNITY_EDITOR
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
// Remove label for floats
EditorGUIUtility.labelWidth = 50;
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(80.0f),
GUILayout.MinWidth(20.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(200.0f),
};
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
GUILayout.BeginVertical();
GUILayout.Label(_instance.label, labelOptions);
GUILayout.BeginHorizontal();
// Create the x settings enum
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue);
// Create the value/disabled information field
if (_instance.changeValue == ValueChangeAction.NewValue){
_instance.value = EditorGUILayout.Toggle(_instance.value, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// Close this line up
GUILayout.EndHorizontal();
GUILayout.EndVertical();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
public class CurveVlueGroupDrawer : ObjectDrawer<CurveValueGroup> {
public override CurveValueGroup OnGUI(GUIContent _content, CurveValueGroup _instance){
// Remove label for floats
EditorGUIUtility.labelWidth = 50;
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(80.0f),
GUILayout.MinWidth(20.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(200.0f),
};
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
GUILayout.BeginVertical();
GUILayout.Label(_instance.label, labelOptions);
GUILayout.BeginHorizontal();
// Create the x settings enum
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue);
// Create the value/disabled information field
if (_instance.changeValue == ValueChangeAction.NewValue){
_instance.newValue = EditorGUILayout.CurveField(_instance.newValue, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// Close this line up
GUILayout.EndHorizontal();
GUILayout.EndVertical();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
public class EnumValueGroupDrawer : ObjectDrawer<EnumValueGroup>{
public override EnumValueGroup OnGUI(GUIContent _content, EnumValueGroup _instance){
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(200.0f),
GUILayout.MinWidth(100.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(200.0f),
};
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
GUILayout.BeginVertical();
GUILayout.Label(_instance.label, labelOptions);
GUILayout.BeginHorizontal();
// Create the x settings enum
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue);
// Create the value/disabled information field
if (_instance.changeValue == ValueChangeAction.NewValue){
_instance.newValue = EditorGUILayout.EnumPopup("", instance.newValue, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// Close this line up
GUILayout.EndHorizontal();
GUILayout.EndVertical();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
public class FloatValueGroupDrawer : ObjectDrawer<FloatValueGroup> {
public override FloatValueGroup OnGUI(GUIContent _content, FloatValueGroup _instance){
// Remove label for floats
EditorGUIUtility.labelWidth = 50;
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(80.0f),
GUILayout.MinWidth(20.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(200.0f),
};
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
GUILayout.BeginVertical();
GUILayout.Label(_instance.label, labelOptions);
GUILayout.BeginHorizontal();
// Create the x settings enum
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue);
// Create the value/disabled information field
if (_instance.changeValue == ValueChangeAction.NewValue){
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
BBParameterEditor.ParameterField("", _instance.value);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
public static void UpdateValue(BoolValueGroup valueGroup, ref bool targetProperty, ref bool defaultProperty){
switch (valueGroup.changeValue.value) {
case ValueChangeAction.NewValue:
targetProperty = valueGroup.value.value;
break;
case ValueChangeAction.ResetValue:
targetProperty = defaultProperty;
break;
}
// Close this line up
GUILayout.EndHorizontal();
GUILayout.EndVertical();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
public class Vector3ValueGroupDrawer : ObjectDrawer<Vector3ValueGroup> {
public override Vector3ValueGroup OnGUI(GUIContent _content, Vector3ValueGroup _instance){
// Remove label for floats
EditorGUIUtility.labelWidth = 20;
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(300.0f),
GUILayout.MinWidth(20.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(200.0f),
};
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
GUILayout.BeginVertical();
GUILayout.Label(_instance.label, labelOptions);
GUILayout.BeginHorizontal();
// Create the x settings enum
_instance.changeX = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX);
// Create the value/disabled information field
if (_instance.changeX == ValueChangeAction.NewValue){
_instance.newValue.x = EditorGUILayout.FloatField(_instance.newValue.x, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeX == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// It do what it do.
GUILayout.Space(5);
// Create the y settings enum
_instance.changeY = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY);
// Create the value/disabled information field
if (_instance.changeY == ValueChangeAction.NewValue){
_instance.newValue.y = EditorGUILayout.FloatField(_instance.newValue.y, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeY == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// It do what it do.
GUILayout.Space(5);
// Create the y settings enum
_instance.changeZ = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeZ);
// Create the value/disabled information field
if (_instance.changeZ == ValueChangeAction.NewValue){
_instance.newValue.z = EditorGUILayout.FloatField(_instance.newValue.z, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeZ == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// Close this line up
GUILayout.EndHorizontal();
GUILayout.EndVertical();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
public class Vector2ValueGroupDrawer : ObjectDrawer<Vector2ValueGroup> {
public override Vector2ValueGroup OnGUI(GUIContent _content, Vector2ValueGroup _instance){
// Remove label for floats
EditorGUIUtility.labelWidth = 50;
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(300.0f),
GUILayout.MinWidth(20.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(200.0f),
};
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
GUILayout.BeginVertical();
GUILayout.Label(_instance.label, labelOptions);
GUILayout.BeginHorizontal();
// Create the x settings enum
_instance.changeX = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX);
// Create the value/disabled information field
if (_instance.changeX == ValueChangeAction.NewValue){
_instance.newValue.x = EditorGUILayout.FloatField(_instance.newValue.x, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeX == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// It do what it do.
GUILayout.Space(5);
// Create the y settings enum
_instance.changeY = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY);
// Create the value/disabled information field
if (_instance.changeY == ValueChangeAction.NewValue){
_instance.newValue.y = EditorGUILayout.FloatField(_instance.newValue.y, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeY == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// Close this line up
GUILayout.EndHorizontal();
GUILayout.EndVertical();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
// Custom editor for each orbital follow ring setting
public class OrbitalFollowValueGroupDrawer : ObjectDrawer<OrbitalFollowValueGroup>{
public override OrbitalFollowValueGroup OnGUI(GUIContent _content, OrbitalFollowValueGroup _instance){
// Remove label for floats
EditorGUIUtility.labelWidth = 1;
// Set layout options for the label and the float fields
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
GUILayout.Width(300.0f),
GUILayout.MinWidth(20.0f),
GUILayout.ExpandWidth(true),
};
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
GUILayout.Width(60.0f),
};
// Start a Horiztonal Section
GUILayout.BeginHorizontal();
// Add the left side label
GUILayout.Label(_instance.label, labelOptions);
// Create the height settings enum
_instance.changeHeight = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeHeight);
// Create the value/disabled information field
if (_instance.changeHeight == ValueChangeAction.NewValue){
_instance.height = EditorGUILayout.FloatField(_instance.height, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeHeight == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// It do what it do.
GUILayout.Space(5);
// Create the radius settings enum
_instance.changeRadius = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeRadius);
// Create the value/disabled information field
if (_instance.changeRadius == ValueChangeAction.NewValue){
_instance.radius = EditorGUILayout.FloatField(_instance.radius, floatOptions);
} else {
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.TextField(_instance.changeRadius == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
EditorGUI.EndDisabledGroup();
}
// Close this line up
GUILayout.EndHorizontal();
// Reset to default so the rest of things don't get messed up
EditorGUIUtility.labelWidth = 0;
return _instance;
}
}
#endif
}