// Parser apply event void IParserEventSubscriber.Apply(ConfigNode node) { // If we don't want an atmosphere, ignore this step if (!celestialBody.atmosphere || !addAFG) { return; } // If we don't already have an atmospheric shell generated if (scaledVersion.GetComponentsInChildren <AtmosphereFromGround> (true).Length == 0) { // Add the material light direction behavior MaterialSetDirection materialLightDirection = scaledVersion.AddComponent <MaterialSetDirection>(); materialLightDirection.valueName = "_localLightDirection"; // Create the atmosphere shell game object GameObject scaledAtmosphere = new GameObject("Atmosphere"); scaledAtmosphere.transform.parent = scaledVersion.transform; scaledAtmosphere.layer = Constants.GameLayers.ScaledSpaceAtmosphere; MeshRenderer renderer = scaledAtmosphere.AddComponent <MeshRenderer>(); renderer.sharedMaterial = new MaterialWrapper.AtmosphereFromGround(); MeshFilter meshFilter = scaledAtmosphere.AddComponent <MeshFilter>(); meshFilter.sharedMesh = Templates.ReferenceGeosphere; scaledAtmosphere.AddComponent <AtmosphereFromGround>(); // Store the AFG atmosphereFromGround = new AtmosphereFromGroundLoader(); // Setup known defaults celestialBody.atmospherePressureSeaLevel = 1.0f; } }
public AtmosphereLoader(CelestialBody body) { // Is this a spawned body? if (body?.scaledBody == null || Injector.IsInPrefab) { throw new InvalidOperationException("The body must be already spawned by the PSystemManager."); } // Store values Value = body; if (Value.afg) { atmosphereFromGround = new AtmosphereFromGroundLoader(Value); } }
// Parser apply event void IParserEventSubscriber.Apply(ConfigNode node) { // If we don't want an atmosphere, ignore this step if (!Value.atmosphere || !addAFG) { return; } // If we don't already have an atmospheric shell generated if (Value.scaledBody.GetComponentsInChildren <AtmosphereFromGround> (true).Length == 0) { // Setup known defaults Value.atmospherePressureSeaLevel = 1.0f; } // Create the AFG Loader atmosphereFromGround = new AtmosphereFromGroundLoader(); // Event Events.OnAtmosphereLoaderApply.Fire(this, node); }