Skip to content

Commit

Permalink
Merge pull request #500 from hubastard/fix-exploration
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomGamers authored Jan 15, 2022
2 parents 2324c64 + acf72f1 commit b22ea81
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## Changelog

0.8.0:
0.7.10:

- @starfish: Added WarningSystem syncing
- @PhantomGamers: Fixed case of NRE when arriving on another planet
- @PhantomGamers: Fixed issue where Universe Exploration tech would break while in a multiplayer game

0.7.9:

Expand Down
12 changes: 4 additions & 8 deletions NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace NebulaPatcher.Patches.Dynamic
[HarmonyPatch(typeof(UIPlanetDetail))]
internal class UIPlanetDetail_Patch
{
private static int BackupUniverseObserveLevel = -1;

[HarmonyPostfix]
[HarmonyPatch(nameof(UIPlanetDetail.OnNameInputEndEdit))]
public static void OnNameInputEndEdit_Postfix(UIPlanetDetail __instance)
Expand Down Expand Up @@ -58,10 +56,9 @@ public static bool _OnUpdate_Prefix(UIPlanetDetail __instance)
[HarmonyPatch(nameof(UIPlanetDetail.RefreshDynamicProperties))]
public static bool OnPlanetDataSet_Prefix(UIPlanetDetail __instance)
{
if(UIRoot.instance.galaxySelect.starmap.clickText != "")
if(Multiplayer.IsActive && Multiplayer.Session.IsInLobby)
{
BackupUniverseObserveLevel = GameMain.history.universeObserveLevel;
GameMain.history.universeObserveLevel = 3;
GameMain.history.universeObserveLevel = 4;
}
return true;
}
Expand All @@ -71,10 +68,9 @@ public static bool OnPlanetDataSet_Prefix(UIPlanetDetail __instance)
[HarmonyPatch(nameof(UIPlanetDetail.RefreshDynamicProperties))]
public static void OnPlanetDataSet_Postfix(UIPlanetDetail __instance)
{
if(BackupUniverseObserveLevel != -1)
if(Multiplayer.IsActive && Multiplayer.Session.IsInLobby)
{
GameMain.history.universeObserveLevel = BackupUniverseObserveLevel;
BackupUniverseObserveLevel = -1;
GameMain.history.universeObserveLevel = SimulatedWorld.GetUniverseObserveLevel();
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions NebulaWorld/MultiplayerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public void OnGameLoadCompleted()
Log.Info("Game load completed");
IsGameLoaded = true;

if (Multiplayer.Session.LocalPlayer.IsHost)
{
GameMain.history.universeObserveLevel = SimulatedWorld.GetUniverseObserveLevel();
}

if (Multiplayer.Session.LocalPlayer.IsInitialDataReceived)
{
Multiplayer.Session.World.SetupInitialPlayerState();
Expand Down
16 changes: 16 additions & 0 deletions NebulaWorld/SimulatedWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,5 +651,21 @@ public void SetPauseIndicator(bool canPause)
}

}

public static int GetUniverseObserveLevel()
{
int level = 0;
// the tech ids of the 4 tiers of Universe Exploration from https://dsp-wiki.com/Upgrades
for (int i = 4104; i >= 4101; i--)
{
if (GameMain.history.TechUnlocked(i))
{
// set level to last digit of tech id
level = (i % 10);
break;
}
}
return level;
}
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.7.9",
"version": "0.7.10",
"assemblyVersion": {
"precision": "build"
},
Expand Down

0 comments on commit b22ea81

Please sign in to comment.