particles/ParticleNode.cs

38 lines
1.1 KiB
C#
Raw Normal View History

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;
2021-12-29 15:08:26 -05:00
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)
{
2021-12-29 15:08:26 -05:00
Position = WasTeleportedLast == false
? LastSimulationPosition.LinearInterpolate(CurrentSimulationPosition,
GetParent<Node2D>().GetParent<Main>().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);
}
}