Files
VirtualChemistry.Demo/Scenes/MainScene.cs
2024-06-21 20:57:19 +08:00

47 lines
1.1 KiB
C#

using Godot;
using System;
public partial class MainScene : Node2D
{
public Node CurrentScene { get; set; }
public VirtualChemDemo Demo { get; set; }
public override void _Ready()
{
GlobalScene.MainScene = this;
Demo = GetNode<VirtualChemDemo>("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<PackedScene>("res://Scenes/CompoundConstructor.tscn")
.Instantiate<CompoundConstructor>();
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)
{
}
}