new-horizons/Marshmallow/Atmosphere/MakeBaseEffects.cs
Mister_Nebula dc23ac2de8 Massive rewrite
- Added moon support
- Rewrote every class for readability
- Rewrote Main class to simplify code (file planets now load on scene load)
2020-06-11 19:41:39 +01:00

48 lines
1.9 KiB
C#

using OWML.ModHelper.Events;
using System.Reflection;
using UnityEngine;
namespace Marshmallow.Atmosphere
{
static class MakeBaseEffects
{
public static void Make(GameObject body, Sector sector)
{
GameObject effectsGO = new GameObject();
effectsGO.SetActive(false);
effectsGO.transform.parent = body.transform;
SectorCullGroup SCG = effectsGO.AddComponent<SectorCullGroup>();
SCG.SetValue("_sector", sector);
SCG.SetValue("_particleSystemSuspendMode", CullGroup.ParticleSystemSuspendMode.Stop);
SCG.SetValue("_occlusionCulling", false);
SCG.SetValue("_dynamicCullingBounds", false);
SCG.SetValue("_waitForStreaming", false);
GameObject rainGO = new GameObject();
rainGO.SetActive(false);
rainGO.transform.parent = effectsGO.transform;
/*ParticleSystem ps = */GameObject.Instantiate(GameObject.Find("Effects_GD_Rain").GetComponent<ParticleSystem>());
VectionFieldEmitter VFE = rainGO.AddComponent<VectionFieldEmitter>();
VFE.fieldRadius = 20f;
VFE.particleCount = 10;
VFE.emitOnLeadingEdge = false;
VFE.emitDirection = VectionFieldEmitter.EmitDirection.Radial;
VFE.reverseDir = true;
VFE.SetValue("_affectingForces", new ForceVolume[0]);
VFE.SetValue("_applyForcePerParticle", false);
PlanetaryVectionController PVC = rainGO.AddComponent<PlanetaryVectionController>();
PVC.SetValue("_followTarget", PVC.GetType().GetNestedType("FollowTarget", BindingFlags.NonPublic).GetField("Player").GetValue(PVC));
PVC.SetValue("_activeInSector", sector);
rainGO.GetComponent<Renderer>().material = GameObject.Find("Effects_GD_Rain").GetComponent<Renderer>().material;
effectsGO.SetActive(true);
rainGO.SetActive(true);
}
}
}