restructured project
This commit is contained in:
38
ParticleSimulation/ParticleNode.cs
Normal file
38
ParticleSimulation/ParticleNode.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Godot;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public class ParticleNode : Node2D
|
||||
{
|
||||
private Label _labelNode;
|
||||
private Sprite _spriteNode;
|
||||
public Vector2 CurrentSimulationPosition = new Vector2();
|
||||
|
||||
public Vector2 LastSimulationPosition;
|
||||
public bool WasTeleportedLast = true;
|
||||
public int SimulationId;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_spriteNode = GetNode<Sprite>("Sprite");
|
||||
_labelNode = GetNode<Label>("Label");
|
||||
}
|
||||
|
||||
public override void _Process(float delta)
|
||||
{
|
||||
Position = WasTeleportedLast == false
|
||||
? LastSimulationPosition.LinearInterpolate(CurrentSimulationPosition,
|
||||
GetParent<Node2D>().GetParent<ParticleSimulationScene>().PhysicsInterpolationFraction)
|
||||
: CurrentSimulationPosition;
|
||||
}
|
||||
|
||||
public void SetLabelText(string text)
|
||||
{
|
||||
_labelNode.Text = text;
|
||||
}
|
||||
|
||||
public void SetColor(float hue, float saturation, float opacity)
|
||||
{
|
||||
_spriteNode.Modulate = Color.FromHsv(hue, saturation, 1, opacity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user