Skip to content

Commit

Permalink
Sync RemoteGroupMask and RoutePriority in StationUI
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Jun 5, 2024
1 parent a98e4c3 commit b5c2e37
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
18 changes: 5 additions & 13 deletions NebulaModel/Packets/Logistics/StationUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public enum EUISettings
PilerCount,
MaxMiningSpeed,
DroneAutoReplenish,
ShipAutoReplenish
ShipAutoReplenish,
RemoteGroupMask,
RoutePriority
}

public StationUI() { }

public StationUI(int planetId, int stationId, int stationGId, EUISettings settingIndex, float value,
public StationUI(int planetId, int stationId, int stationGId, EUISettings settingIndex, double value,
bool warperShouldTakeFromStorage = false)
{
PlanetId = planetId;
Expand All @@ -35,21 +37,11 @@ public StationUI(int planetId, int stationId, int stationGId, EUISettings settin
WarperShouldTakeFromStorage = warperShouldTakeFromStorage;
}

public StationUI(int planetId, int stationId, int stationGId, EUISettings settingIndex, string settingString)
{
PlanetId = planetId;
StationId = stationId;
StationGId = stationGId;
SettingIndex = settingIndex;
SettingString = settingString;
}

public int PlanetId { get; set; }
public int StationId { get; set; }
public int StationGId { get; set; }
public EUISettings SettingIndex { get; set; }
public float SettingValue { get; set; }
public string SettingString { get; set; }
public double SettingValue { get; set; }
public bool WarperShouldTakeFromStorage { get; set; }
public bool ShouldRefund { get; set; }
}
38 changes: 38 additions & 0 deletions NebulaPatcher/Patches/Dynamic/UIStationWindow_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,44 @@ public static void OnWarperIconClick_Postfix(UIStationWindow __instance, int __s
__instance.warperIconButton.button.interactable = false;
}

[HarmonyPostfix]
[HarmonyPatch(nameof(UIStationWindow.OnGroupButtonClick))]
public static void OnGroupButtonClick_Postfix(UIStationWindow __instance)
{
if (__instance.event_lock || !Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS)
{
return;
}

if (__instance.stationId == 0 || __instance.factory == null)
{
return;
}
var stationComponent = __instance.transport.stationPool[__instance.stationId];
var packet = new StationUI(__instance.factory.planet.id, stationComponent.id, stationComponent.gid,
StationUI.EUISettings.RemoteGroupMask, BitConverter.Int64BitsToDouble(stationComponent.remoteGroupMask));
Multiplayer.Session.Network.SendPacket(packet);
}

[HarmonyPostfix]
[HarmonyPatch(nameof(UIStationWindow.OnBehaviorBomboBoxItemIndexChange))]
public static void OnBehaviorBomboBoxItemIndexChange_Postfix(UIStationWindow __instance)
{
if (__instance.event_lock || !Multiplayer.IsActive || Multiplayer.Session.Ships.PatchLockILS)
{
return;
}

if (__instance.stationId == 0 || __instance.factory == null)
{
return;
}
var stationComponent = __instance.transport.stationPool[__instance.stationId];
var packet = new StationUI(__instance.factory.planet.id, stationComponent.id, stationComponent.gid,
StationUI.EUISettings.RoutePriority, (int)stationComponent.routePriority);
Multiplayer.Session.Network.SendPacket(packet);
}

[HarmonyPostfix]
[HarmonyPatch(nameof(UIStationWindow._OnOpen))]
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Original Function Name")]
Expand Down
10 changes: 10 additions & 0 deletions NebulaWorld/Logistics/StationUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ private static void UpdateSettingsUI(StationComponent stationComponent, ref Stat
stationComponent.shipAutoReplenish = packet.SettingValue != 0;
break;
}
case StationUI.EUISettings.RemoteGroupMask:
{
stationComponent.remoteGroupMask = BitConverter.DoubleToInt64Bits(packet.SettingValue);
break;
}
case StationUI.EUISettings.RoutePriority:
{
stationComponent.routePriority = (ERemoteRoutePriority)packet.SettingValue;
break;
}
case StationUI.EUISettings.None:
break;
default:
Expand Down

0 comments on commit b5c2e37

Please sign in to comment.