private Util.LinkedList <byte> SerializeCelestialBodies(CelestialBody[] bodies) { Util.LinkedList <byte> bytes = new Util.LinkedList <byte>(); foreach (CelestialBody body in bodies) { bytes.Append(body.Serialize()); } bytes.Prepend(BitConverter.GetBytes(bodies.Length)); bytes.Prepend(BitConverter.GetBytes(bytes.Length + 4)); return(bytes); }
protected override void ThreadFunction() { ProgressTracker.Instance.PushActivity("Creating the " + MapSize.ToString()); ProgressTracker.Instance.PushActivity("Allocating space"); PreInitializeMap(MapSize, MapSeed); ProgressTracker.Instance.PopActivity(); ProgressTracker.Instance.PushActivity("Populating"); Map.Initialize(); while (!Map.Initialized) { ThreadManager.Instance.Update(); } ProgressTracker.Instance.PopActivity(); if (GameManager.Instance.RenderEdges) { ProgressTracker.Instance.PushActivity("Moving data into graph module"); EuclideanGraph.EuclideanGraph <Containers.Container> graph = new EuclideanGraph.EuclideanGraph <Containers.Container>(); Util.LinkedList <Containers.Container> smallBodies = Map.GetAllSmallBodies(); foreach (Containers.Container body in smallBodies) { graph.AddNode(body); } ProgressTracker.Instance.PopActivity(); ProgressTracker.Instance.PushActivity("Creating graph"); graph.GenerateDelaunayTriangulation(); graph.GenerateMST(); graph.AddNoise(MapSeed); ProgressTracker.Instance.PopActivity(); ProgressTracker.Instance.PushActivity("Moving data out of graph module"); WarpJumps = new List <CelestialBodyIdentifier[]>(); foreach (Containers.Container[] edge in graph.GetEdges()) { WarpJumps.Add(new CelestialBodyIdentifier[] { edge[0].ID, edge[1].ID }); } ProgressTracker.Instance.PopActivity(); } else { WarpJumps = new List <CelestialBodyIdentifier[]>(); } ProgressTracker.Instance.PopActivity(); }
public Util.LinkedList <Container> GetAllSmallBodies() { Util.LinkedList <Container> bodies = new Util.LinkedList <Container>(); if (Expanses != null) { foreach (Expanse expanse in Expanses) { bodies.Append(expanse.GetAllSmallBodies()); } } if (Galaxies != null) { foreach (Galaxy galaxy in Galaxies) { bodies.Append(galaxy.GetAllSmallBodies()); } } if (Sectors != null) { foreach (Sector sector in Sectors) { bodies.Append(sector.GetAllSmallBodies()); } } if (SolarSystems != null) { foreach (SolarSystem solarSystem in SolarSystems) { bodies.Append(solarSystem.GetAllSmallBodies()); } } if (Stars != null) { foreach (Star star in Stars) { bodies.AddLast(star); } } if (Planets != null) { foreach (Planet planet in Planets) { bodies.AddLast(planet); } } return(bodies); }
public Util.LinkedList <byte> Serialize() { Util.LinkedList <byte> bytes = new Util.LinkedList <byte>(); bytes.Append(BitConverter.GetBytes((int)Type)); bytes.Append(ID.Serialize()); bytes.Append(BitConverter.GetBytes(Position.x)); bytes.Append(BitConverter.GetBytes(Position.y)); bytes.Append(BitConverter.GetBytes(Radius)); bytes.Append(SerializeCelestialBodies(Expanses)); bytes.Append(SerializeCelestialBodies(Galaxies)); bytes.Append(SerializeCelestialBodies(Sectors)); bytes.Append(SerializeCelestialBodies(SolarSystems)); bytes.Append(SerializeCelestialBodies(Stars)); bytes.Append(SerializeCelestialBodies(Planets)); bytes.Prepend(BitConverter.GetBytes(bytes.Length + 4)); return(bytes); }