change: all movement separated into invidividual tasks, a lot of shuffling value groups and related stuff around
This commit is contained in:
@@ -2,13 +2,15 @@ using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Units;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Core {
|
||||
[Category("Reset")]
|
||||
[Description("Commits movement unit changes to the handler.")]
|
||||
public class ChangeMovementSettings : ActionTask<UnitMovementHandler> {
|
||||
// Move Speed
|
||||
|
||||
|
||||
[ParadoxNotion.Design.Header("Speed")]
|
||||
public FloatValueGroup moveSpeed = new (newLabel: "Move Speed");
|
||||
public FloatValueGroup moveSpeedSoothing = new (newLabel: "Move Speed Smoothing");
|
||||
@@ -19,15 +21,7 @@ namespace Reset.Core {
|
||||
public FloatValueGroup deaccelerationSmoothing = new (newLabel: "Deacceleration Smoothing");
|
||||
// public CurveValueGroup deaccelerationCurve = new (newLabel: "Deacceleration Curve"); // Currently unused, may return
|
||||
|
||||
// Direction
|
||||
[Space(5)]
|
||||
public Vector3ValueGroup feedNewDirection = new Vector3ValueGroup("Feed New Direction");
|
||||
public float newDirectionStrength;
|
||||
[Space(5)]
|
||||
public Vector2 addDirectionFromInput;
|
||||
public float addInputStrength;
|
||||
[SliderField(0,1)]
|
||||
public float addInputPriorty;
|
||||
|
||||
|
||||
// Jumping
|
||||
[ParadoxNotion.Design.Header("Jumping")]
|
||||
@@ -63,48 +57,41 @@ namespace Reset.Core {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
// Direction
|
||||
UpdateFloatValue(airDirectionDecay, ref agent.data.airDirectionDecay, ref agent.data.airDirectionDecay);
|
||||
UpdateFloatValue(accelerationSmoothing, ref agent.data.accelerationSmoothing, ref agent.defaultData.accelerationSmoothing);
|
||||
UpdateFloatValue(deaccelerationSmoothing, ref agent.data.deaccelerationSmoothing, ref agent.defaultData.deaccelerationSmoothing);
|
||||
// UpdateCurveProperty(deaccelerationCurve, ref agent.data.deaccelerationCurve, ref agent.defaultData.deaccelerationCurve); // Currently unused, may return
|
||||
|
||||
// Direction from value
|
||||
// Check that feedDir is not changed
|
||||
UpdateVector3Value(feedNewDirection, ref feedDir, ref feedDir);
|
||||
|
||||
// If there's a direciton add it to the player for a frame
|
||||
if (feedDir != Vector3.zero) {
|
||||
agent.AddToCurrentDirection(agent.transform.rotation * feedDir.normalized, newDirectionStrength);
|
||||
// Reset the fed direction after it's added so future runs don't have
|
||||
feedDir = Vector3.zero;
|
||||
}
|
||||
|
||||
// Direction from controller input
|
||||
if (addDirectionFromInput != Vector2.zero){
|
||||
agent.OverwriteDirectionFromInput(new Vector3(addDirectionFromInput.x, addDirectionFromInput.y), addInputPriorty, addInputStrength);
|
||||
}
|
||||
|
||||
// Move Speed
|
||||
UpdateFloatValue(moveSpeed, ref agent.data.moveSpeed, ref agent.defaultData.moveSpeed);
|
||||
UpdateFloatValue(moveSpeedSoothing, ref agent.data.moveSpeedSoothing, ref agent.defaultData.moveSpeedSoothing);
|
||||
|
||||
// Jump
|
||||
UpdateFloatValue(jumpPower, ref agent.data.jumpPower, ref agent.defaultData.jumpPower);
|
||||
UpdateFloatValue(jumpPowerDecay, ref agent.data.jumpPowerDecay, ref agent.defaultData.jumpPowerDecay);
|
||||
|
||||
// Gravity
|
||||
UpdateFloatValue(gravityPower, ref agent.data.gravityPower, ref agent.defaultData.gravityPower);
|
||||
UpdateFloatValue(gravityMax, ref agent.data.gravityMax, ref agent.defaultData.gravityMax);
|
||||
UpdateFloatValue(gravityAcceleration, ref agent.data.gravityAcceleration, ref agent.defaultData.gravityAcceleration);
|
||||
UpdateFloatValue(gravityScale, ref agent.data.gravityScale, ref agent.defaultData.gravityScale);
|
||||
UpdateFloatValue(settingsChangeSmoothing, ref agent.data.settingsChangeSmoothing, ref agent.defaultData.settingsChangeSmoothing);
|
||||
|
||||
// Rotation
|
||||
UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing);
|
||||
UpdateFloatValue(rotationSpeed, ref agent.data.rotationSpeed, ref agent.defaultData.rotationSpeed);
|
||||
UpdateFloatValue(rotationSmoothing, ref agent.data.rotationSmoothing, ref agent.defaultData.rotationSmoothing);
|
||||
UpdateFloatValue(rotationInputBlending, ref agent.data.rotationInputBlending, ref agent.defaultData.rotationInputBlending);
|
||||
// // Direction
|
||||
// FloatValueGroup.UpdateValue(airDirectionDecay, ref agent.data.airDirectionDecay, ref agent.defaultData.airDirectionDecay);
|
||||
// FloatValueGroup.ChangeSmoothingEasing(airDirectionDecay,
|
||||
// ref agent.smoothing.airDirectionDecay,
|
||||
// ref agent.easing.airDirectionDecay,
|
||||
// ref agent.defaultSmoothing.airDirectionDecay,
|
||||
// ref agent.defaultEasing.airDirectionDecay
|
||||
// );
|
||||
//
|
||||
// UpdateFloatValue(accelerationSmoothing, ref agent.data.accelerationSmoothing, ref agent.defaultData.accelerationSmoothing);
|
||||
// UpdateFloatValue(deaccelerationSmoothing, ref agent.data.deaccelerationSmoothing, ref agent.defaultData.deaccelerationSmoothing);
|
||||
// // UpdateCurveProperty(deaccelerationCurve, ref agent.data.deaccelerationCurve, ref agent.defaultData.deaccelerationCurve); // Currently unused, may return
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Move Speed
|
||||
// UpdateFloatValue(moveSpeed, ref agent.data.moveSpeed, ref agent.defaultData.moveSpeed);
|
||||
// UpdateFloatValue(moveSpeedSoothing, ref agent.data.moveSpeedSoothing, ref agent.defaultData.moveSpeedSoothing);
|
||||
//
|
||||
// // Jump
|
||||
// UpdateFloatValue(jumpPower, ref agent.data.jumpPower, ref agent.defaultData.jumpPower);
|
||||
// UpdateFloatValue(jumpPowerDecay, ref agent.data.jumpPowerDecay, ref agent.defaultData.jumpPowerDecay);
|
||||
//
|
||||
// // Gravity
|
||||
// UpdateFloatValue(gravityPower, ref agent.data.gravityPower, ref agent.defaultData.gravityPower);
|
||||
// UpdateFloatValue(gravityMax, ref agent.data.gravityMax, ref agent.defaultData.gravityMax);
|
||||
// UpdateFloatValue(gravityAcceleration, ref agent.data.gravityAcceleration, ref agent.defaultData.gravityAcceleration);
|
||||
// UpdateFloatValue(gravityScale, ref agent.data.gravityScale, ref agent.defaultData.gravityScale);
|
||||
// UpdateFloatValue(settingsChangeSmoothing, ref agent.data.settingsChangeSmoothing, ref agent.defaultData.settingsChangeSmoothing);
|
||||
//
|
||||
// // Rotation
|
||||
// UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing);
|
||||
// UpdateFloatValue(rotationSpeed, ref agent.data.rotationSpeed, ref agent.defaultData.rotationSpeed);
|
||||
// UpdateFloatValue(rotationSmoothing, ref agent.data.rotationSmoothing, ref agent.defaultData.rotationSmoothing);
|
||||
// UpdateFloatValue(rotationInputBlending, ref agent.data.rotationInputBlending, ref agent.defaultData.rotationInputBlending);
|
||||
|
||||
// Rotation from value
|
||||
if (feedNewRotation.value != Vector3.zero) {
|
||||
@@ -133,103 +120,5 @@ namespace Reset.Core {
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
|
||||
public void UpdateCurveProperty(CurveValueGroup valueGroup, ref AnimationCurve targetProperty, ref AnimationCurve defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NoChange:
|
||||
break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.newValue;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVector3Value(Vector3ValueGroup valueGroup, ref Vector3 targetProperty, ref Vector3 defaultProperty){
|
||||
switch (valueGroup.changeX) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.x = valueGroup.newValue.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.x = defaultProperty.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.y = valueGroup.newValue.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.y = defaultProperty.y;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeZ) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.z = valueGroup.newValue.z;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.z = defaultProperty.z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVector2Value(Vector2ValueGroup valueGroup, ref Vector2 targetProperty, ref Vector2 defaultProperty){
|
||||
switch (valueGroup.changeX) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.x = valueGroup.newValue.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.x = defaultProperty.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.y = valueGroup.newValue.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.y = defaultProperty.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateBoolValue(BoolValueGroup valueGroup, ref bool targetProperty, ref bool defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateEnumValue(EnumValueGroup valueGroup, ref Enum targetProperty, ref Enum defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.newValue;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFloatValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user