2021-12-27 23:29:02 -05:00
|
|
|
using Godot;
|
|
|
|
|
2021-12-28 14:32:11 -05:00
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
// ReSharper disable once ClassNeverInstantiated.Global
|
2021-12-27 23:29:02 -05:00
|
|
|
public class ParticleNode : Node2D
|
|
|
|
{
|
|
|
|
private Label _labelNode;
|
2021-12-28 14:32:11 -05:00
|
|
|
private Sprite _spriteNode;
|
|
|
|
public Vector2 CurrentSimulationPosition = new Vector2();
|
|
|
|
|
|
|
|
public Vector2 LastSimulationPosition;
|
2021-12-29 15:08:26 -05:00
|
|
|
public bool WasTeleportedLast = true;
|
2021-12-27 23:29:02 -05:00
|
|
|
public int SimulationId;
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
_spriteNode = GetNode<Sprite>("Sprite");
|
|
|
|
_labelNode = GetNode<Label>("Label");
|
|
|
|
}
|
|
|
|
|
2021-12-28 14:32:11 -05:00
|
|
|
public override void _Process(float delta)
|
|
|
|
{
|
2021-12-29 15:08:26 -05:00
|
|
|
Position = WasTeleportedLast == false
|
2021-12-28 14:32:11 -05:00
|
|
|
? LastSimulationPosition.LinearInterpolate(CurrentSimulationPosition,
|
|
|
|
GetParent<Node2D>().GetParent<Main>().PhysicsInterpolationFraction)
|
|
|
|
: CurrentSimulationPosition;
|
|
|
|
}
|
|
|
|
|
2021-12-27 23:29:02 -05:00
|
|
|
public void SetLabelText(string text)
|
|
|
|
{
|
|
|
|
_labelNode.Text = text;
|
|
|
|
}
|
|
|
|
|
2021-12-28 14:32:11 -05:00
|
|
|
public void SetColor(float hue, float saturation, float opacity)
|
2021-12-27 23:29:02 -05:00
|
|
|
{
|
2021-12-28 14:32:11 -05:00
|
|
|
_spriteNode.Modulate = Color.FromHsv(hue, saturation, 1, opacity);
|
2021-12-27 23:29:02 -05:00
|
|
|
}
|
|
|
|
}
|