Added all base code from MysteryPlanet project

This commit is contained in:
Mister_Nebula 2020-04-11 20:27:14 +01:00
parent 8bdd2e13bf
commit 3a8b625f94
21 changed files with 1018 additions and 24 deletions

View File

@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Marshmallow
{
public class Class1
{
}
}

138
Marshmallow/Main.cs Normal file
View File

@ -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<Flashlight>(Events.AfterStart);
IModEvents events = base.ModHelper.Events;
events.OnEvent = (Action<MonoBehaviour, Events>)Delegate.Combine(events.OnEvent, new Action<MonoBehaviour, Events>(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);
}
}
}

59
Marshmallow/MakeAir.cs Normal file
View File

@ -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<SphereCollider>();
atmoSC.isTrigger = true;
atmoSC.radius = airScale;
SimpleFluidVolume sfv = air.AddComponent<SimpleFluidVolume>();
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<VisorRainEffectVolume>();
vref.SetValue("_rainDirection", VisorRainEffectVolume.RainDirection.Radial);
vref.SetValue("_layer", 0);
vref.SetValue("_priority", 0);
AudioSource auds = air.AddComponent<AudioSource>();
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<OWAudioSource>();
owas.SetAudioLibraryClip(AudioType.GD_RainAmbient_LP);
owas.SetClipSelectionType(OWAudioSource.ClipSelectionOnPlay.RANDOM);
owas.SetTrack(OWAudioMixer.TrackName.Environment);
AudioVolume av = air.AddComponent<AudioVolume>();
}
air.SetActive(true);
}
}
}

View File

@ -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<Light>();
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<Light>().cookie;
SectorLightsCullGroup cg = light.AddComponent<SectorLightsCullGroup>();
cg.SetSector(Main.SECTOR);
light.SetActive(true);
}
}
}

View File

@ -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<MeshFilter>();
mf.mesh = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent<MeshFilter>().mesh;
MeshRenderer mr = fog.AddComponent<MeshRenderer>();
mr.materials = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent<MeshRenderer>().materials;
mr.allowOcclusionWhenDynamic = true;
PlanetaryFogController pfc = fog.AddComponent<PlanetaryFogController>();
pfc.fogLookupTexture = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent<PlanetaryFogController>().fogLookupTexture;
pfc.fogRadius = topCloudScale + 10;
pfc.fogDensity = fogDensity;
pfc.fogExponent = 1f;
pfc.fogColorRampTexture = GameObject.Find("Atmosphere_GD/FogSphere").GetComponent<PlanetaryFogController>().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<MeshRenderer>().material;
GameObject lod0 = new GameObject();
lod0.transform.parent = atmo.transform;
MeshFilter f0 = lod0.AddComponent<MeshFilter>();
f0.mesh = GameObject.Find("Atmosphere_LOD0").GetComponent<MeshFilter>().mesh;
MeshRenderer r0 = lod0.AddComponent<MeshRenderer>();
r0.material = mat;
GameObject lod1 = new GameObject();
lod0.transform.parent = atmo.transform;
MeshFilter f1 = lod1.AddComponent<MeshFilter>();
f1.mesh = GameObject.Find("Atmosphere_LOD1").GetComponent<MeshFilter>().mesh;
MeshRenderer r1 = lod1.AddComponent<MeshRenderer>();
r1.material = mat;
GameObject lod2 = new GameObject();
lod2.transform.parent = atmo.transform;
MeshFilter f2 = lod2.AddComponent<MeshFilter>();
f2.mesh = GameObject.Find("Atmosphere_LOD2").GetComponent<MeshFilter>().mesh;
MeshRenderer r2 = lod2.AddComponent<MeshRenderer>();
r2.material = mat;
GameObject lod3 = new GameObject();
lod3.transform.parent = atmo.transform;
MeshFilter f3 = lod3.AddComponent<MeshFilter>();
f3.mesh = GameObject.Find("Atmosphere_LOD3").GetComponent<MeshFilter>().mesh;
MeshRenderer r3 = lod3.AddComponent<MeshRenderer>();
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<LODGroup>();
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);
}
}
}

View File

@ -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<SectorCullGroup>();
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<ParticleSystem>());
VectionFieldEmitter vfe = rain.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 = rain.AddComponent<PlanetaryVectionController>();
pvc.SetValue("_followTarget", pvc.GetType().GetNestedType("FollowTarget", BindingFlags.NonPublic).GetField("Player").GetValue(pvc));
pvc.SetValue("_activeInSector", Main.SECTOR);
rain.GetComponent<Renderer>().material = GameObject.Find("Effects_GD_Rain").GetComponent<Renderer>().material;
main.SetActive(true);
rain.SetActive(true);
}
}
}

88
Marshmallow/MakeClouds.cs Normal file
View File

@ -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<MeshFilter>();
MF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
MeshRenderer MR = cloudsTop.AddComponent<MeshRenderer>();
MR.materials = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().materials;
RotateTransform RT = cloudsTop.AddComponent<RotateTransform>();
RT.SetValue("_localAxis", Vector3.up);
RT.SetValue("degreesPerSecond", 10);
RT.SetValue("randomizeRotationRate", false);
/*
SectorCullGroup scg = cloudsTop.AddComponent<SectorCullGroup>();
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<TessellatedSphereRenderer>();
TSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
TSR.sharedMaterials = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().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<TessSphereSectorToggle>();
TSST.SetValue("_sector", Main.SECTOR);
GameObject cloudsFluid = new GameObject();
cloudsFluid.layer = 17;
cloudsFluid.SetActive(false);
cloudsFluid.transform.parent = cloudsMain.transform;
SphereCollider cloudSC = cloudsFluid.AddComponent<SphereCollider>();
cloudSC.isTrigger = true;
cloudSC.radius = topCloudScale/2;
OWShellCollider cloudShell = cloudsFluid.AddComponent<OWShellCollider>();
cloudShell.SetValue("_innerRadius", bottomCloudScale);
CloudLayerFluidVolume cloudLayer = cloudsFluid.AddComponent<CloudLayerFluidVolume>();
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);
}
}
}

View File

@ -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<ConstantForceDetector>();
ForceVolume[] temp = new ForceVolume[1];
temp[0] = Locator.GetAstroObject(AstroObject.Name.Sun).GetGravityVolume();
CFD.SetValue("_detectableFields", temp);
CFD.SetValue("_inheritElement0", false);
FieldDetector.SetActive(true);
}
}
}

View File

@ -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<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
sphere.GetComponent<SphereCollider>().radius = 1f;
sphere.SetActive(true);
/*
GameObject sphere = new GameObject();
Debug.LogError("1");
sphere.SetActive(false);
Debug.LogError("2");
MeshFilter mf = sphere.AddComponent<MeshFilter>();
Debug.LogError("3");
mf.mesh = mesh;
Debug.LogError("4");
MeshRenderer mr = sphere.AddComponent<MeshRenderer>();
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<GameObject>("PLANET");
GameObject temp = GameObject.CreatePrimitive(PrimitiveType.Sphere);
geo.GetComponent<Renderer>().material = temp.GetComponent<Renderer>().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<MeshFilter>().mesh.name);
Debug.LogError(geo.transform.parent.name);
geo.SetActive(true);
*/
}
}
}

View File

@ -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<GravityVolume>();
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<SphereCollider>();
GV_SC.isTrigger = true;
GV_SC.radius = 4000;
OWCollider GV_OWC = GravityWell.AddComponent<OWCollider>();
GV_OWC.SetLODActivationMask(DynamicOccupant.Player);
GravityWell.SetActive(true);
return GV;
}
}
}

View File

@ -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<MapMarker>();
MM.SetValue("_labelID", UITextType.YouAreDeadMessage);
MM.SetValue("_markerType", MM.GetType().GetNestedType("MarkerType", BindingFlags.NonPublic).GetField("Planet").GetValue(MM));
}
}
}

View File

@ -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<Rigidbody>();
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<OWRigidbody>();
Main.OWRB.SetValue("_kinematicSimulation", true);
Main.OWRB.SetValue("_autoGenerateCenterOfMass", true);
Main.OWRB.SetIsTargetable(true);
Main.OWRB.SetValue("_maintainOriginalCenterOfMass", true);
InitialMotion IM = body.AddComponent<InitialMotion>();
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<AstroObject>();
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);
}
}
}
}

View File

@ -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<SphereCollider>();
RF_SC.isTrigger = true;
RF_SC.radius = 600f;
ReferenceFrameVolume RF_RFV = RFVolume.AddComponent<ReferenceFrameVolume>();
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);
}
}
}

35
Marshmallow/MakeSector.cs Normal file
View File

@ -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>();
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<OWTriggerVolume>();
Sector sector = sectorBase.AddComponent<Sector>();
sector.SetValue("_name", Sector.Name.InvisiblePlanet);
sector.SetValue("__attachedOWRigidbody", Main.OWRB);
sector.SetValue("_subsectors", new List<Sector>());
sectorBase.SetActive(true);
return sector;
}
}
}

View File

@ -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<SpawnPoint>();
}
}
}

View File

@ -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<GiantsDeepSunOverrideVolume>();
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);
}
}
}

View File

@ -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<SphereShape>();
ss.SetCollisionMode(Shape.CollisionMode.Volume);
ss.SetLayer(Shape.Layer.Sector);
ss.layerMask = -1;
ss.pointChecksOnly = true;
ss.radius = topCloudSize;
OWTriggerVolume trigvol = ruleset.AddComponent<OWTriggerVolume>();
PlanetoidRuleset prule = ruleset.AddComponent<PlanetoidRuleset>();
prule.SetValue("_altitudeFloor", groundSize);
prule.SetValue("_altitudeCeiling", topCloudSize);
EffectRuleset er = ruleset.AddComponent<EffectRuleset>();
er.SetValue("_type", EffectRuleset.BubbleType.Underwater);
er.SetValue("_material", GameObject.Find("RulesetVolumes_GD").GetComponent<RulesetVolume>().GetValue<Material>("_material"));
er.SetValue("_cloudMaterial", GameObject.Find("RulesetVolumes_GD").GetComponent<RulesetVolume>().GetValue<Material>("_cloudMaterial"));
volumes.SetActive(true);
}
}
}

59
Marshmallow/MakeWater.cs Normal file
View File

@ -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<SphereCollider>();
TessellatedSphereRenderer tsr = waterBase.AddComponent<TessellatedSphereRenderer>();
tsr.tessellationMeshGroup = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
tsr.sharedMaterials = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
tsr.maxLOD = 7;
tsr.LODBias = 2;
tsr.LODRadius = 2f;
TessSphereSectorToggle toggle = waterBase.AddComponent<TessSphereSectorToggle>();
toggle.SetValue("_sector", Main.SECTOR);
OceanEffectController effectC = waterBase.AddComponent<OceanEffectController>();
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<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
fog1.AddComponent<MeshRenderer>().material = new Material(Shader.Find("Sprites/Default"));
fog1.GetComponent<MeshRenderer>().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<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
fog2.AddComponent<MeshRenderer>().material = new Material(Shader.Find("Sprites/Default"));
fog2.GetComponent<MeshRenderer>().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<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
fog3.AddComponent<MeshRenderer>().material = new Material(Shader.Find("Sprites/Default"));
fog3.GetComponent<MeshRenderer>().material.color = new Color32(0, 75, 50, 5);
waterBase.SetActive(true);
Main.Log("Water - waterScale : " + waterScale);
}
}
}

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>6bde7833-a385-4a73-a121-8335d5e875c0</ProjectGuid> <ProjectGuid>{6BDE7833-A385-4A73-A121-8335D5E875C0}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Marshmallow</RootNamespace> <RootNamespace>Marshmallow</RootNamespace>
@ -31,20 +31,86 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System"/> <Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll</HintPath>
<Reference Include="System.Core"/> </Reference>
<Reference Include="System.Xml.Linq"/> <Reference Include="Assembly-CSharp">
<Reference Include="System.Data.DataSetExtensions"/> <HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="NAudio-Unity, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="System.Data"/> <HintPath>..\packages\OWML.0.3.43\lib\net35\NAudio-Unity.dll</HintPath>
</Reference>
<Reference Include="System.Xml"/> <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="OWML, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.43\lib\net35\OWML.dll</HintPath>
</Reference>
<Reference Include="OWML.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.43\lib\net35\OWML.Common.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Assets, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.Assets.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Events, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.Events.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Menus, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.43\lib\net35\OWML.ModHelper.Menus.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Networking">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.Networking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>E:\Epic\Epic Games\OuterWilds\OuterWilds_Data\Managed\UnityEngine.UIModule.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Class1.cs" /> <Compile Include="Class1.cs" />
<Compile Include="MakeAir.cs" />
<Compile Include="MakeAmbientLight.cs" />
<Compile Include="MakeAtmosphere.cs" />
<Compile Include="MakeBaseEffects.cs" />
<Compile Include="MakeClouds.cs" />
<Compile Include="MakeFieldDetector.cs" />
<Compile Include="MakeGravityWell.cs" />
<Compile Include="MakeMapMarker.cs" />
<Compile Include="MakeOrbitingAstroObject.cs" />
<Compile Include="MakeRFVolume.cs" />
<Compile Include="MakeSpawnPoint.cs" />
<Compile Include="MakeSunOverride.cs" />
<Compile Include="MakeVolumes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -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;
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Json.Net.Unity3D" version="9.0.1" targetFramework="net35" />
<package id="Lib.Harmony" version="1.2.0.1" targetFramework="net35" />
<package id="OWML" version="0.3.43" targetFramework="net35" />
</packages>