Skip to content

Commit

Permalink
DebugWindow: handle system changes better
Browse files Browse the repository at this point in the history
  • Loading branch information
behindcurtain3 committed Apr 24, 2024
1 parent 655e894 commit 81b2b96
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions Pulsar4X/Pulsar4X.Client/DebugAndPData/DebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
using ImGuiNET;
using ImGuiSDL2CS;
using Pulsar4X.Engine;
using Pulsar4X.Atb;
using Pulsar4X.Datablobs;
using Pulsar4X.Orbital;
using Pulsar4X.Extensions;
using Pulsar4X.SDL2UI.Combat;
using Vector3 = Pulsar4X.Orbital.Vector3;
using System.Collections.Immutable;
using System.Linq;

namespace Pulsar4X.SDL2UI
Expand Down Expand Up @@ -57,7 +55,6 @@ private Entity? SelectedEntity
bool _isRunningFrame = false;
bool _drawSOI = false;
bool _drawParentSOI = false;
//List<ECSLib.Vector4> positions = new List<ECSLib.Vector4>();
private bool _showDamageWindow = false;
private IntPtr _dmgTxtr;

Expand All @@ -75,11 +72,9 @@ private Entity? SelectedEntity

};



private DebugWindow()
{

_uiState.OnStarSystemChanged += RefreshFactionEntites;
}
internal static DebugWindow GetInstance()
{
Expand All @@ -89,7 +84,7 @@ internal static DebugWindow GetInstance()
else
{
instance = (DebugWindow)_uiState.LoadedWindows[typeof(DebugWindow)];
instance.RefreshFactionEntites();
instance.RefreshFactionEntites(_uiState);
//if(_uiState.LastClickedEntity?.Entity != null)
// instance.SelectedEntity = _uiState.LastClickedEntity.Entity;
}
Expand Down Expand Up @@ -900,7 +895,7 @@ private bool EnableDrawSOI()
return true;
}

void RefreshFactionEntites()
void RefreshFactionEntites(GlobalUIState uiState)
{
_factionOwnedEntites = new List<(string name, Entity entity)>();
var factionEntites = _uiState.SelectedSystem.GetEntitiesByFaction(_uiState.Faction.Id);
Expand Down Expand Up @@ -1282,12 +1277,6 @@ public override void OnSystemTickChange(DateTime newDate)
_dateChangeSinceLastFrame = true;

if(SystemState == null) return;

if (SystemState.EntitiesToBin.Count > 0)
{
RefreshFactionEntites();
}

}

public override void OnGameTickChange(DateTime newDate)
Expand Down

0 comments on commit 81b2b96

Please sign in to comment.