Skip to content

Commit

Permalink
Always Rebuild Homes
Browse files Browse the repository at this point in the history
Fix bug / spacebar heating with expecting stock CommNet ScenarioModule to have a certain configuration.
Now destroys all CommNetHome objects every scene change.
  • Loading branch information
DRVeyl committed May 17, 2021
1 parent 6ac7431 commit 49f3c99
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/RealAntennasProject/RACommNetScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@ protected override void Start()

public override void OnAwake()
{
if (RealAntennas.Network.CommNetPatcher.GetCommNetScenarioModule() is ProtoScenarioModule psm)
if (RealAntennas.Network.CommNetPatcher.GetCommNetScenarioModule() is ProtoScenarioModule psm &&
!RealAntennas.Network.CommNetPatcher.CommNetPatched(psm))
{
Debug.Log($"{ModTag} Scenario check: Found {RATools.DisplayGamescenes(psm)}");
if (!RealAntennas.Network.CommNetPatcher.CommNetPatched(psm))
{
RealAntennas.Network.CommNetPatcher.UnloadCommNet();
DestroyNetwork();
RebuildHomes();
Debug.Log($"{ModTag} Ignore CommNetScenario ERR immediately following this.");
}
RealAntennas.Network.CommNetPatcher.UnloadCommNet();
DestroyNetwork();
Debug.Log($"{ModTag} Ignore CommNetScenario ERR immediately after Homes rebuild logging.");
}
RebuildHomes();
if (CommNetEnabled) // Don't self-delete if we are not enabled.
base.OnAwake(); // Will set CommNetScenario.Instance to this
}
Expand Down Expand Up @@ -141,12 +138,15 @@ private void BuildHomes()

private void UnloadHomes()
{
var logger = StringBuilderCache.Acquire();
logger.Append($"{ModTag} Unloaded the following homes: ");
foreach (CommNetHome home in FindObjectsOfType<CommNetHome>())
{
Debug.Log($"{ModTag} Immediately destroying {home}");
logger.Append($"{home} ");
DestroyImmediate(home);
}
GroundStations.Clear();
Debug.Log(logger.ToStringAndRelease());
}

private void BuildHome(ConfigNode node, CelestialBody body)
Expand Down

0 comments on commit 49f3c99

Please sign in to comment.