Skip to content

Commit

Permalink
Add events for surveys completing
Browse files Browse the repository at this point in the history
  • Loading branch information
behindcurtain3 committed Apr 5, 2024
1 parent 5456827 commit 602c157
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Pulsar4X/GameEngine/Engine/Processors/GeoSurveyProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using Pulsar4X.Datablobs;
using Pulsar4X.Events;
using Pulsar4X.Extensions;
using Pulsar4X.Interfaces;

namespace Pulsar4X.Engine;
Expand Down Expand Up @@ -27,9 +29,19 @@ internal override void ProcessEntity(Entity entity, DateTime atDateTime)
if(!geoSurveyableDB.GeoSurveyStatus.ContainsKey(Fleet.FactionOwnerID))
geoSurveyableDB.GeoSurveyStatus[Fleet.FactionOwnerID] = geoSurveyableDB.PointsRequired;

if(totalSurveyPoints > geoSurveyableDB.GeoSurveyStatus[Fleet.FactionOwnerID])
if(totalSurveyPoints >= geoSurveyableDB.GeoSurveyStatus[Fleet.FactionOwnerID])
{
// Survey is complete
geoSurveyableDB.GeoSurveyStatus[Fleet.FactionOwnerID] = 0;

EventManager.Instance.Publish(
Event.Create(
EventType.GeoSurveyCompleted,
atDateTime,
$"Geo Survey of {Target.GetName(Fleet.FactionOwnerID)} complete",
Fleet.FactionOwnerID,
Target.Manager.ManagerGuid,
Target.Id));
}
else
{
Expand Down
14 changes: 13 additions & 1 deletion Pulsar4X/GameEngine/Engine/Processors/JPSurveyProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using Pulsar4X.Datablobs;
using Pulsar4X.Events;
using Pulsar4X.Extensions;
using Pulsar4X.Interfaces;

namespace Pulsar4X.Engine;
Expand Down Expand Up @@ -27,9 +29,19 @@ internal override void ProcessEntity(Entity entity, DateTime atDateTime)
if(!jpSurveyableDB.SurveyPointsRemaining.ContainsKey(Fleet.FactionOwnerID))
jpSurveyableDB.SurveyPointsRemaining[Fleet.FactionOwnerID] = jpSurveyableDB.PointsRequired;

if(totalSurveyPoints > jpSurveyableDB.SurveyPointsRemaining[Fleet.FactionOwnerID])
if(totalSurveyPoints >= jpSurveyableDB.SurveyPointsRemaining[Fleet.FactionOwnerID])
{
// Survey is complete
jpSurveyableDB.SurveyPointsRemaining[Fleet.FactionOwnerID] = 0;

EventManager.Instance.Publish(
Event.Create(
EventType.JumpPointSurveyCompleted,
atDateTime,
$"Survey of {Target.GetName(Fleet.FactionOwnerID)} complete",
Fleet.FactionOwnerID,
Target.Manager.ManagerGuid,
Target.Id));
}
else
{
Expand Down
1 change: 1 addition & 0 deletions Pulsar4X/GameEngine/Events/EventTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ public enum EventType
NewJumpConnection,
NewSystemDiscovered,
JumpPointFound,
JumpPointSurveyCompleted,

// Empire Events
EmpireInDebt,
Expand Down

0 comments on commit 602c157

Please sign in to comment.