Skip to content

Commit

Permalink
Bit of work on geo surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
behindcurtain3 committed Mar 24, 2024
1 parent 741b706 commit b9f2609
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
15 changes: 15 additions & 0 deletions Pulsar4X/GameEngine/Engine/Factories/DefaultStartFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static class DefaultStartFactory
private static ShipDesign _gunshipDesign;
private static ShipDesign _spaceXStarShipDesign;
private static OrdnanceDesign _missile;
private static ComponentDesign _geoSurveyor;


// this code is a test for multiple systems, worth mentioning it utterly failed, modularity is good when you have it huh.ç
Expand Down Expand Up @@ -486,6 +487,7 @@ public static ShipDesign DefaultShipDesign(Game game, Entity faction, FactionDat
(DefaultSimpleLaser(game, faction, factionDataStore), 2),
(DefaultBFC(game, faction, factionDataStore), 1),
(ShipSmallCargo(game, faction, factionDataStore), 1),
(DefaultGeoSurveyor(game, faction, factionDataStore), 1),
(DefaultFuelTank(game, faction, factionDataStore), 2),
(DefaultWarpDesign(game, faction, factionDataStore), 4),
(DefaultBatteryBank(game, faction, factionDataStore), 3),
Expand Down Expand Up @@ -1045,6 +1047,19 @@ public static ComponentDesign FacPassiveSensor(Game game, Entity faction, Factio
return _sensorInstalation;

}

public static ComponentDesign DefaultGeoSurveyor(Game game, Entity faction, FactionDataStore factionDataStore)
{
if (_geoSurveyor != null)
return _geoSurveyor;
ComponentTemplateBlueprint template = factionDataStore.ComponentTemplates["geo-surveyor"];
ComponentDesigner design = new ComponentDesigner(template, factionDataStore, faction.GetDataBlob<FactionTechDB>());
design.ComponentDesignAttributes["Survey Speed"].SetValueFromInput(10);
design.Name = "Geo-Surveyor";
_geoSurveyor = design.CreateDesign(faction);
factionDataStore.IncrementTechLevel(_geoSurveyor.TechID);
return _geoSurveyor;
}
}

}
19 changes: 18 additions & 1 deletion Pulsar4X/GameEngine/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ internal static bool AreAllDependenciesPresent(this IHasDataBlobs entity)
return requiredDataBlobTypes.IsSubsetOf(entityDataBlobTypes);
}

public static bool IsOrHasColony(this Entity entity) {
public static bool IsOrHasColony(this Entity entity)
{
if(entity.HasDataBlob<ColonyInfoDB>()) return true;

if(entity.TryGetDatablob<PositionDB>(out var positionDB))
Expand All @@ -437,5 +438,21 @@ public static bool IsOrHasColony(this Entity entity) {

return false;
}

public static bool HasGeoSurveyAbility(this Entity entity)
{
if(entity.HasDataBlob<GeoSurveyAbilityDB>()) return true;

if(entity.TryGetDatablob<FleetDB>(out var fleetDB))
{
foreach(var child in fleetDB.Children)
{
if(child.HasGeoSurveyAbility())
return true;
}
}

return false;
}
}
}
19 changes: 17 additions & 2 deletions Pulsar4X/Pulsar4X.Client/EmpireManagement/FleetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class FleetWindow : PulsarGuiWindow
private enum IssueOrderType
{
MoveTo,
GeoSurvey,
}

private IssueOrderType selectedIssueOrderType = IssueOrderType.MoveTo;
Expand Down Expand Up @@ -276,17 +277,20 @@ private void DisplayTabs()
{
selectedIssueOrderType = IssueOrderType.MoveTo;
}
if(SelectedFleet.HasGeoSurveyAbility() && ImGui.Selectable("Geo Survey ...", selectedIssueOrderType == IssueOrderType.GeoSurvey))
{
selectedIssueOrderType = IssueOrderType.GeoSurvey;
}

ImGui.EndChild();
}
ImGui.SameLine();
if(ImGui.BeginChild("IssueOrders", secondChildSize, true))
{

var bodies = _uiState.SelectedSystem.GetAllEntitiesWithDataBlob<SystemBodyInfoDB>(_uiState.Faction.Id);
switch(selectedIssueOrderType)
{
case IssueOrderType.MoveTo:
var bodies = _uiState.SelectedSystem.GetAllEntitiesWithDataBlob<SystemBodyInfoDB>(_uiState.Faction.Id);
foreach(var body in bodies)
{
var name = body.GetName(_uiState.Faction.Id);
Expand All @@ -297,6 +301,17 @@ private void DisplayTabs()
}
}
break;
case IssueOrderType.GeoSurvey:
foreach(var body in bodies)
{
var name = body.GetName(_uiState.Faction.Id);
if(ImGui.Button(name + "###geosurvey-button-" + name))
{
// var order = MoveToSystemBodyOrder.CreateCommand(_uiState.Faction.Id, SelectedFleet, body);
// _uiState.Game.OrderHandler.HandleOrder(order);
}
}
break;
}

ImGui.EndChild();
Expand Down

0 comments on commit b9f2609

Please sign in to comment.