-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from Baldie-dev/master
Building on Remote Star system + unloading factories when client leaves star system
- Loading branch information
Showing
6 changed files
with
138 additions
and
2 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
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
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,75 @@ | ||
using HarmonyLib; | ||
using NebulaWorld; | ||
|
||
namespace NebulaPatcher.Patches.Dynamic | ||
{ | ||
[HarmonyPatch(typeof(PlanetData))] | ||
class PlanetData_Patch | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch("UnloadMeshes")] | ||
public static bool UnloadMeshes_Prefix(PlanetData __instance) | ||
{ | ||
//Host should not unload planet meshes, since he need to permorm all terrain operations | ||
if (SimulatedWorld.Initialized && LocalPlayer.IsMasterClient) | ||
{ | ||
//Do not unload meshes, just hide them so it is not visible | ||
UnloadVisuals(__instance); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch("UnloadData")] | ||
public static bool UnloadData_Prefix() | ||
{ | ||
//Host should not unload planet data, since he need to permorm all operations from users | ||
if (SimulatedWorld.Initialized && LocalPlayer.IsMasterClient) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public static void UnloadVisuals(PlanetData __instance) | ||
{ | ||
if (__instance.gameObject != null) | ||
{ | ||
__instance.gameObject.SetActive(false); | ||
} | ||
if (__instance.terrainMaterial != null) | ||
{ | ||
UnityEngine.Object.Destroy(__instance.terrainMaterial); | ||
__instance.terrainMaterial = null; | ||
} | ||
if (__instance.oceanMaterial != null) | ||
{ | ||
UnityEngine.Object.Destroy(__instance.oceanMaterial); | ||
__instance.oceanMaterial = null; | ||
} | ||
if (__instance.atmosMaterial != null) | ||
{ | ||
UnityEngine.Object.Destroy(__instance.atmosMaterial); | ||
__instance.atmosMaterial = null; | ||
} | ||
if (__instance.minimapMaterial != null) | ||
{ | ||
UnityEngine.Object.Destroy(__instance.minimapMaterial); | ||
__instance.minimapMaterial = null; | ||
} | ||
if (__instance.reformMaterial0 != null) | ||
{ | ||
UnityEngine.Object.Destroy(__instance.reformMaterial0); | ||
__instance.reformMaterial0 = null; | ||
} | ||
if (__instance.reformMaterial1 != null) | ||
{ | ||
UnityEngine.Object.Destroy(__instance.reformMaterial1); | ||
__instance.reformMaterial1 = null; | ||
} | ||
} | ||
} | ||
} |
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