Implement RPC Node
This commit is contained in:
parent
f7ee533d5a
commit
605e43273e
13 changed files with 524 additions and 206 deletions
|
|
@ -4,13 +4,41 @@ public partial class StarNode : StaticBody3D
|
|||
{
|
||||
public Star StarData { get; set; }
|
||||
|
||||
private Vector3 lastFrameCoordinates = Vector3.Zero;
|
||||
private Vector3 lastFrameRotation = Vector3.Zero;
|
||||
|
||||
private Vector3 velocityOffset = Vector3.Zero;
|
||||
private Vector3 angularVelocityOffset = Vector3.Zero;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
GlobalPosition = StarData.LocalCoordinates + StarData.SectorOffset;
|
||||
GlobalRotation = StarData.Rotation;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
GlobalPosition = StarData.LocalCoordinates + StarData.SectorOffset;
|
||||
if (StarData.LocalCoordinates == lastFrameCoordinates)
|
||||
{
|
||||
velocityOffset += StarData.Velocity * delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastFrameCoordinates = StarData.LocalCoordinates;
|
||||
velocityOffset = Vector3.Zero;
|
||||
}
|
||||
|
||||
if (StarData.Rotation == lastFrameRotation)
|
||||
{
|
||||
angularVelocityOffset += StarData.AngularVelocity * delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastFrameRotation = StarData.Rotation;
|
||||
angularVelocityOffset = Vector3.Zero;
|
||||
}
|
||||
|
||||
GlobalPosition = StarData.LocalCoordinates + StarData.SectorOffset + velocityOffset;
|
||||
GlobalRotation = StarData.Rotation + angularVelocityOffset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue