Skip to content

Commit

Permalink
Merge pull request #714 from starfi5h/pr-LCP2
Browse files Browse the repository at this point in the history
Sync control panel (I) #2 - station inspector panel
  • Loading branch information
starfi5h authored Dec 1, 2024
2 parents a3536a2 + 693291b commit a8a1f99
Show file tree
Hide file tree
Showing 7 changed files with 651 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public LCPFilterResultsRequest(in ControlPanelFilter controlPanelFilter)
}
else
{
ItemsFilter = new int[0];
ItemsFilter = Array.Empty<int>();
}
StateFilter = controlPanelFilter.stateFilter;
SearchFilter = controlPanelFilter.searchFilter;
SortMethod = (short)controlPanelFilter.sortMethod;

LocalPlanetAstroId = GameMain.data.localPlanet?.astroId ?? 0;
LocalStarAstroId = GameMain.data.localStar?.astroId ?? 0;
PlayerUposition = new Float3(GameMain.mainPlayer.uPosition);
PlayerUposition = new Double3(GameMain.mainPlayer.uPosition.x, GameMain.mainPlayer.uPosition.y, GameMain.mainPlayer.uPosition.z);
}

public int TypeFilter { get; set; }
Expand All @@ -37,5 +37,5 @@ public LCPFilterResultsRequest(in ControlPanelFilter controlPanelFilter)
public short SortMethod { get; set; }
public int LocalPlanetAstroId { get; set; }
public int LocalStarAstroId { get; set; }
public Float3 PlayerUposition { get; set; }
public Double3 PlayerUposition { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override void ProcessPacket(LCPFilterResultsRequest packet, NebulaConn
var factoryCount = GameMain.data.factoryCount;
var localPlanetAstroId = packet.LocalPlanetAstroId;
var localStarAstroId = packet.LocalStarAstroId;
ref var ptr = ref GameMain.data.mainPlayer.uPosition;
var playerUPosition = new VectorLF3(packet.PlayerUposition.x, packet.PlayerUposition.y, packet.PlayerUposition.z);

var factories = GameMain.data.factories;
var galaxyAstros = GameMain.data.spaceSector.galaxyAstros;
Expand All @@ -47,7 +47,7 @@ protected override void ProcessPacket(LCPFilterResultsRequest packet, NebulaConn
var astroId = factories[i].planet.astroId;
if (filter.sortMethod == ControlPanelFilter.ESortMethod.AstroDistance)
{
var sqrMagnitude = (galaxyAstros[astroId].uPos - ptr).sqrMagnitude;
var sqrMagnitude = (galaxyAstros[astroId].uPos - playerUPosition).sqrMagnitude;
var index = sortedAstros.Count - 1;
while (index >= 0 && sqrMagnitude < sortedAstros[index].sqrDistToPlayer)
{
Expand Down
13 changes: 12 additions & 1 deletion NebulaPatcher/Patches/Dynamic/UIControlPanelObjectEntry_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,16 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
return instructions;
}
}
}

[HarmonyPostfix]
[HarmonyPatch(nameof(UIControlPanelObjectEntry.OnSelectButtonClick))]
public static void OnSelectButtonClick_Postfix(UIControlPanelObjectEntry __instance)
{
if (!__instance.isTargetDataValid)
{
// The main reason why target data is invalid is due to remote planet is not loaded for client
// So make a popup here to info the user about this behavior
UIRealtimeTip.Popup("Can't view remote planet for MP client!".Translate());
}
}
}
Loading

0 comments on commit a8a1f99

Please sign in to comment.