2021-12-26 14:58:58 -05:00
|
|
|
using Godot;
|
2022-01-17 23:52:42 -05:00
|
|
|
using System;
|
2022-01-25 12:33:18 -05:00
|
|
|
using Particles.ParticleSimulation;
|
2021-12-26 14:58:58 -05:00
|
|
|
|
2022-01-17 23:52:42 -05:00
|
|
|
public class Main : Node
|
2021-12-26 14:58:58 -05:00
|
|
|
{
|
2021-12-27 14:58:33 -05:00
|
|
|
|
2022-01-25 12:33:18 -05:00
|
|
|
public int Seed;
|
2022-01-25 23:06:48 -05:00
|
|
|
public float Zoom;
|
2022-01-25 12:33:18 -05:00
|
|
|
|
2022-01-25 23:06:48 -05:00
|
|
|
private int _nParticles;
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
OS.MinWindowSize = new Vector2(1024, 600);
|
|
|
|
}
|
|
|
|
|
2022-01-25 12:33:18 -05:00
|
|
|
public void StartSimulation(int nParticles)
|
2021-12-27 16:10:07 -05:00
|
|
|
{
|
2022-01-25 12:33:18 -05:00
|
|
|
_nParticles = nParticles;
|
2022-01-18 12:01:37 -05:00
|
|
|
var particleSimulationPackedScene = GD.Load<PackedScene>("res://ParticleSimulation/ParticleSimulationScene.tscn");
|
2022-01-17 23:52:42 -05:00
|
|
|
var particleSimulationScene = particleSimulationPackedScene.Instance<ParticleSimulationScene>();
|
2022-01-25 12:33:18 -05:00
|
|
|
particleSimulationScene.Name = Seed.ToString();
|
2022-01-17 23:52:42 -05:00
|
|
|
AddChild(particleSimulationScene);
|
2022-01-25 23:06:48 -05:00
|
|
|
particleSimulationScene.Initialize(Seed, nParticles, Zoom);
|
2022-01-17 23:52:42 -05:00
|
|
|
GetNode<Control>("MainMenu").Hide();
|
2021-12-26 21:16:28 -05:00
|
|
|
}
|
2022-01-25 12:02:24 -05:00
|
|
|
|
|
|
|
public void ExitToMenu()
|
|
|
|
{
|
2022-01-25 12:33:18 -05:00
|
|
|
GetNode(Seed.ToString()).QueueFree();
|
2022-01-25 12:02:24 -05:00
|
|
|
GetNode<Control>("MainMenu").Show();
|
2022-01-25 12:33:18 -05:00
|
|
|
GetNode<MainMenu>("MainMenu").RefreshSeedText();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void RestartSimulation()
|
|
|
|
{
|
|
|
|
GetNode<ParticleSimulationScene>(Seed.ToString()).Hide();
|
|
|
|
GetNode(Seed.ToString()).QueueFree();
|
2022-01-25 23:06:48 -05:00
|
|
|
Seed = Mathf.Abs((int)GD.Randi());
|
2022-01-25 12:33:18 -05:00
|
|
|
StartSimulation(_nParticles);
|
2022-01-25 12:02:24 -05:00
|
|
|
}
|
2022-01-17 23:52:42 -05:00
|
|
|
|
|
|
|
}
|