diff --git a/Marshmallow/Class1.cs b/Marshmallow/Class1.cs deleted file mode 100644 index 90d4e45e..00000000 --- a/Marshmallow/Class1.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Marshmallow -{ - public class Class1 - { - } -} diff --git a/Marshmallow/Main.cs b/Marshmallow/Main.cs new file mode 100644 index 00000000..8542aa7d --- /dev/null +++ b/Marshmallow/Main.cs @@ -0,0 +1,138 @@ +using OWML.Common; +using OWML.ModHelper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace Marshmallow +{ + public class Main : ModBehaviour + { + GameObject generatedPlanet; + public static OWRigidbody OWRB; + public static Sector SECTOR; + public static SpawnPoint SPAWN; + + public static IModHelper helper; + + void Start() + { + base.ModHelper.Events.Subscribe(Events.AfterStart); + IModEvents events = base.ModHelper.Events; + events.OnEvent = (Action)Delegate.Combine(events.OnEvent, new Action(this.OnEvent)); + + helper = base.ModHelper; + } + + private void OnEvent(MonoBehaviour behaviour, Events ev) + { + bool flag = behaviour.GetType() == typeof(Flashlight) && ev == Events.AfterStart; + if (flag) + { + PlanetStructure inputStructure = new PlanetStructure + { + name = "invisibleplanet", + + primaryBody = Locator.GetAstroObject(AstroObject.Name.Sun), + aoType = AstroObject.Type.Planet, + aoName = AstroObject.Name.InvisiblePlanet, + + position = new Vector3(0, 0, 30000), + + makeSpawnPoint = true, + + hasClouds = true, + topCloudSize = 650f, + bottomCloudSize = 600f, + cloudTint = new Color32(0, 75, 15, 128), + + hasWater = true, + waterSize = 401f, + + hasRain = true, + + hasGravity = true, + surfaceAccel = 12f, + + hasMapMarker = true, + + hasFog = true, + fogTint = new Color32(0, 75, 15, 128), + fogDensity = 0.75f, + + hasOrbit = true + }; + + generatedPlanet = GenerateBody(inputStructure); + + if (inputStructure.primaryBody = Locator.GetAstroObject(AstroObject.Name.Sun)) + { + generatedPlanet.transform.parent = Locator.GetRootTransform(); + } + else + { + generatedPlanet.transform.parent = inputStructure.primaryBody.transform; + } + + generatedPlanet.transform.position = inputStructure.position; + generatedPlanet.SetActive(true); + } + } + + private GameObject GenerateBody(PlanetStructure planet) + { + float groundScale = 400f; + + GameObject body; + + body = new GameObject(); + body.name = planet.name; + body.SetActive(false); + + Body.MakeGeometry.Make(body, groundScale); + + General.MakeOrbitingAstroObject.Make(body, planet.primaryBody, 0.02f, planet.hasGravity, planet.surfaceAccel, groundScale); + General.MakeRFVolume.Make(body); + + if (planet.hasMapMarker) + { + General.MakeMapMarker.Make(body); + } + + SECTOR = Body.MakeSector.Make(body, planet.topCloudSize.Value); + + if (planet.hasClouds) + { + Atmosphere.MakeClouds.Make(body, planet.topCloudSize.Value, planet.bottomCloudSize.Value, planet.cloudTint.Value); + Atmosphere.MakeSunOverride.Make(body, planet.topCloudSize.Value, planet.bottomCloudSize.Value, planet.waterSize.Value); + } + + Atmosphere.MakeAir.Make(body, planet.topCloudSize.Value / 2, planet.hasRain); + + if (planet.hasWater) + { + Body.MakeWater.Make(body, planet.waterSize.Value); + } + + Atmosphere.MakeBaseEffects.Make(body); + Atmosphere.MakeVolumes.Make(body, groundScale, planet.topCloudSize.Value); + General.MakeAmbientLight.Make(body); + Atmosphere.MakeAtmosphere.Make(body, planet.topCloudSize.Value, planet.hasFog, planet.fogDensity, planet.fogTint); + + if (planet.makeSpawnPoint) + { + SPAWN = General.MakeSpawnPoint.Make(body, new Vector3(0, groundScale+10, 0)); + } + + return body; + } + + public static void Log(string text) + { + helper.Console.WriteLine("[Marshmallow] : " + text); + } + } +} diff --git a/Marshmallow/MakeAir.cs b/Marshmallow/MakeAir.cs new file mode 100644 index 00000000..0a68030f --- /dev/null +++ b/Marshmallow/MakeAir.cs @@ -0,0 +1,59 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.Atmosphere +{ + static class MakeAir + { + public static void Make(GameObject body, float airScale, bool isRaining) + { + GameObject air = new GameObject(); + air.layer = 17; + air.SetActive(false); + air.transform.parent = body.transform; + + SphereCollider atmoSC = air.AddComponent(); + atmoSC.isTrigger = true; + atmoSC.radius = airScale; + + SimpleFluidVolume sfv = air.AddComponent(); + sfv.SetValue("_layer", 5); + sfv.SetValue("_priority", 1); + sfv.SetValue("_density", 1.2f); + sfv.SetValue("_fluidType", FluidVolume.Type.AIR); + sfv.SetValue("_allowShipAutoroll", true); + sfv.SetValue("_disableOnStart", false); + + if (isRaining) + { + VisorRainEffectVolume vref = air.AddComponent(); + vref.SetValue("_rainDirection", VisorRainEffectVolume.RainDirection.Radial); + vref.SetValue("_layer", 0); + vref.SetValue("_priority", 0); + + AudioSource auds = air.AddComponent(); + auds.mute = false; + auds.bypassEffects = false; + auds.bypassListenerEffects = false; + auds.bypassReverbZones = false; + auds.playOnAwake = false; + auds.loop = true; + auds.priority = 128; + auds.volume = 0.35f; + auds.pitch = 1f; + auds.panStereo = 0f; + auds.spatialBlend = 0f; + auds.reverbZoneMix = 1f; + + OWAudioSource owas = air.AddComponent(); + owas.SetAudioLibraryClip(AudioType.GD_RainAmbient_LP); + owas.SetClipSelectionType(OWAudioSource.ClipSelectionOnPlay.RANDOM); + owas.SetTrack(OWAudioMixer.TrackName.Environment); + + AudioVolume av = air.AddComponent(); + } + + air.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeAmbientLight.cs b/Marshmallow/MakeAmbientLight.cs new file mode 100644 index 00000000..0ae0aa40 --- /dev/null +++ b/Marshmallow/MakeAmbientLight.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeAmbientLight + { + public static void Make(GameObject body) + { + GameObject light = new GameObject(); + light.SetActive(false); + light.transform.parent = body.transform; + Light l = light.AddComponent(); + l.type = LightType.Point; + l.range = 700f; + l.color = Color.red; + l.intensity = 0.8f; + l.shadows = LightShadows.None; + l.cookie = GameObject.Find("AmbientLight_GD").GetComponent().cookie; + + SectorLightsCullGroup cg = light.AddComponent(); + cg.SetSector(Main.SECTOR); + + light.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeAtmosphere.cs b/Marshmallow/MakeAtmosphere.cs new file mode 100644 index 00000000..0d2404f5 --- /dev/null +++ b/Marshmallow/MakeAtmosphere.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Marshmallow.Atmosphere +{ + static class MakeAtmosphere + { + public static void Make(GameObject body, float topCloudScale, bool hasFog, float fogDensity, Color fogTint) + { + topCloudScale /= 2; + + GameObject atmoM = new GameObject(); + atmoM.SetActive(false); + atmoM.name = "Atmosphere"; + atmoM.transform.parent = body.transform; + + if (hasFog) + { + GameObject fog = new GameObject(); + fog.SetActive(false); + fog.name = "FogSphere"; + fog.transform.parent = atmoM.transform; + fog.transform.localScale = new Vector3(topCloudScale + 10, topCloudScale + 10, topCloudScale + 10); + + MeshFilter mf = fog.AddComponent(); + mf.mesh = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent().mesh; + + MeshRenderer mr = fog.AddComponent(); + mr.materials = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent().materials; + mr.allowOcclusionWhenDynamic = true; + + PlanetaryFogController pfc = fog.AddComponent(); + pfc.fogLookupTexture = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent().fogLookupTexture; + pfc.fogRadius = topCloudScale + 10; + pfc.fogDensity = fogDensity; + pfc.fogExponent = 1f; + pfc.fogColorRampTexture = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent().fogColorRampTexture; + pfc.fogColorRampIntensity = 1f; + pfc.fogTint = fogTint; + + fog.SetActive(true); + } + + /* + GameObject atmo = new GameObject(); + atmo.SetActive(false); + atmo.transform.parent = atmoM.transform; + atmo.transform.localScale = new Vector3(topCloudScale + 100, topCloudScale + 100, topCloudScale + 100); + + Material mat = GameObject.Find("Atmosphere_LOD0").GetComponent().material; + + GameObject lod0 = new GameObject(); + lod0.transform.parent = atmo.transform; + MeshFilter f0 = lod0.AddComponent(); + f0.mesh = GameObject.Find("Atmosphere_LOD0").GetComponent().mesh; + MeshRenderer r0 = lod0.AddComponent(); + r0.material = mat; + + GameObject lod1 = new GameObject(); + lod0.transform.parent = atmo.transform; + MeshFilter f1 = lod1.AddComponent(); + f1.mesh = GameObject.Find("Atmosphere_LOD1").GetComponent().mesh; + MeshRenderer r1 = lod1.AddComponent(); + r1.material = mat; + + GameObject lod2 = new GameObject(); + lod2.transform.parent = atmo.transform; + MeshFilter f2 = lod2.AddComponent(); + f2.mesh = GameObject.Find("Atmosphere_LOD2").GetComponent().mesh; + MeshRenderer r2 = lod2.AddComponent(); + r2.material = mat; + + GameObject lod3 = new GameObject(); + lod3.transform.parent = atmo.transform; + MeshFilter f3 = lod3.AddComponent(); + f3.mesh = GameObject.Find("Atmosphere_LOD3").GetComponent().mesh; + MeshRenderer r3 = lod3.AddComponent(); + r3.material = mat; + + // THIS FUCKING THING. do NOT ask why i have done this. IT WORKS. + // This creates an LOD group in the worst way possible. i am so sorry. + LODGroup lodg = atmo.AddComponent(); + + LOD[] lodlist = new LOD[4]; + Renderer[] t0 = { r0 }; + Renderer[] t1 = { r1 }; + Renderer[] t2 = { r2 }; + Renderer[] t3 = { r3 }; + LOD one = new LOD(1, t0); + LOD two = new LOD(0.7f, t1); + LOD three = new LOD(0.27f, t2); + LOD four = new LOD(0.08f, t3); + lodlist[0] = one; + lodlist[1] = two; + lodlist[2] = three; + lodlist[3] = four; + + lodg.SetLODs(lodlist); + lodg.fadeMode = LODFadeMode.None; + */ + + //atmo.SetActive(true); + atmoM.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeBaseEffects.cs b/Marshmallow/MakeBaseEffects.cs new file mode 100644 index 00000000..f6bd948a --- /dev/null +++ b/Marshmallow/MakeBaseEffects.cs @@ -0,0 +1,51 @@ +using OWML.ModHelper.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using UnityEngine; + +namespace Marshmallow.Atmosphere +{ + static class MakeBaseEffects + { + public static void Make(GameObject body) + { + GameObject main = new GameObject(); + main.SetActive(false); + main.transform.parent = body.transform; + + SectorCullGroup maincull = main.AddComponent(); + maincull.SetValue("_sector", Main.SECTOR); + maincull.SetValue("_particleSystemSuspendMode", CullGroup.ParticleSystemSuspendMode.Stop); + maincull.SetValue("_occlusionCulling", false); + maincull.SetValue("_dynamicCullingBounds", false); + maincull.SetValue("_waitForStreaming", false); + + GameObject rain = new GameObject(); + rain.SetActive(false); + rain.transform.parent = main.transform; + + ParticleSystem ps = GameObject.Instantiate(GameObject.Find("Effects_GD_Rain").GetComponent()); + + VectionFieldEmitter vfe = rain.AddComponent(); + 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 = rain.AddComponent(); + pvc.SetValue("_followTarget", pvc.GetType().GetNestedType("FollowTarget", BindingFlags.NonPublic).GetField("Player").GetValue(pvc)); + pvc.SetValue("_activeInSector", Main.SECTOR); + + rain.GetComponent().material = GameObject.Find("Effects_GD_Rain").GetComponent().material; + + main.SetActive(true); + rain.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeClouds.cs b/Marshmallow/MakeClouds.cs new file mode 100644 index 00000000..c8625e1c --- /dev/null +++ b/Marshmallow/MakeClouds.cs @@ -0,0 +1,88 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.Atmosphere +{ + static class MakeClouds + { + public static void Make(GameObject body, float topCloudScale, float bottomCloudScale, Color? cloudTint = null) + { + GameObject cloudsMain = new GameObject(); + cloudsMain.SetActive(false); + cloudsMain.transform.parent = body.transform; + + GameObject cloudsTop = new GameObject(); + cloudsTop.SetActive(false); + cloudsTop.transform.parent = cloudsMain.transform; + cloudsTop.transform.localScale = new Vector3(topCloudScale/2, topCloudScale/2, topCloudScale/2); + + MeshFilter MF = cloudsTop.AddComponent(); + MF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent().mesh; + + MeshRenderer MR = cloudsTop.AddComponent(); + MR.materials = GameObject.Find("CloudsTopLayer_GD").GetComponent().materials; + + RotateTransform RT = cloudsTop.AddComponent(); + RT.SetValue("_localAxis", Vector3.up); + RT.SetValue("degreesPerSecond", 10); + RT.SetValue("randomizeRotationRate", false); + + /* + SectorCullGroup scg = cloudsTop.AddComponent(); + scg.SetValue("_sector", MainClass.SECTOR); + scg.SetValue("_occlusionCulling", true); + scg.SetValue("_dynamicCullingBounds", false); + scg.SetValue("_particleSystemSuspendMode", CullGroup.ParticleSystemSuspendMode.Pause); + scg.SetValue("_waitForStreaming", false); + */ + + GameObject cloudsBottom = new GameObject(); + cloudsBottom.SetActive(false); + cloudsBottom.transform.parent = cloudsMain.transform; + cloudsBottom.transform.localScale = new Vector3(bottomCloudScale/2, bottomCloudScale/2, bottomCloudScale/2); + + TessellatedSphereRenderer TSR = cloudsBottom.AddComponent(); + TSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_GD").GetComponent().tessellationMeshGroup; + TSR.sharedMaterials = GameObject.Find("CloudsBottomLayer_GD").GetComponent().sharedMaterials; + + foreach (var item in TSR.sharedMaterials) + { + item.SetColor("_Color", cloudTint.Value); + } + + TSR.maxLOD = 6; + TSR.LODBias = 0; + TSR.LODRadius = 1f; + + TessSphereSectorToggle TSST = cloudsBottom.AddComponent(); + TSST.SetValue("_sector", Main.SECTOR); + + GameObject cloudsFluid = new GameObject(); + cloudsFluid.layer = 17; + cloudsFluid.SetActive(false); + cloudsFluid.transform.parent = cloudsMain.transform; + + SphereCollider cloudSC = cloudsFluid.AddComponent(); + cloudSC.isTrigger = true; + cloudSC.radius = topCloudScale/2; + + OWShellCollider cloudShell = cloudsFluid.AddComponent(); + cloudShell.SetValue("_innerRadius", bottomCloudScale); + + CloudLayerFluidVolume cloudLayer = cloudsFluid.AddComponent(); + cloudLayer.SetValue("_layer", 5); + cloudLayer.SetValue("_priority", 1); + cloudLayer.SetValue("_density", 1.2f); + cloudLayer.SetValue("_fluidType", FluidVolume.Type.CLOUD); + cloudLayer.SetValue("_allowShipAutoroll", true); + cloudLayer.SetValue("_disableOnStart", false); + + cloudsTop.SetActive(true); + cloudsBottom.SetActive(true); + cloudsFluid.SetActive(true); + cloudsMain.SetActive(true); + + Main.Log("Clouds - topCloudScale : " + topCloudScale + ", bottomCloudScale : " + bottomCloudScale + ", cloudTint : " + cloudTint); + } + } +} diff --git a/Marshmallow/MakeFieldDetector.cs b/Marshmallow/MakeFieldDetector.cs new file mode 100644 index 00000000..51473027 --- /dev/null +++ b/Marshmallow/MakeFieldDetector.cs @@ -0,0 +1,24 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeFieldDetector + { + public static void Make(GameObject body) + { + GameObject FieldDetector = new GameObject(); + FieldDetector.SetActive(false); + FieldDetector.name = "FieldDetector"; + FieldDetector.transform.parent = body.transform; + FieldDetector.layer = 20; + + ConstantForceDetector CFD = FieldDetector.AddComponent(); + ForceVolume[] temp = new ForceVolume[1]; + temp[0] = Locator.GetAstroObject(AstroObject.Name.Sun).GetGravityVolume(); + CFD.SetValue("_detectableFields", temp); + CFD.SetValue("_inheritElement0", false); + FieldDetector.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeGeometry.cs b/Marshmallow/MakeGeometry.cs new file mode 100644 index 00000000..ea21daaa --- /dev/null +++ b/Marshmallow/MakeGeometry.cs @@ -0,0 +1,60 @@ +using OWML.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Marshmallow.Body +{ + static class MakeGeometry + { + public static void Make(GameObject body, float groundScale) + { + + + GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); + sphere.transform.parent = body.transform; + sphere.transform.localScale = new Vector3(groundScale / 2, groundScale / 2, groundScale / 2); + sphere.GetComponent().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent().mesh; + sphere.GetComponent().radius = 1f; + sphere.SetActive(true); + + /* + GameObject sphere = new GameObject(); + Debug.LogError("1"); + sphere.SetActive(false); + Debug.LogError("2"); + MeshFilter mf = sphere.AddComponent(); + Debug.LogError("3"); + mf.mesh = mesh; + Debug.LogError("4"); + MeshRenderer mr = sphere.AddComponent(); + Debug.LogError("5"); + mr.material = new Material(Shader.Find("Standard")); + Debug.LogError("6"); + sphere.transform.parent = body.transform; + Debug.LogError("7"); + sphere.transform.localScale = new Vector3(groundScale / 2, groundScale / 2, groundScale / 2); + Debug.LogError("8"); + sphere.SetActive(true); + Debug.LogError("9"); + */ + + /* + var geo = MainClass.assetBundle.LoadAsset("PLANET"); + GameObject temp = GameObject.CreatePrimitive(PrimitiveType.Sphere); + geo.GetComponent().material = temp.GetComponent().material; + GameObject.Destroy(temp); + geo.transform.parent = body.transform; + geo.transform.localScale = new Vector3(1,1,1); + geo.transform.localPosition = new Vector3(0, 0, 0); + Debug.LogError(geo.name); + Debug.LogError(geo.GetComponent().mesh.name); + Debug.LogError(geo.transform.parent.name); + geo.SetActive(true); + + */ + } + } +} diff --git a/Marshmallow/MakeGravityWell.cs b/Marshmallow/MakeGravityWell.cs new file mode 100644 index 00000000..16c1e45f --- /dev/null +++ b/Marshmallow/MakeGravityWell.cs @@ -0,0 +1,41 @@ +using OWML.ModHelper.Events; +using System.Reflection; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeGravityWell + { + public static GravityVolume Make(GameObject body, float surfaceAccel, float upperSurface, float lowerSurface) + { + GameObject GravityWell = new GameObject(); + GravityWell.transform.parent = body.transform; + GravityWell.name = "GravityWell"; + GravityWell.layer = 17; + GravityWell.SetActive(false); + + GravityVolume GV = GravityWell.AddComponent(); + GV.SetValue("_cutoffAcceleration", 0.1f); + GV.SetValue("_falloffType", GV.GetType().GetNestedType("FalloffType", BindingFlags.NonPublic).GetField("linear").GetValue(GV)); + GV.SetValue("_alignmentRadius", 600f); + GV.SetValue("_upperSurfaceRadius", upperSurface); + GV.SetValue("_lowerSurfaceRadius", lowerSurface); + GV.SetValue("_layer", 3); + GV.SetValue("_priority", 0); + GV.SetValue("_alignmentPriority", 0); + GV.SetValue("_surfaceAcceleration", surfaceAccel); + GV.SetValue("_inheritable", false); + GV.SetValue("_isPlanetGravityVolume", true); + GV.SetValue("_cutoffRadius", 55f); + + SphereCollider GV_SC = GravityWell.AddComponent(); + GV_SC.isTrigger = true; + GV_SC.radius = 4000; + + OWCollider GV_OWC = GravityWell.AddComponent(); + GV_OWC.SetLODActivationMask(DynamicOccupant.Player); + GravityWell.SetActive(true); + return GV; + } + } +} diff --git a/Marshmallow/MakeMapMarker.cs b/Marshmallow/MakeMapMarker.cs new file mode 100644 index 00000000..cf7f4f52 --- /dev/null +++ b/Marshmallow/MakeMapMarker.cs @@ -0,0 +1,16 @@ +using OWML.ModHelper.Events; +using System.Reflection; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeMapMarker + { + public static void Make(GameObject body) + { + var MM = body.AddComponent(); + MM.SetValue("_labelID", UITextType.YouAreDeadMessage); + MM.SetValue("_markerType", MM.GetType().GetNestedType("MarkerType", BindingFlags.NonPublic).GetField("Planet").GetValue(MM)); + } + } +} diff --git a/Marshmallow/MakeOrbitingAstroObject.cs b/Marshmallow/MakeOrbitingAstroObject.cs new file mode 100644 index 00000000..d50f4c78 --- /dev/null +++ b/Marshmallow/MakeOrbitingAstroObject.cs @@ -0,0 +1,52 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeOrbitingAstroObject + { + public static void Make(GameObject body, AstroObject primaryBody, float angularSpeed, bool hasGravity, float surfaceAccel, float groundSize) + { + Rigidbody RB = body.AddComponent(); + RB.mass = 10000; + RB.drag = 0f; + RB.angularDrag = 0f; + RB.useGravity = false; + RB.isKinematic = true; + RB.interpolation = RigidbodyInterpolation.None; + RB.collisionDetectionMode = CollisionDetectionMode.Discrete; + + Main.OWRB = body.AddComponent(); + Main.OWRB.SetValue("_kinematicSimulation", true); + Main.OWRB.SetValue("_autoGenerateCenterOfMass", true); + Main.OWRB.SetIsTargetable(true); + Main.OWRB.SetValue("_maintainOriginalCenterOfMass", true); + + InitialMotion IM = body.AddComponent(); + IM.SetPrimaryBody(primaryBody.GetAttachedOWRigidbody()); + IM.SetValue("_orbitAngle", 0f); + IM.SetValue("_isGlobalAxis", false); + IM.SetValue("_initAngularSpeed", angularSpeed); + IM.SetValue("_initLinearSpeed", 0f); + IM.SetValue("_isGlobalAxis", false); + + MakeFieldDetector.Make(body); + + if (hasGravity) + { + GravityVolume GV = MakeGravityWell.Make(body, surfaceAccel, groundSize, groundSize); + } + + + AstroObject AO = body.AddComponent(); + AO.SetValue("_type", AstroObject.Type.Planet); + AO.SetValue("_name", AstroObject.Name.InvisiblePlanet); + AO.SetPrimaryBody(primaryBody); + if (hasGravity) + { + GravityVolume GV = MakeGravityWell.Make(body, surfaceAccel, groundSize, groundSize); + AO.SetValue("_gravityVolume", GV); + } + } + } +} diff --git a/Marshmallow/MakeRFVolume.cs b/Marshmallow/MakeRFVolume.cs new file mode 100644 index 00000000..f71031d2 --- /dev/null +++ b/Marshmallow/MakeRFVolume.cs @@ -0,0 +1,39 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeRFVolume + { + public static void Make(GameObject body) + { + GameObject RFVolume = new GameObject(); + RFVolume.name = "RFVolume"; + RFVolume.transform.parent = body.transform; + RFVolume.layer = 19; + RFVolume.SetActive(false); + + SphereCollider RF_SC = RFVolume.AddComponent(); + RF_SC.isTrigger = true; + RF_SC.radius = 600f; + + ReferenceFrameVolume RF_RFV = RFVolume.AddComponent(); + ReferenceFrame test = new ReferenceFrame(Main.OWRB); + test.SetValue("_minSuitTargetDistance", 300); + test.SetValue("_maxTargetDistance", 0); + test.SetValue("_autopilotArrivalDistance", 1000); + test.SetValue("_autoAlignmentDistance", 1000); + test.SetValue("_hideLandingModePrompt", false); + test.SetValue("_matchAngularVelocity", true); + test.SetValue("_minMatchAngularVelocityDistance", 70); + test.SetValue("_maxMatchAngularVelocityDistance", 400); + test.SetValue("_bracketsRadius", 300); + RF_RFV.SetValue("_referenceFrame", test); + RF_RFV.SetValue("_minColliderRadius", 300); + RF_RFV.SetValue("_maxColliderRadius", 2000); + RF_RFV.SetValue("_isPrimaryVolume", true); + RF_RFV.SetValue("_isCloseRangeVolume", false); + RFVolume.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeSector.cs b/Marshmallow/MakeSector.cs new file mode 100644 index 00000000..6003e072 --- /dev/null +++ b/Marshmallow/MakeSector.cs @@ -0,0 +1,35 @@ +using OWML.ModHelper.Events; +using System.Collections.Generic; +using UnityEngine; + +namespace Marshmallow.Body +{ + static class MakeSector + { + public static Sector Make(GameObject body, float sectorSize) + { + GameObject sectorBase = new GameObject(); + sectorBase.SetActive(false); + sectorBase.transform.parent = body.transform; + + SphereShape sphereshape = sectorBase.AddComponent(); + sphereshape.SetCollisionMode(Shape.CollisionMode.Volume); + sphereshape.SetLayer(Shape.Layer.Sector); + sphereshape.layerMask = -1; + sphereshape.pointChecksOnly = true; + sphereshape.radius = 700f; + sphereshape.center = Vector3.zero; + + OWTriggerVolume trigVol = sectorBase.AddComponent(); + + Sector sector = sectorBase.AddComponent(); + sector.SetValue("_name", Sector.Name.InvisiblePlanet); + sector.SetValue("__attachedOWRigidbody", Main.OWRB); + sector.SetValue("_subsectors", new List()); + + sectorBase.SetActive(true); + + return sector; + } + } +} diff --git a/Marshmallow/MakeSpawnPoint.cs b/Marshmallow/MakeSpawnPoint.cs new file mode 100644 index 00000000..921b69af --- /dev/null +++ b/Marshmallow/MakeSpawnPoint.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Marshmallow.General +{ + static class MakeSpawnPoint + { + public static SpawnPoint Make(GameObject body, Vector3 position) + { + GameObject spawn = new GameObject(); + spawn.transform.parent = body.transform; + spawn.layer = 8; + + spawn.transform.localPosition = position; + + Main.Log("Made spawnpoint on [" + body.name + "] at " + position); + + return spawn.AddComponent(); + } + } +} diff --git a/Marshmallow/MakeSunOverride.cs b/Marshmallow/MakeSunOverride.cs new file mode 100644 index 00000000..7082236e --- /dev/null +++ b/Marshmallow/MakeSunOverride.cs @@ -0,0 +1,24 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.Atmosphere +{ + static class MakeSunOverride + { + public static void Make(GameObject body, float topCloudScale, float bottomCloudScale, float waterSize) + { + GameObject sunov = new GameObject(); + sunov.SetActive(false); + sunov.transform.parent = body.transform; + + GiantsDeepSunOverrideVolume vol = sunov.AddComponent(); + vol.SetValue("_sector", Main.SECTOR); + vol.SetValue("_cloudsOuterRadius", topCloudScale/2); + vol.SetValue("_cloudsInnerRadius", bottomCloudScale/2); + vol.SetValue("_waterOuterRadius", waterSize/2); + vol.SetValue("_waterInnerRadius", 402.5f); + + sunov.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeVolumes.cs b/Marshmallow/MakeVolumes.cs new file mode 100644 index 00000000..49654a8d --- /dev/null +++ b/Marshmallow/MakeVolumes.cs @@ -0,0 +1,42 @@ +using OWML.ModHelper.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Marshmallow.Atmosphere +{ + static class MakeVolumes + { + public static void Make(GameObject body, float groundSize, float topCloudSize) + { + GameObject volumes = new GameObject(); + volumes.SetActive(false); + volumes.transform.parent = body.transform; + + GameObject ruleset = new GameObject(); + ruleset.transform.parent = volumes.transform; + + SphereShape ss = ruleset.AddComponent(); + ss.SetCollisionMode(Shape.CollisionMode.Volume); + ss.SetLayer(Shape.Layer.Sector); + ss.layerMask = -1; + ss.pointChecksOnly = true; + ss.radius = topCloudSize; + + OWTriggerVolume trigvol = ruleset.AddComponent(); + + PlanetoidRuleset prule = ruleset.AddComponent(); + prule.SetValue("_altitudeFloor", groundSize); + prule.SetValue("_altitudeCeiling", topCloudSize); + + EffectRuleset er = ruleset.AddComponent(); + er.SetValue("_type", EffectRuleset.BubbleType.Underwater); + er.SetValue("_material", GameObject.Find("RulesetVolumes_GD").GetComponent().GetValue("_material")); + er.SetValue("_cloudMaterial", GameObject.Find("RulesetVolumes_GD").GetComponent().GetValue("_cloudMaterial")); + + volumes.SetActive(true); + } + } +} diff --git a/Marshmallow/MakeWater.cs b/Marshmallow/MakeWater.cs new file mode 100644 index 00000000..b277e5c0 --- /dev/null +++ b/Marshmallow/MakeWater.cs @@ -0,0 +1,59 @@ +using OWML.ModHelper.Events; +using UnityEngine; + +namespace Marshmallow.Body +{ + static class MakeWater + { + public static void Make(GameObject body, float waterScale) + { + GameObject waterBase = new GameObject(); + waterBase.SetActive(false); + waterBase.layer = 15; + waterBase.transform.parent = body.transform; + waterBase.transform.localScale = new Vector3(waterScale / 2, waterScale / 2, waterScale / 2); + waterBase.DestroyAllComponents(); + + TessellatedSphereRenderer tsr = waterBase.AddComponent(); + tsr.tessellationMeshGroup = GameObject.Find("Ocean_GD").GetComponent().tessellationMeshGroup; + tsr.sharedMaterials = GameObject.Find("Ocean_GD").GetComponent().sharedMaterials; + tsr.maxLOD = 7; + tsr.LODBias = 2; + tsr.LODRadius = 2f; + + TessSphereSectorToggle toggle = waterBase.AddComponent(); + toggle.SetValue("_sector", Main.SECTOR); + + OceanEffectController effectC = waterBase.AddComponent(); + effectC.SetValue("_sector", Main.SECTOR); + effectC.SetValue("_ocean", tsr); + + // Because assetbundles were a bitch... + + GameObject fog1 = new GameObject(); + fog1.transform.parent = waterBase.transform; + fog1.transform.localScale = new Vector3(1,1,1); + fog1.AddComponent().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent().mesh; + fog1.AddComponent().material = new Material(Shader.Find("Sprites/Default")); + fog1.GetComponent().material.color = new Color32(0, 75, 50, 5); + + GameObject fog2 = new GameObject(); + fog2.transform.parent = waterBase.transform; + fog2.transform.localScale = new Vector3(1.001f, 1.001f, 1.001f); + fog2.AddComponent().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent().mesh; + fog2.AddComponent().material = new Material(Shader.Find("Sprites/Default")); + fog2.GetComponent().material.color = new Color32(0, 75, 50, 5); + + GameObject fog3 = new GameObject(); + fog3.transform.parent = fog2.transform; + fog3.transform.localScale = new Vector3(1.001f, 1.001f, 1.001f); + fog3.AddComponent().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent().mesh; + fog3.AddComponent().material = new Material(Shader.Find("Sprites/Default")); + fog3.GetComponent().material.color = new Color32(0, 75, 50, 5); + + waterBase.SetActive(true); + + Main.Log("Water - waterScale : " + waterScale); + } + } +} diff --git a/Marshmallow/Marshmallow.csproj b/Marshmallow/Marshmallow.csproj index c4498a56..4b6ac830 100644 --- a/Marshmallow/Marshmallow.csproj +++ b/Marshmallow/Marshmallow.csproj @@ -1,10 +1,10 @@ - + Debug AnyCPU - 6bde7833-a385-4a73-a121-8335d5e875c0 + {6BDE7833-A385-4A73-A121-8335D5E875C0} Library Properties Marshmallow @@ -31,20 +31,86 @@ 4 - - - - - - - - - - + + ..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\Assembly-CSharp.dll + + + ..\packages\OWML.0.3.43\lib\net35\NAudio-Unity.dll + + + ..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll + + + ..\packages\OWML.0.3.43\lib\net35\OWML.dll + + + ..\packages\OWML.0.3.43\lib\net35\OWML.Common.dll + + + ..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.dll + + + ..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.Assets.dll + + + ..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.Events.dll + + + ..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.Menus.dll + + + + + + + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.AudioModule.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.IMGUIModule.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.Networking.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.ParticleSystemModule.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll + + + E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.UIModule.dll + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/Marshmallow/PlanetStructure.cs b/Marshmallow/PlanetStructure.cs new file mode 100644 index 00000000..ee584501 --- /dev/null +++ b/Marshmallow/PlanetStructure.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace Marshmallow +{ + public class PlanetStructure + { + public string name; + + public AstroObject primaryBody; + public AstroObject.Type aoType; + public AstroObject.Name aoName; + + public Vector3 position; + + public bool makeSpawnPoint = false; + + public bool hasClouds = false; + public float? topCloudSize = null; + public float? bottomCloudSize = null; + public Color? cloudTint = null; + + public bool hasWater = false; + public float? waterSize = null; + + public bool hasRain = false; + + public bool hasGravity = false; + public float surfaceAccel = 1f; + + public bool hasMapMarker = false; + + public bool hasFog = false; + public Color fogTint = Color.white; + public float fogDensity = 0.3f; + + public bool hasOrbit = false; + } +} diff --git a/Marshmallow/packages.config b/Marshmallow/packages.config new file mode 100644 index 00000000..3cacfe77 --- /dev/null +++ b/Marshmallow/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file