using Godot; using System; public partial class MainScene : Node2D { public Node CurrentScene { get; set; } public VirtualChemistryDemo Demo { get; set; } public override void _Ready() { GlobalScene.MainScene = this; Demo = GetNode("Demo"); CurrentScene = Demo; } public void SwitchToConstructor() { if (CurrentScene == GlobalScene.CompoundConstructor) return; if (CurrentScene != Demo) throw new Exception("?"); if (GlobalScene.CompoundConstructor == null) GlobalScene.CompoundConstructor = ResourceLoader .Load("res://Scenes/CompoundConstructor.tscn") .Instantiate(); RemoveChild(Demo); AddChild(GlobalScene.CompoundConstructor); CurrentScene = GlobalScene.CompoundConstructor; } public void SwitchToDemo() { if (CurrentScene == Demo) return; if (CurrentScene != GlobalScene.CompoundConstructor) throw new Exception("?"); RemoveChild(CurrentScene); AddChild(Demo); CurrentScene = Demo; } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { } }