Skip to content

Commit

Permalink
More work on geo-surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
behindcurtain3 committed Mar 25, 2024
1 parent 2964274 commit aea2080
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 38 deletions.
1 change: 0 additions & 1 deletion Pulsar4X/GameEngine/Datablobs/FactionInfoDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class FactionInfoDB : BaseDataBlob

public IEventLog EventLog { get; internal set; }


public FactionInfoDB()
{
var componentDesigns = new Dictionary<string, ComponentDesign>();
Expand Down
21 changes: 0 additions & 21 deletions Pulsar4X/GameEngine/Datablobs/GeoSurveyStatusDB.cs

This file was deleted.

18 changes: 18 additions & 0 deletions Pulsar4X/GameEngine/Datablobs/GeoSurveyableDB.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;
using Pulsar4X.DataStructures;

namespace Pulsar4X.Datablobs;

public class GeoSurveyableDB : BaseDataBlob
{
[JsonProperty]
public uint pointsRequired { get; set; }

/// <summary>
/// Stores the status of the geosurveys that have been conducted by each faction
/// Key: faction id
/// Value: the points remaining to complete the survey
/// </summary>
[JsonProperty]
public SafeDictionary<int, uint> GeoSurveyStatus { get; set; } = new ();
}
14 changes: 12 additions & 2 deletions Pulsar4X/GameEngine/Engine/Factories/Sol/EarthAndLuna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public static Entity Earth(Game game, StarSystem sol, Entity sun, DateTime epoch
};
AtmosphereDB planetAtmosphereDB = new AtmosphereDB(pressureAtm, true, 71, 1f, 1f, 57.2f, atmoGasses);

var geoSurveyable = new GeoSurveyableDB()
{
pointsRequired = 1500
};

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 Expand Up @@ -80,8 +85,13 @@ public static Entity Luna(Game game, StarSystem sol, Entity sun, Entity parentPl
moonBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, planetOrbit); //yes, using parent planet orbit here, since this is the DB it calculates the average distance from.
PositionDB moonPositionDB = new PositionDB(moonOrbitDB.GetPosition(game.TimePulse.GameGlobalDateTime), sol.Guid, parentPlanet);

var geoSurveyable = new GeoSurveyableDB()
{
pointsRequired = 250
};

Entity moon = Entity.Create();
sol.AddEntity(moon, new List<BaseDataBlob> { moonNameDB, sensorProfile, moonPositionDB, moonBodyDB, moonMVDB, moonOrbitDB });
sol.AddEntity(moon, new List<BaseDataBlob> { moonNameDB, sensorProfile, moonPositionDB, moonBodyDB, moonMVDB, moonOrbitDB, geoSurveyable });
SensorTools.PlanetEmmisionSig(sensorProfile, moonBodyDB, moonMVDB);
return moon;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private bool GeoSurveyFilter(Entity entity)
{
return entity.HasDataBlob<SystemBodyInfoDB>()
&& !entity.HasDataBlob<StarInfoDB>()
&& (!entity.HasDataBlob<GeoSurveyStatusDB>() || !entity.GetDataBlob<GeoSurveyStatusDB>().IsSurveyComplete(RequestingFactionGuid));
&& (!entity.HasDataBlob<GeoSurveyableDB>() || !entity.GetDataBlob<GeoSurveyableDB>().IsSurveyComplete(RequestingFactionGuid));
}

public static MoveToNearestGeoSurveyAction CreateCommand(int factionId, Entity commandingEntity)
Expand Down
11 changes: 0 additions & 11 deletions Pulsar4X/GameEngine/Extensions/GeoSurveyStatusDBExtensions.cs

This file was deleted.

18 changes: 18 additions & 0 deletions Pulsar4X/GameEngine/Extensions/GeoSurveyableDBExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Pulsar4X.Datablobs;
using Pulsar4X.Engine;

namespace Pulsar4X.Extensions;

public static class GeoSurveyableDBExtensions
{
public static bool IsSurveyComplete(this GeoSurveyableDB geoSurveyableDB, int factionId)
{
return geoSurveyableDB.GeoSurveyStatus.ContainsKey(factionId)
&& geoSurveyableDB.GeoSurveyStatus[factionId] == 0;
}

public static bool HasSurveyStarted(this GeoSurveyableDB geoSurveyableDB, int factionId)
{
return geoSurveyableDB.GeoSurveyStatus.ContainsKey(factionId);
}
}
28 changes: 26 additions & 2 deletions Pulsar4X/Pulsar4X.Client/GalaxyManagement/SystemTreeViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ internal override void Display()
.OrderBy(x => x.Position?.AbsolutePosition ?? Orbital.Vector3.Zero)
.ToList();

if(ImGui.BeginTable("DesignStatsTables", 3, ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.RowBg))
if(ImGui.BeginTable("DesignStatsTables", 4, ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.RowBg))
{
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("Type", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("Colony", ImGuiTableColumnFlags.None);
ImGui.TableSetupColumn("GeoSurvey", ImGuiTableColumnFlags.None);
ImGui.TableHeadersRow();

foreach (var body in stars)
Expand Down Expand Up @@ -112,5 +113,28 @@ private void PrintEntity(Entity entity, int depth = 0)
{
ImGui.Text("");
}
ImGui.TableNextColumn();
if(entity.TryGetDatablob<GeoSurveyableDB>(out var geoSurveyableDB))
{
if(geoSurveyableDB.HasSurveyStarted(_uiState.Faction.Id))
{
if(geoSurveyableDB.IsSurveyComplete(_uiState.Faction.Id))
{
ImGui.Text("Complete");
}
else
{
ImGui.Text("In Progress");
}
}
else
{
ImGui.Text("Surveyable");
}
}
else
{
ImGui.Text("");
}
}
}

0 comments on commit aea2080

Please sign in to comment.