Object parenting; Ship module prototype; Use 64 bit

This commit is contained in:
Aslan 2026-01-24 23:05:19 -05:00
parent 3f97e18615
commit 8335714acc
30 changed files with 436 additions and 62 deletions

View file

@ -10,7 +10,7 @@ public partial class Player : CharacterBody3D
private Vector3 gravityVelocity = Vector3.Zero;
private Vector3 movementVelocity = Vector3.Zero;
private float cameraPitch = 0f;
private double cameraPitch = 0f;
private Camera3D camera;
private GravityReceiver gravityReceiver;
@ -60,10 +60,10 @@ public partial class Player : CharacterBody3D
if (@event is InputEventMouseMotion motion)
{
float yawDelta = -motion.Relative.X * MouseSensitivity;
float yawDeltaRad = Mathf.DegToRad(yawDelta);
float pitchDelta = -motion.Relative.Y * MouseSensitivity;
float pitchDeltaRad = Mathf.DegToRad(pitchDelta);
double yawDelta = -motion.Relative.X * MouseSensitivity;
double yawDeltaRad = Mathf.DegToRad(yawDelta);
double pitchDelta = -motion.Relative.Y * MouseSensitivity;
double pitchDeltaRad = Mathf.DegToRad(pitchDelta);
RotateObjectLocal(Vector3.Up, yawDeltaRad);
@ -82,7 +82,7 @@ public partial class Player : CharacterBody3D
public bool IsInGravity()
{
return gravityReceiver.InGravityZone && gravityReceiver.GravityStrength > 0f;
return gravityReceiver.InGravityZone && gravityReceiver.GetGravityStrength() > 0f;
}
public bool IsOnGravityFloor()
@ -92,7 +92,7 @@ public partial class Player : CharacterBody3D
KinematicCollision3D collision = GetSlideCollision(i);
Vector3 collisionNormal = collision.GetNormal();
float alignment = collisionNormal.Dot(gravityReceiver.GravityDirection);
double alignment = collisionNormal.Dot(gravityReceiver.GetGravityDirection());
if (alignment > 0.7f)
{
@ -107,35 +107,35 @@ public partial class Player : CharacterBody3D
{
if (!IsOnGravityFloor())
{
newGravityVelocity -= gravityReceiver.GravityDirection * gravityReceiver.GravityStrength * (float)delta;
newGravityVelocity -= gravityReceiver.GetGravityDirection() * gravityReceiver.GetGravityStrength() * (float)delta;
}
else
{
newGravityVelocity = -gravityReceiver.GravityDirection;
newGravityVelocity = -gravityReceiver.GetGravityDirection();
}
Vector3 currentUp = GlobalTransform.Basis.Y;
Vector3 targetUp = gravityReceiver.GravityDirection;
Vector3 targetUp = gravityReceiver.GetGravityDirection();
Vector3 axis = currentUp.Cross(targetUp);
if (axis.Length() < 0.00001f)
{
return;
}
float angle = currentUp.AngleTo(targetUp);
double angle = currentUp.AngleTo(targetUp);
Rotate(axis.Normalized(), angle * (float)delta * 10f);
GlobalRotate(axis.Normalized(), angle * delta * 10f);
}
private void ProcessCamera(double delta)
{
if (cameraPitch > 0.01f)
{
cameraPitch -= 90f * (float)delta;
cameraPitch -= 90f * delta;
}
else if (cameraPitch < -0.001f)
{
cameraPitch += 90f * (float)delta;
cameraPitch += 90f * delta;
}
if (Mathf.Abs(cameraPitch) < 1f)
{
@ -149,7 +149,7 @@ public partial class Player : CharacterBody3D
float inputX = Input.GetAxis("move_left", "move_right");
float inputZ = Input.GetAxis("move_forward", "move_back");
Vector3 direction = Transform.Basis.X * inputX + Transform.Basis.Z * inputZ;
Vector3 direction = GlobalTransform.Basis.X * inputX + GlobalTransform.Basis.Z * inputZ;
if (direction != Vector3.Zero)
{
@ -166,7 +166,7 @@ public partial class Player : CharacterBody3D
if (Input.IsActionJustPressed("jump") && IsOnGravityFloor())
{
newGravityVelocity = gravityReceiver.GravityDirection * JumpForce;
newGravityVelocity = gravityReceiver.GetGravityDirection() * JumpForce;
}
}
@ -191,9 +191,9 @@ public partial class Player : CharacterBody3D
newMovementVelocity.Z = 0f;
}
float inputRotateZ = Input.GetAxis("rotate_left", "rotate_right");
double inputRotateZ = Input.GetAxis("rotate_left", "rotate_right");
float rotateAmountZ = Mathf.DegToRad(inputRotateZ);
double rotateAmountZ = Mathf.DegToRad(inputRotateZ);
RotateObjectLocal(Vector3.Forward, rotateAmountZ);
}