-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for syncing dark fog settings in lobby and combat setting…
…s screen.
- Loading branch information
Showing
6 changed files
with
154 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace NebulaModel.Packets.Session | ||
{ | ||
public class LobbyUpdateCombatValues | ||
{ | ||
public LobbyUpdateCombatValues() { } | ||
|
||
public LobbyUpdateCombatValues(CombatSettings combatSettings) | ||
{ | ||
CombatAggressiveness = combatSettings.aggressiveness; | ||
CombatInitialLevel = combatSettings.initialLevel; | ||
CombatInitialGrowth = combatSettings.initialGrowth; | ||
CombatInitialColonize = combatSettings.initialColonize; | ||
CombatMaxDensity = combatSettings.maxDensity; | ||
CombatGrowthSpeedFactor = combatSettings.growthSpeedFactor; | ||
CombatPowerThreatFactor = combatSettings.powerThreatFactor; | ||
CombatBattleThreatFactor = combatSettings.battleThreatFactor; | ||
CombatBattleExpFactor = combatSettings.battleExpFactor; | ||
} | ||
|
||
public float CombatAggressiveness { get; set; } | ||
public float CombatInitialLevel { get; set; } | ||
public float CombatInitialGrowth { get; set; } | ||
public float CombatInitialColonize { get; set; } | ||
public float CombatMaxDensity { get; set; } | ||
public float CombatGrowthSpeedFactor { get; set; } | ||
public float CombatPowerThreatFactor { get; set; } | ||
public float CombatBattleThreatFactor { get; set; } | ||
public float CombatBattleExpFactor { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
NebulaNetwork/PacketProcessors/Session/LobbyUpdateCombatValuesProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#region | ||
|
||
using NebulaAPI.Packets; | ||
using NebulaModel.Networking; | ||
using NebulaModel.Packets; | ||
using NebulaModel.Packets.Session; | ||
|
||
#endregion | ||
|
||
namespace NebulaNetwork.PacketProcessors.Session | ||
{ | ||
[RegisterPacketProcessor] | ||
internal class LobbyUpdateCombatValuesProcessor:PacketProcessor<LobbyUpdateCombatValues> | ||
Check warning on line 13 in NebulaNetwork/PacketProcessors/Session/LobbyUpdateCombatValuesProcessor.cs GitHub Actions / build (Debug)
Check warning on line 13 in NebulaNetwork/PacketProcessors/Session/LobbyUpdateCombatValuesProcessor.cs GitHub Actions / build (Debug)
Check warning on line 13 in NebulaNetwork/PacketProcessors/Session/LobbyUpdateCombatValuesProcessor.cs GitHub Actions / build (Release)
|
||
{ | ||
protected override void ProcessPacket(LobbyUpdateCombatValues packet, NebulaConnection conn) | ||
{ | ||
if (IsHost) | ||
{ | ||
return; | ||
} | ||
|
||
var gameDesc = UIRoot.instance.galaxySelect.gameDesc; | ||
if (!gameDesc.isPeaceMode) | ||
{ | ||
gameDesc.combatSettings.aggressiveness = packet.CombatAggressiveness; | ||
gameDesc.combatSettings.initialLevel = packet.CombatInitialLevel; | ||
gameDesc.combatSettings.initialGrowth = packet.CombatInitialGrowth; | ||
gameDesc.combatSettings.initialColonize = packet.CombatInitialColonize; | ||
gameDesc.combatSettings.maxDensity = packet.CombatMaxDensity; | ||
gameDesc.combatSettings.growthSpeedFactor = packet.CombatGrowthSpeedFactor; | ||
gameDesc.combatSettings.powerThreatFactor = packet.CombatPowerThreatFactor; | ||
gameDesc.combatSettings.battleThreatFactor = packet.CombatBattleThreatFactor; | ||
gameDesc.combatSettings.battleExpFactor = packet.CombatBattleExpFactor; | ||
} | ||
|
||
UIRoot.instance.galaxySelect.gameDesc = gameDesc; | ||
UIRoot.instance.galaxySelect.SetStarmapGalaxy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#region | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using HarmonyLib; | ||
using NebulaModel; | ||
using NebulaModel.Logger; | ||
using NebulaModel.Packets.Session; | ||
using NebulaPatcher.Patches.Transpilers; | ||
using NebulaWorld; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
#endregion | ||
|
||
namespace NebulaPatcher.Patches.Dynamic | ||
{ | ||
[HarmonyPatch(typeof(UICombatSettingsDF))] | ||
internal class UICombatSettingsDF_Patch | ||
{ | ||
[HarmonyPostfix] | ||
[HarmonyPatch(nameof(UICombatSettingsDF.ApplySettings))] | ||
public static void ApplySettings_Postfix(UICombatSettingsDF __instance) | ||
{ | ||
if (!Multiplayer.IsInMultiplayerMenu || !Multiplayer.Session.LocalPlayer.IsHost) | ||
{ | ||
return; | ||
} | ||
// syncing players are those who have not loaded into the game yet, so they might still be in the lobby. they need to check if this packet is relevant for them in the corresponding handler. | ||
// just remembered others cant be in game anyways when host ist still in lobby >.> | ||
using (Multiplayer.Session.Network.PlayerManager.GetSyncingPlayers(out var syncingPlayers)) | ||
{ | ||
foreach (var entry in syncingPlayers) | ||
{ | ||
entry.Key.SendPacket(new LobbyUpdateCombatValues(__instance.gameDesc.combatSettings)); | ||
} | ||
} | ||
using (Multiplayer.Session.Network.PlayerManager.GetPendingPlayers(out var pendingPlayers)) | ||
{ | ||
foreach (var entry in pendingPlayers) | ||
{ | ||
entry.Key.SendPacket(new LobbyUpdateCombatValues(__instance.gameDesc.combatSettings)); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters