Construct Compound

This commit is contained in:
h z
2024-06-22 02:28:37 +08:00
parent 5a5bc2d556
commit d0d90501a5
5 changed files with 34 additions and 31 deletions

View File

@@ -49,11 +49,12 @@ public partial class CompoundConstructor : Panel
BaseAtom a = AtomResolver.Resolve(idx);
Compound c = a.GrabCompound;
c.Amount = 1;
a.Compound = c;
Atom at = ResourceLoader.Load<PackedScene>("res://Scenes/Atom.tscn").Instantiate<Atom>();
at.BaseAtom = a;
AddChild(at);
at.Position = new(500, 500);
HomogeneousMixture.AddCompound(c);
HomogeneousMixture.AddCompound(c, true, true);
Atoms.Add(at);
}
@@ -112,6 +113,8 @@ public partial class CompoundConstructor : Panel
{
HeterogeneousMixture.Container = GlobalScene.Demo.SelectedBottle;
GlobalScene.Demo.SelectedBottle.Content = HeterogeneousMixture;
GlobalScene.Demo.SelectedBottle.BuildMenu();
Clear();
}
@@ -128,7 +131,8 @@ public partial class CompoundConstructor : Panel
foreach (Atom atom in Atoms)
{
RemoveChild(atom);
if (!BondMap.ContainsKey(atom))
continue;
foreach (Bond bond in BondMap[atom])
{
if (!removedBonds.Contains(bond))
@@ -140,6 +144,7 @@ public partial class CompoundConstructor : Panel
Atoms = new();
BondMap = new();
HeterogeneousMixture = new HeterogeneousMixture();
HomogeneousMixture = HeterogeneousMixture.AddLayer();
}
private void ForceClear() => Clear(false);