Krakensbane is working
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using Godot;
|
||||
using ImGuiNET;
|
||||
using Quadratic.Carto.MathExt;
|
||||
|
||||
namespace Quadratic.Carto.Craft;
|
||||
|
||||
@@ -14,23 +16,26 @@ namespace Quadratic.Carto.Craft;
|
||||
/// </remarks>
|
||||
public sealed partial class Krakensbane : Node3D
|
||||
{
|
||||
Node3D? focusedVessel = null;
|
||||
[Export]
|
||||
public Node3D? FocusedVessel { get; set; }
|
||||
|
||||
const float maxDistance = 500.0f;
|
||||
|
||||
DVector3 originPosition = DVector3.Zero;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Debug.Assert(
|
||||
focusedVessel == null || focusedVessel.GetParent() == this,
|
||||
FocusedVessel == null || FocusedVessel.GetParent() == this,
|
||||
"Focused vessel must be a direct descendant of Krakensbane"
|
||||
);
|
||||
|
||||
if (focusedVessel == null)
|
||||
if (FocusedVessel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var vesselPosition = focusedVessel.Transform.Origin;
|
||||
var vesselPosition = FocusedVessel.Transform.Origin;
|
||||
var vesselDistance = vesselPosition.Length();
|
||||
if (vesselDistance > maxDistance)
|
||||
{
|
||||
@@ -45,7 +50,14 @@ public sealed partial class Krakensbane : Node3D
|
||||
child.Transform = applyTransform * child.Transform;
|
||||
}
|
||||
|
||||
GD.Print($"Resetting position; delta = {-vesselPosition}");
|
||||
originPosition += vesselPosition.AsVim().AsDouble();
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
ImGui.Begin("Krakensbane");
|
||||
ImGui.Text($"Origin: {originPosition}");
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
|
||||
16
src/GlobalUsing.cs
Normal file
16
src/GlobalUsing.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// These are the types used in the engine-independent core of the codebase.
|
||||
// We add aliases for them to prevent namespace clash with Godot types.
|
||||
global using VVector4 = Vim.Math3d.Vector4;
|
||||
global using VVector3 = Vim.Math3d.Vector3;
|
||||
global using VVector2 = Vim.Math3d.Vector2;
|
||||
global using DVector4 = Vim.Math3d.DVector4;
|
||||
global using DVector3 = Vim.Math3d.DVector3;
|
||||
global using DVector2 = Vim.Math3d.DVector2;
|
||||
global using VQuaternion = Vim.Math3d.Quaternion;
|
||||
global using VMatrix4x4 = Vim.Math3d.Matrix4x4;
|
||||
// Also alias System.Numerics types to prevent namespace clash with Godot types.
|
||||
global using NVector4 = System.Numerics.Vector4;
|
||||
global using NVector3 = System.Numerics.Vector3;
|
||||
global using NVector2 = System.Numerics.Vector2;
|
||||
global using NQuaternion = System.Numerics.Quaternion;
|
||||
global using NMatrix4x4 = System.Numerics.Matrix4x4;
|
||||
Reference in New Issue
Block a user