Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync control panel (I) #2 - station inspector panel #714

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading