Skip to content

Commit bc0ae18

Browse files
committed
Fix more cases of the OnLoad issue
1 parent 94bbbcb commit bc0ae18

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

Source/RocketSoundEnhancement/PartModules/RSE_Wheels.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public override void OnStart(StartState state)
3333
if (state == StartState.Editor || state == StartState.None)
3434
return;
3535

36+
// This likely doesn't work correctly with B9PS if it's trying to modify the module config
37+
if (part != null && part.partInfo != null && part.partInfo.partPrefab != null)
38+
{
39+
int moduleIndex = part.modules.IndexOf(this);
40+
var prefab = part.partInfo.partPrefab.modules[moduleIndex] as RSE_Wheels;
41+
offLoadVolumeScale = prefab.offLoadVolumeScale;
42+
}
43+
3644
base.OnStart(state);
3745

3846
moduleWheel = part.GetComponent<ModuleWheelBase>();
@@ -176,11 +184,8 @@ public override void OnLoad(ConfigNode node)
176184
{
177185
base.OnLoad(node);
178186

179-
if (part?.partInfo?.partPrefab != null)
187+
if (HighLogic.LoadedScene != GameScenes.LOADING)
180188
{
181-
int moduleIndex = part.modules.IndexOf(this);
182-
var prefab = part.partInfo.partPrefab.modules[moduleIndex] as RSE_Wheels;
183-
offLoadVolumeScale = prefab.offLoadVolumeScale;
184189
return;
185190
}
186191

Source/RocketSoundEnhancement/PartModules/ShipEffectsCollisions.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public override void OnStart(StartState state)
3232
if (state == StartState.Editor || state == StartState.None)
3333
return;
3434

35+
// This likely doesn't work correctly with B9PS if it's trying to modify the module config
36+
if (part != null && part.partInfo != null && part.partInfo.partPrefab != null)
37+
{
38+
int moduleIndex = part.modules.IndexOf(this);
39+
var prefab = part.partInfo.partPrefab.modules[moduleIndex] as ShipEffectsCollisions;
40+
41+
SoundLayerCollisionGroups = prefab.SoundLayerCollisionGroups;
42+
return;
43+
}
44+
3545
base.OnStart(state);
3646

3747
if (SoundLayerCollisionGroups.Count > 0)
@@ -120,12 +130,8 @@ public override void OnLoad(ConfigNode node)
120130
{
121131
base.OnLoad(node);
122132

123-
if (part?.partInfo?.partPrefab != null)
133+
if (HighLogic.LoadedScene != GameScenes.LOADING)
124134
{
125-
int moduleIndex = part.modules.IndexOf(this);
126-
var prefab = part.partInfo.partPrefab.modules[moduleIndex] as ShipEffectsCollisions;
127-
128-
SoundLayerCollisionGroups = prefab.SoundLayerCollisionGroups;
129135
return;
130136
}
131137

0 commit comments

Comments
 (0)