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() => GlobalScene.ElasticContainer ? Content.Volume : ContainerVolume; public HeterogeneousMixture Content { get; set; } public double EnvironmentPressure { get; set; } public double EnvironmentTemperature { get; set; } public IsomorphicMap Map { get; set; } = new(); private void BuildMap() { foreach (HomogeneousMixture m in Content.Layers) { if (!Map.ContainsKey(m)) { FlaskContent fc = ResourceLoader .Load("res://Scenes/FlaskContent.tscn") .Instantiate(); 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); InnerLayer.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("InnerLayer"); } private void ShowAll() { GlobalScene.MainControlPanel.BuildAllTree(); } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { } }