3 Commits

3 changed files with 487 additions and 1706 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -97,7 +97,7 @@ namespace NodeCanvas.Tasks.Actions {
Vector3 input = new(rawInput.x, rawInput.y, 0f); Vector3 input = new(rawInput.x, rawInput.y, 0f);
smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 1f); smoothedInput = Vector3.SmoothDamp(smoothedInput, input, ref smoothedInputRefVelocity, 1f);
DebugOverlayDrawer.ChangeValue("Grapple", "Smoothed Input", smoothedInput.ToString()); DebugOverlayDrawer.ChangeValue("Grapple", "Smoothed Input", smoothedInput);
// The swing angle needs to change for the downwards swing, based on distance to the ground // The swing angle needs to change for the downwards swing, based on distance to the ground
Physics.Raycast(agent.transform.position, Vector3.down, out RaycastHit hit); Physics.Raycast(agent.transform.position, Vector3.down, out RaycastHit hit);
@@ -110,7 +110,7 @@ namespace NodeCanvas.Tasks.Actions {
float outwardsAngle = Mathf.Lerp(0f, -60f, currentDist / 15f); float outwardsAngle = Mathf.Lerp(0f, -60f, currentDist / 15f);
float outputAngle = inwardsAngle + outwardsAngle; float outputAngle = inwardsAngle + outwardsAngle;
DebugOverlayDrawer.ChangeValue("Grapple", "Output Angle", outputAngle.ToString() + $"({inwardsAngle.ToString()} + {outwardsAngle.ToString()})"); DebugOverlayDrawer.ChangeValue("Grapple", "Output Angle", outputAngle + $"({inwardsAngle} + {outwardsAngle})");
// Calculate the swing direction. // Calculate the swing direction.
// Vector3 swingDirection = Quaternion.LookRotation(smoothedInput) * directionToPoint * smoothedInput.magnitude; // Old // Vector3 swingDirection = Quaternion.LookRotation(smoothedInput) * directionToPoint * smoothedInput.magnitude; // Old
@@ -190,8 +190,8 @@ namespace NodeCanvas.Tasks.Actions {
Quaternion.LookRotation(directionToPoint) * -directionToPoint.Flatten(null, null, 0).normalized Quaternion.LookRotation(directionToPoint) * -directionToPoint.Flatten(null, null, 0).normalized
); );
DebugOverlayDrawer.ChangeValue("Grapple", "Horizontal Dot", xzDot.ToString()); DebugOverlayDrawer.ChangeValue("Grapple", "Horizontal Dot", xzDot);
DebugOverlayDrawer.ChangeValue("Grapple", "Vertical Dot", yDot.ToString()); DebugOverlayDrawer.ChangeValue("Grapple", "Vertical Dot", yDot);
// Check if done // Check if done
if (xzDot < horizontalDotBreak || yDot < verticalDotBreak) { if (xzDot < horizontalDotBreak || yDot < verticalDotBreak) {
@@ -219,7 +219,7 @@ namespace NodeCanvas.Tasks.Actions {
float outwardsAngle = Mathf.Lerp(0f, -60f, currentDist / 15f); float outwardsAngle = Mathf.Lerp(0f, -60f, currentDist / 15f);
float outputAngle = inwardsAngle + outwardsAngle; float outputAngle = inwardsAngle + outwardsAngle;
DebugOverlayDrawer.ChangeValue("Grapple", "Output Angle", outputAngle.ToString() + $"({inwardsAngle.ToString()} + {outwardsAngle.ToString()})"); DebugOverlayDrawer.ChangeValue("Grapple", "Output Angle", outputAngle + $"({inwardsAngle} + {outwardsAngle})");
Vector3 pointDirectionXZStable = agent.transform.position.DirectionTo(grapplePoint.value.Flatten(null, agent.transform.position.y)); Vector3 pointDirectionXZStable = agent.transform.position.DirectionTo(grapplePoint.value.Flatten(null, agent.transform.position.y));
Vector3 rightSwingDirectin = Quaternion.AngleAxis(100f + outputAngle, Vector3.up) * pointDirectionXZStable; // Working Vector3 rightSwingDirectin = Quaternion.AngleAxis(100f + outputAngle, Vector3.up) * pointDirectionXZStable; // Working
@@ -253,7 +253,7 @@ namespace NodeCanvas.Tasks.Actions {
Vector3 xAxisTargetDirection = Vector3.Lerp(rightSwingDirectin, leftSwingDirectin, Mathf.Abs((input.x - 1f) / 2f)); Vector3 xAxisTargetDirection = Vector3.Lerp(rightSwingDirectin, leftSwingDirectin, Mathf.Abs((input.x - 1f) / 2f));
targetSwingDirection = Vector3.Slerp(targetSwingDirection, xAxisTargetDirection, Mathf.Abs((input.x))); targetSwingDirection = Vector3.Slerp(targetSwingDirection, xAxisTargetDirection, Mathf.Abs((input.x)));
// targetSwingDirection = xAxisTargetDirection; // targetSwingDirection = xAxisTargetDirection;
DebugOverlayDrawer.ChangeValue("Grapple", "LR Input Dot", Mathf.Abs((input.x - 1f) / 2f).ToString()); DebugOverlayDrawer.ChangeValue("Grapple", "LR Input Dot", Mathf.Abs((input.x - 1f) / 2f));
} }
return targetSwingDirection.normalized; return targetSwingDirection.normalized;

View File

@@ -73,7 +73,7 @@ namespace Reset.Core.Tools{
GameObject thisPageObject = null; GameObject thisPageObject = null;
bool alreadyExisted = false; bool alreadyExisted = false;
// This checks for a gameobject with the page name. Sets it if it finds it // This checks for a page with the gameobject's name. Sets it if it finds it
foreach (var page in Instance.Pages) { foreach (var page in Instance.Pages) {
if (page.Key.name == $"{Instance.pageNamePrefix}{pageName}") { if (page.Key.name == $"{Instance.pageNamePrefix}{pageName}") {
thisPageObject = page.Key; thisPageObject = page.Key;
@@ -82,7 +82,7 @@ namespace Reset.Core.Tools{
} }
} }
// Otherwise, this will make a new one and add it // Otherwise, this will make a new GameObject/page and add it
UIDocument thisDocument; UIDocument thisDocument;
if (thisPageObject == null) { if (thisPageObject == null) {
@@ -92,7 +92,7 @@ namespace Reset.Core.Tools{
// Add it to the list of page objects and set it's transform // Add it to the list of page objects and set it's transform
KeyValuePair<GameObject, List<string>> newPage = new(thisPageObject, new List<string>()); KeyValuePair<GameObject, List<string>> newPage = new(thisPageObject, new List<string>());
Instance.Pages.Add(newPage.Key, newPage.Value); Instance.Pages.Add(newPage.Key, newPage.Value);
thisPageObject.transform.SetParent(Instance.canvasRootGameObject.transform); thisPageObject.transform.SetParent(Instance.root.transform);
// Add a UI Document for it, give it the base template // Add a UI Document for it, give it the base template
thisDocument = thisPageObject.AddComponent<UIDocument>(); thisDocument = thisPageObject.AddComponent<UIDocument>();
@@ -138,18 +138,16 @@ namespace Reset.Core.Tools{
} }
// Publicly accessible method to change the value // Publicly accessible method to change the value
public static void ChangeValue(string pageName, string sourceName, string newValue){ public static void ChangeValue(string pageName, string sourceName, object newValue){
try { try {
Instance.values[$"{pageName}/{sourceName}"].text = newValue; if (Instance.values.ContainsKey($"{pageName}/{sourceName}")) {
} catch (Exception e) { Instance.values[$"{pageName}/{sourceName}"].text = newValue.ToString();
try { } else {
AddOnOverlay(pageName, sourceName); AddOnOverlay(pageName, sourceName);
Instance.values[$"{pageName}/{sourceName}"].text = newValue; Instance.values[$"{pageName}/{sourceName}"].text = newValue.ToString();
throw;
} catch (Exception exception) {
Debug.LogError($"Failed to both update an existing or create a new debug overlay: {exception.Message}" );
throw;
} }
} catch (Exception e) {
Debug.LogError($"Failed to both update an existing or create a new debug overlay: {e.Message}");
} }
} }