Skip to content

Commit

Permalink
Fill out the System viewer
Browse files Browse the repository at this point in the history
Fixed gravity on Mars and Luna
  • Loading branch information
behindcurtain3 committed Mar 26, 2024
1 parent 42831f4 commit b55884a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Pulsar4X/GameEngine/Engine/Factories/DefaultStartFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ public static Entity DefaultHumans(Game game, string name)
Entity solStar = solSys.GetAllEntitiesWithDataBlob<StarInfoDB>().First();
Entity earth = NameLookup.GetFirstEntityWithName(solSys, "Earth"); //should be fourth entity created
Entity luna = NameLookup.GetFirstEntityWithName(solSys, "Luna");
Entity mars = NameLookup.GetFirstEntityWithName(solSys, "Mars");
//Entity factionEntity = FactionFactory.CreatePlayerFaction(game, owner, name);
Entity factionEntity = FactionFactory.CreateFaction(game, name);
FactionInfoDB factionInfoDB = factionEntity.GetDataBlob<FactionInfoDB>();
FactionDataStore factionDataStore = factionInfoDB.Data;

earth.GetDataBlob<GeoSurveyableDB>().GeoSurveyStatus[factionEntity.Id] = 0;
luna.GetDataBlob<GeoSurveyableDB>().GeoSurveyStatus[factionEntity.Id] = 0;
mars.GetDataBlob<GeoSurveyableDB>().GeoSurveyStatus[factionEntity.Id] = 0;

Entity targetFaction = FactionFactory.CreateFaction(game, "OpFor");
FactionDataStore opForDataStore = targetFaction.GetDataBlob<FactionInfoDB>().Data;
Expand Down
2 changes: 1 addition & 1 deletion Pulsar4X/GameEngine/Engine/Factories/Sol/EarthAndLuna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static Entity Luna(Game game, StarSystem sol, Entity sun, Entity parentPl
OrbitDB planetOrbit = parentPlanet.GetDataBlob<OrbitDB>();
PositionDB planetPositionDB = parentPlanet.GetDataBlob<PositionDB>();

SystemBodyInfoDB moonBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Moon, SupportsPopulations = true };
SystemBodyInfoDB moonBodyDB = new SystemBodyInfoDB { Gravity = 1.625, BodyType = BodyType.Moon, SupportsPopulations = true };
MassVolumeDB moonMVDB = MassVolumeDB.NewFromMassAndRadius_AU(7.34767309E22, Distance.KmToAU(6378.1));
NameDB moonNameDB = new NameDB("Luna");
double moonSemiMajorAxisAU = Distance.KmToAU(0.3844E6);
Expand Down
9 changes: 7 additions & 2 deletions Pulsar4X/GameEngine/Engine/Factories/Sol/Mars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static Entity Mars(Game game, StarSystem sol, Entity sun, DateTime epoch,
{
MassVolumeDB sunMVDB = sun.GetDataBlob<MassVolumeDB>();

SystemBodyInfoDB planetBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.25f };
SystemBodyInfoDB planetBodyDB = new SystemBodyInfoDB { Gravity = 3.72076, BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.25f };
MassVolumeDB planetMVDB = MassVolumeDB.NewFromMassAndRadius_AU(0.64174E24, Distance.KmToAU(3396.2));
NameDB planetNameDB = new NameDB("Mars");

Expand Down Expand Up @@ -51,8 +51,13 @@ public static Entity Mars(Game game, StarSystem sol, Entity sun, DateTime epoch,
};
AtmosphereDB planetAtmosphereDB = new AtmosphereDB(pressureAtm, false, 0, 0, 0, -63, atmoGasses);

var geoSurveyable = new GeoSurveyableDB()
{
PointsRequired = 575
};

Entity planet = Entity.Create();
sol.AddEntity(planet, new List<BaseDataBlob> { planetNameDB, sensorProfile, planetPositionDB, planetBodyDB, planetMVDB, planetOrbitDB, planetAtmosphereDB });
sol.AddEntity(planet, new List<BaseDataBlob> { planetNameDB, sensorProfile, planetPositionDB, planetBodyDB, planetMVDB, planetOrbitDB, planetAtmosphereDB, geoSurveyable });
SensorTools.PlanetEmmisionSig(sensorProfile, planetBodyDB, planetMVDB);
return planet;
}
Expand Down
70 changes: 65 additions & 5 deletions Pulsar4X/Pulsar4X.Client/GalaxyManagement/SystemTreeViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ internal override void Display()
.OrderBy(x => x.Position?.AbsolutePosition ?? Orbital.Vector3.Zero)
.ToList();

if(ImGui.BeginTable("DesignStatsTables", 4, ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.RowBg))
if(ImGui.BeginTable("DesignStatsTables", 9, ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.RowBg))
{
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("Colony", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("GeoSurvey", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.None, 0.1f);
ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.None, 0.1f);
ImGui.TableSetupColumn("Colony", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableSetupColumn("GeoSurvey", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableSetupColumn("Gravity", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableSetupColumn("Temperature", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableSetupColumn("Atm Pressure", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableSetupColumn("Oxygen", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableSetupColumn("Minerals", ImGuiTableColumnFlags.None, 0.075f);
ImGui.TableHeadersRow();

foreach (var body in stars)
Expand Down Expand Up @@ -114,13 +119,15 @@ private void PrintEntity(Entity entity, int depth = 0)
ImGui.Text("");
}
ImGui.TableNextColumn();
bool isSurveyComplete = false;
if(entity.TryGetDatablob<GeoSurveyableDB>(out var geoSurveyableDB))
{
if(geoSurveyableDB.HasSurveyStarted(_uiState.Faction.Id))
{
if(geoSurveyableDB.IsSurveyComplete(_uiState.Faction.Id))
{
ImGui.Text("Complete");
isSurveyComplete = true;
}
else
{
Expand All @@ -136,5 +143,58 @@ private void PrintEntity(Entity entity, int depth = 0)
{
ImGui.Text("");
}

if(isSurveyComplete)
{
var bodyInfoDb = entity.GetDataBlob<SystemBodyInfoDB>();
ImGui.TableNextColumn();
ImGui.Text(Stringify.Velocity(bodyInfoDb.Gravity));
ImGui.TableNextColumn();
ImGui.Text(bodyInfoDb.BaseTemperature.ToString("#.#") + " C");

if(entity.TryGetDatablob<AtmosphereDB>(out var atmosphereDB))
{
ImGui.TableNextColumn();
ImGui.Text(Stringify.Number(atmosphereDB.Pressure));
ImGui.TableNextColumn();
if(atmosphereDB.Composition.ContainsKey("oxygen"))
{
ImGui.Text(atmosphereDB.Composition["oxygen"] > 0.001 ? atmosphereDB.Composition["oxygen"].ToString("0.0#") : "trace");
}
else
{
ImGui.Text("No");
}
}
else
{
ImGui.TableNextColumn();
ImGui.TableNextColumn();
}

if(entity.TryGetDatablob<MineralsDB>(out var mineralsDB))
{
ImGui.TableNextColumn();
ImGui.Text("Yes");
}
else
{
ImGui.TableNextRow();
}
}
else
{
ImGui.TableNextRow();
}


// DisplayHelpers.PrintRow("Tectonic Activity", bodyInfoDb.Tectonics.ToDescription());
// DisplayHelpers.PrintRow("Gravity", Stringify.Velocity(bodyInfoDb.Gravity));
// DisplayHelpers.PrintRow("Temperature", bodyInfoDb.BaseTemperature.ToString("#.#") + " C");
// DisplayHelpers.PrintRow("Length of Day", bodyInfoDb.LengthOfDay.TotalHours + " hours");
// DisplayHelpers.PrintRow("Tilt", bodyInfoDb.AxialTilt.ToString("#") + "°");
// DisplayHelpers.PrintRow("Magnetic Field", bodyInfoDb.MagneticField.ToString("#") + " μT");
// DisplayHelpers.PrintRow("Radiation Level", bodyInfoDb.RadiationLevel.ToString("#"));
// DisplayHelpers.PrintRow("Atmospheric Dust", bodyInfoDb.AtmosphericDust.ToString("#"), separator: false);
}
}

0 comments on commit b55884a

Please sign in to comment.