This commit is contained in:
h z
2024-06-21 20:57:19 +08:00
commit 7eed16cd02
48 changed files with 1599 additions and 0 deletions

60
Scenes/Flask.cs Executable file
View File

@@ -0,0 +1,60 @@
using Godot;
using Mathool.DataStructure;
using VirtualChemistry.Chemistry.Containers;
using VirtualChemistry.Chemistry.Mixtures.Implements;
public partial class Flask : TextureRect, IChemicalContainer
{
public double ContainerVolume { get; set; } = 100;
public double Volume() => ContainerVolume;
public HeterogeneousMixture Content { get; set; }
public double EnvironmentPressure { get; set; }
public double EnvironmentTemperature { get; set; }
public IsomorphicMap<HomogeneousMixture, FlaskContent> Map { get; set; } = new();
private void BuildMap()
{
foreach (HomogeneousMixture m in Content.Layers)
{
if (!Map.ContainsKey(m))
{
FlaskContent fc = ResourceLoader
.Load<PackedScene>("res://Scenes/FlaskContent.tscn")
.Instantiate<FlaskContent>();
fc.Mixture = m;
AddChild(fc);
fc.Position = new(0, -(float)fc.StartFrom);
}
}
foreach (FlaskContent fc in Map.Values)
{
if (fc.Mixture.HeterogeneousMixture == HeterogeneousMixture.Null)
{
Map.Remove(fc);
RemoveChild(fc);
}
}
}
public void Update()
{
BuildMap();
foreach (FlaskContent fc in Map.Values)
fc.UpdateVolumeAndPosition();
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
GlobalScene.Flask = this;
Content = HeterogeneousMixture.Null;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}