Skip to content

Commit

Permalink
Release 69. Comet GameEvents.onNewVesselCreated nullref fix
Browse files Browse the repository at this point in the history
  • Loading branch information
R-T-B committed Jan 28, 2021
1 parent 04b9250 commit 996bbb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Kopernicus/Constants/CompatibilityChecker.cs
Expand Up @@ -65,7 +65,7 @@ public class CompatibilityChecker : MonoBehaviour
internal const Int32 VERSION_MINOR = 11;
internal const Int32 REVISION = 0;
#endif
internal const Int32 KOPERNICUS = 68;
internal const Int32 KOPERNICUS = 69;

public static Boolean IsCompatible()
{
Expand Down
21 changes: 5 additions & 16 deletions src/Kopernicus/RuntimeUtility/DiscoverableObjects.cs
Expand Up @@ -269,7 +269,7 @@ public void SpawnAsteroid(Asteroid asteroid, UInt32 seed)
}
else
{
float fragmentDynamicPressureModifier = 0f;
float fragmentDynamicPressureModifier = 0f;
bool optimizedCollider = false;
CometOrbitType cometType = CometManager.GenerateWeightedCometType();
Orbit cometOrbit = cometType.CalculateHomeOrbit();
Expand All @@ -282,24 +282,13 @@ public void SpawnAsteroid(Asteroid asteroid, UInt32 seed)
configNode.AddValue("cometPartId", value);
ConfigNode configNode3 = new ConfigNode("VESSELMODULES");
configNode3.AddNode(configNode);
vessel = ProtoVessel.CreateVesselNode(DiscoverableObjectsUtil.GenerateCometName(), VesselType.SpaceObject, cometOrbit, 0, new ConfigNode[1]
{
configNode2
}, new ConfigNode("ACTIONGROUPS"), ProtoVessel.CreateDiscoveryNode(DiscoveryLevels.Presence, randomObjClass, lifetime, maxLifetime), configNode3);
vessel = ProtoVessel.CreateVesselNode(DiscoverableObjectsUtil.GenerateCometName(), VesselType.SpaceObject, cometOrbit, 0, new ConfigNode[1] { configNode2 }, new ConfigNode("ACTIONGROUPS"), ProtoVessel.CreateDiscoveryNode(DiscoveryLevels.Presence, randomObjClass, lifetime, maxLifetime), configNode3);
OverrideNode(ref vessel, asteroid.Vessel);
ProtoVessel protoVessel = new ProtoVessel(vessel, HighLogic.CurrentGame);
try
{
Kopernicus.Events.OnRuntimeUtilitySpawnAsteroid.Fire(asteroid, protoVessel);
GameEvents.onNewVesselCreated.Fire(protoVessel.vesselRef);
GameEvents.onAsteroidSpawned.Fire(protoVessel.vesselRef);
}
catch
{
//I don't know why this is needed.
}
Kopernicus.Events.OnRuntimeUtilitySpawnAsteroid.Fire(asteroid, protoVessel);
protoVessel.Load(HighLogic.CurrentGame.flightState);

GameEvents.onNewVesselCreated.Fire(protoVessel.vesselRef);
GameEvents.onAsteroidSpawned.Fire(protoVessel.vesselRef);
Debug.Log("[Kopernicus] New object found near " + body.name + ": " + protoVessel.vesselName + "!");
}
#endif
Expand Down

0 comments on commit 996bbb9

Please sign in to comment.