Construct Compound
This commit is contained in:
@@ -10,11 +10,10 @@ public partial class Bottle : MenuButton, IChemicalContainer
|
||||
private HeterogeneousMixture HeterogeneousMixture { get; set; }
|
||||
public double Volume() => ContainerVolume;
|
||||
|
||||
public HeterogeneousMixture Content { get; set; }
|
||||
public HeterogeneousMixture Content { get; set; } = HeterogeneousMixture.Null;
|
||||
public double EnvironmentPressure { get; set; }
|
||||
public double EnvironmentTemperature { get; set; }
|
||||
public HeterogeneousMixture ChemicalContent { get; set; } = HeterogeneousMixture.Null;
|
||||
public HomogeneousMixture MainComponent => ChemicalContent.Layers
|
||||
public HomogeneousMixture MainComponent => Content.Layers
|
||||
.DefaultIfEmpty(HomogeneousMixture.Null)
|
||||
.MaxBy(x => x.Amount);
|
||||
public Compound MainCompound => MainComponent.Compounds
|
||||
@@ -23,12 +22,24 @@ public partial class Bottle : MenuButton, IChemicalContainer
|
||||
|
||||
private const string Empty = "Empty";
|
||||
private string PotionName => $"Main: {(MainCompound == Compound.Null ? Empty : MainCompound.Expression)}";
|
||||
private string PotionAmount => $"Amount: {(MainCompound == Compound.Null ? 0d : ChemicalContent.Amount)}";
|
||||
private string PotionAmount => $"Amount: {(MainCompound == Compound.Null ? 0d : Content.Amount)}";
|
||||
|
||||
public Sprite2D ContentTexture { get; set; }
|
||||
|
||||
private void BuildMenu()
|
||||
public void BuildMenu()
|
||||
{
|
||||
|
||||
if (Content == HeterogeneousMixture.Null)
|
||||
ContentTexture.Modulate = Color.Color8(0, 0, 0, 0);
|
||||
else
|
||||
{
|
||||
ContentTexture.Modulate = Color.Color8(
|
||||
MainComponent.ColorRed,
|
||||
MainComponent.ColorGreen,
|
||||
MainComponent.ColorBlue,
|
||||
MainComponent.ColorTransparent
|
||||
);
|
||||
}
|
||||
PopupMenu menu = GetPopup();
|
||||
menu.Clear();
|
||||
foreach (var w in menu.GetSignalConnectionList(PopupMenu.SignalName.IdPressed))
|
||||
@@ -55,8 +66,8 @@ public partial class Bottle : MenuButton, IChemicalContainer
|
||||
GlobalScene.MainScene.SwitchToConstructor();
|
||||
return;
|
||||
case 3:
|
||||
ChemicalContent = GlobalScene.Flask.Content;
|
||||
ChemicalContent.Container = this;
|
||||
Content = GlobalScene.Flask.Content;
|
||||
Content.Container = this;
|
||||
GlobalScene.Flask.Content = HeterogeneousMixture.Null;
|
||||
GlobalScene.Flask.Update();
|
||||
return;
|
||||
@@ -71,17 +82,6 @@ public partial class Bottle : MenuButton, IChemicalContainer
|
||||
public override void _Ready()
|
||||
{
|
||||
ContentTexture = GetNode<Sprite2D>("Content");
|
||||
if (ChemicalContent == HeterogeneousMixture.Null)
|
||||
ContentTexture.Modulate = new Color(0, 0, 0, 0);
|
||||
else
|
||||
{
|
||||
ContentTexture.Modulate = new Color(
|
||||
MainComponent.ColorRed,
|
||||
MainComponent.ColorGreen,
|
||||
MainComponent.ColorBlue,
|
||||
MainComponent.ColorTransparent
|
||||
);
|
||||
}
|
||||
BuildMenu();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -36,8 +36,6 @@ text = "Clear"
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
|
||||
[node name="MovingLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[connection signal="pressed" from="ControlLayer/Controller/BuildMixture" to="." method="Build"]
|
||||
[connection signal="pressed" from="ControlLayer/Controller/Clear" to="." method="ForceClear"]
|
||||
[connection signal="pressed" from="ControlLayer/Controller/Back" to="." method="Back"]
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class StringLoader : Window
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
Input = GetNode<TextEdit>("Input");
|
||||
Input = GetNode<TextEdit>("V1/Input");
|
||||
GlobalScene.StringLoader = this;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
size = Vector2i(500, 250)
|
||||
script = ExtResource("1_qoxxp")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
[node name="V1" type="VBoxContainer" parent="."]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
@@ -19,25 +19,25 @@ offset_bottom = 37.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||
[node name="Label" type="Label" parent="V1"]
|
||||
layout_mode = 2
|
||||
text = "Expression:"
|
||||
|
||||
[node name="Input" type="TextEdit" parent="VBoxContainer"]
|
||||
[node name="Input" type="TextEdit" parent="V1"]
|
||||
custom_minimum_size = Vector2(450, 40)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="V1"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="Load" type="Button" parent="V1/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Load"
|
||||
|
||||
[node name="Cancel" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
[node name="Cancel" type="Button" parent="V1/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Load" to="." method="Load"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Cancel" to="." method="Cancel"]
|
||||
[connection signal="pressed" from="V1/HBoxContainer/Load" to="." method="Load"]
|
||||
[connection signal="pressed" from="V1/HBoxContainer/Cancel" to="." method="Cancel"]
|
||||
|
||||
Reference in New Issue
Block a user