63 lines
1.5 KiB
C#
Executable File
63 lines
1.5 KiB
C#
Executable File
using Godot;
|
|
using Skeleton.DataStructure;
|
|
using VirtualChemistry.Chemistry.Containers;
|
|
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
|
|
|
public partial class Flask : TextureRect, IChemicalContainer
|
|
{
|
|
public double ContainerVolume { get; set; } = 0.5;
|
|
private TextureRect InnerLayer { get; set; }
|
|
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;
|
|
InnerLayer.AddChild(fc);
|
|
fc.Position = new(0, -(float)fc.StartFrom);
|
|
Map[m] = fc;
|
|
}
|
|
}
|
|
|
|
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 = new(this);
|
|
InnerLayer = GetNode<TextureRect>("InnerLayer");
|
|
}
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
public override void _Process(double delta)
|
|
{
|
|
}
|
|
}
|