Files
VirtualChemistry.Demo/Scenes/Bond.cs
2024-06-21 20:57:19 +08:00

35 lines
877 B
C#
Executable File

using Godot;
public partial class Bond : Line2D
{
public Atom AtomFrom { get; set; }
public Atom AtomTo { get; set; }
private Label BondTypeA { get; set; }
private Label BondTypeB { get; set; }
public string TypeA { get; set; }
public string TypeB { get; set; }
public override void _Ready()
{
BondTypeA = GetNode<Label>("BondTypeA");
BondTypeB = GetNode<Label>("BondTypeB");
}
public void BondUpdate()
{
Vector2 v1 = AtomFrom.Position + new Vector2(32, 32);
Vector2 v2 = AtomTo.Position + new Vector2(32, 32);
Vector2 m = (v1 + v2) / 2;
Points = new[] { v1, m, v2 };
BondTypeA.Position = m - new Vector2(10, 10);
BondTypeB.Position = m + new Vector2(10, 10);
BondTypeA.Text = TypeA;
BondTypeB.Text = TypeB;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}