Add initial game code

This commit is contained in:
Aslan 2025-09-12 08:34:06 -04:00
parent f80a60e208
commit 1383997ebf
55 changed files with 1355 additions and 0 deletions

View file

@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.Threading.Tasks;
public partial class Universe
{
public decimal CurrentTick { get; private set; }
public List<GameObject> GameObjects { get; private set; }
public Ship PlayerShip { get; private set; }
public Universe()
{
this.GameObjects = new List<GameObject>();
}
public decimal SimulateTick()
{
this.CurrentTick++;
List<Task> galaxySimulationTasks = new List<Task>();
foreach (GameObject gameObject in this.GameObjects)
{
if (gameObject.GetType().Name == "Galaxy")
{
Task galaxySimulation = new Task(() => gameObject.Simulate());
galaxySimulation.Start();
galaxySimulationTasks.Add(galaxySimulation);
continue;
}
gameObject.Simulate();
}
Task.WaitAll(galaxySimulationTasks.ToArray());
return this.CurrentTick;
}
}