mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge pull request #22 from xen-42/planetary-features
Planetary features
This commit is contained in:
commit
e2df5b8151
@ -38,12 +38,7 @@ namespace NewHorizons.Atmosphere
|
|||||||
PFC.fogExponent = 1f;
|
PFC.fogExponent = 1f;
|
||||||
PFC.fogColorRampTexture = dbPlanetaryFogController.fogColorRampTexture;
|
PFC.fogColorRampTexture = dbPlanetaryFogController.fogColorRampTexture;
|
||||||
PFC.fogColorRampIntensity = 1f;
|
PFC.fogColorRampIntensity = 1f;
|
||||||
var adjustedColour = atmo.FogTint.ToColor32();
|
PFC.fogTint = atmo.FogTint.ToColor();
|
||||||
adjustedColour.r = (byte)(adjustedColour.r * atmo.FogDensity);
|
|
||||||
adjustedColour.g = (byte)(adjustedColour.g * atmo.FogDensity);
|
|
||||||
adjustedColour.b = (byte)(adjustedColour.b * atmo.FogDensity);
|
|
||||||
adjustedColour.a = (byte)(adjustedColour.a * atmo.FogDensity);
|
|
||||||
PFC.fogTint = atmo.FogTint.ToColor32();
|
|
||||||
|
|
||||||
GameObject lodFogGO = new GameObject("LODFogSphere");
|
GameObject lodFogGO = new GameObject("LODFogSphere");
|
||||||
lodFogGO.SetActive(false);
|
lodFogGO.SetActive(false);
|
||||||
@ -55,7 +50,7 @@ namespace NewHorizons.Atmosphere
|
|||||||
|
|
||||||
MeshRenderer lodMR = lodFogGO.AddComponent<MeshRenderer>();
|
MeshRenderer lodMR = lodFogGO.AddComponent<MeshRenderer>();
|
||||||
lodMR.material = new Material(brambleLODFog.GetComponent<MeshRenderer>().material);
|
lodMR.material = new Material(brambleLODFog.GetComponent<MeshRenderer>().material);
|
||||||
lodMR.material.color = atmo.FogTint.ToColor32();
|
lodMR.material.color = atmo.FogTint.ToColor();
|
||||||
lodMR.material.renderQueue = 1000;
|
lodMR.material.renderQueue = 1000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
var cubeSphereMR = icosphere.AddComponent<MeshRenderer>();
|
var cubeSphereMR = icosphere.AddComponent<MeshRenderer>();
|
||||||
cubeSphereMR.material = new Material(Shader.Find("Standard"));
|
cubeSphereMR.material = new Material(Shader.Find("Standard"));
|
||||||
cubeSphereMR.material.color = module.Color.ToColor32();
|
cubeSphereMR.material.color = module.Color.ToColor();
|
||||||
|
|
||||||
var cubeSphereMC = icosphere.AddComponent<MeshCollider>();
|
var cubeSphereMC = icosphere.AddComponent<MeshCollider>();
|
||||||
cubeSphereMC.sharedMesh = mesh;
|
cubeSphereMC.sharedMesh = mesh;
|
||||||
|
|||||||
@ -71,7 +71,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
// Enable all children or something
|
// Enable all children or something
|
||||||
var enabledField = component.GetType().GetField("enabled");
|
var enabledField = component.GetType().GetField("enabled");
|
||||||
if (enabledField != null && enabledField.FieldType == typeof(bool)) enabledField.SetValue(component, true);
|
if (enabledField != null && enabledField.FieldType == typeof(bool)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => enabledField.SetValue(component, true));
|
||||||
|
|
||||||
// TODO: Make this work or smthng
|
// TODO: Make this work or smthng
|
||||||
if (component is GhostIK) (component as GhostIK).enabled = false;
|
if (component is GhostIK) (component as GhostIK).enabled = false;
|
||||||
@ -80,6 +80,14 @@ namespace NewHorizons.Builder.Props
|
|||||||
if (component is Animator) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Animator).enabled = true);
|
if (component is Animator) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Animator).enabled = true);
|
||||||
if (component is Collider) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Collider).enabled = true);
|
if (component is Collider) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Collider).enabled = true);
|
||||||
|
|
||||||
|
if(component is Shape) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Shape).enabled = true);
|
||||||
|
|
||||||
|
if(component is DarkMatterVolume)
|
||||||
|
{
|
||||||
|
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
|
||||||
|
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (component is SectoredMonoBehaviour)
|
if (component is SectoredMonoBehaviour)
|
||||||
{
|
{
|
||||||
(component as SectoredMonoBehaviour).SetSector(sector);
|
(component as SectoredMonoBehaviour).SetSector(sector);
|
||||||
|
|||||||
@ -38,6 +38,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
foreach (var propInfo in scatterInfo)
|
foreach (var propInfo in scatterInfo)
|
||||||
{
|
{
|
||||||
|
Random.InitState(propInfo.seed);
|
||||||
|
|
||||||
GameObject prefab;
|
GameObject prefab;
|
||||||
if (propInfo.assetBundle != null) prefab = PropBuildManager.LoadPrefab(propInfo.assetBundle, propInfo.path, uniqueModName, assets);
|
if (propInfo.assetBundle != null) prefab = PropBuildManager.LoadPrefab(propInfo.assetBundle, propInfo.path, uniqueModName, assets);
|
||||||
else prefab = GameObject.Find(propInfo.path);
|
else prefab = GameObject.Find(propInfo.path);
|
||||||
|
|||||||
@ -121,7 +121,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
clip = mod.Assets.GetAudio(info.AudioFilePath);
|
clip = AudioUtility.LoadAudio(mod.Manifest.ModFolderPath + "/" + info.AudioFilePath);
|
||||||
|
//clip = mod.Assets.GetAudio(info.AudioFilePath);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
1
NewHorizons/External/PropModule.cs
vendored
1
NewHorizons/External/PropModule.cs
vendored
@ -18,6 +18,7 @@ namespace NewHorizons.External
|
|||||||
|
|
||||||
public class ScatterInfo
|
public class ScatterInfo
|
||||||
{
|
{
|
||||||
|
public int seed = 0;
|
||||||
public int count;
|
public int count;
|
||||||
public string path;
|
public string path;
|
||||||
public string assetBundle;
|
public string assetBundle;
|
||||||
|
|||||||
@ -5,87 +5,55 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace NewHorizons.Utility
|
namespace NewHorizons.Utility
|
||||||
{
|
{
|
||||||
public static class AudioUtility
|
public static class AudioUtility
|
||||||
{
|
{
|
||||||
// Thank you https://answers.unity.com/questions/737002/wav-byte-to-audioclip.html?_ga=2.94866780.194866897.1641426110-1837936344.1635819725
|
public static AudioClip LoadAudio(string filePath)
|
||||||
|
|
||||||
// convert two bytes to one float in the range -1 to 1
|
|
||||||
static float bytesToFloat(byte firstByte, byte secondByte)
|
|
||||||
{
|
{
|
||||||
// convert two bytes to one short (little endian)
|
var task = Task.Run(async () => await GetAudioClip(filePath));
|
||||||
short s = (short)((secondByte << 8) | firstByte);
|
task.Wait();
|
||||||
// convert to range from -1 to (just below) 1
|
return task.Result;
|
||||||
return s / 32768.0F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bytesToInt(byte[] bytes, int offset = 0)
|
private static async Task<AudioClip> GetAudioClip(string filePath)
|
||||||
{
|
{
|
||||||
int value = 0;
|
|
||||||
for (int i = 0; i < 4; i++)
|
var extension = filePath.Split(new char[] { '.' }).Last();
|
||||||
|
|
||||||
|
UnityEngine.AudioType audioType;
|
||||||
|
|
||||||
|
switch (extension)
|
||||||
{
|
{
|
||||||
value |= ((int)bytes[offset + i]) << (i * 8);
|
case ("wav"):
|
||||||
}
|
audioType = UnityEngine.AudioType.WAV;
|
||||||
return value;
|
break;
|
||||||
|
case ("ogg"):
|
||||||
|
audioType = UnityEngine.AudioType.OGGVORBIS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Logger.LogError($"Invalid audio file extension ({extension}) must be .wav or .ogg");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] GetBytes(string filename)
|
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(filePath, audioType))
|
||||||
{
|
{
|
||||||
return File.ReadAllBytes(filename);
|
var result = www.SendWebRequest();
|
||||||
}
|
|
||||||
|
|
||||||
// Returns left and right double arrays. 'right' will be null if sound is mono.
|
while (!result.isDone) { await Task.Delay(100); }
|
||||||
public static AudioClip LoadWAV(string filename)
|
|
||||||
|
if (www.isNetworkError)
|
||||||
{
|
{
|
||||||
var wav = GetBytes(filename);
|
Debug.Log(www.error);
|
||||||
|
return null;
|
||||||
// Determine if mono or stereo
|
}
|
||||||
var ChannelCount = wav[22]; // Forget byte 23 as 99.999% of WAVs are 1 or 2 channels
|
else
|
||||||
|
|
||||||
// Get the frequency
|
|
||||||
var Frequency = bytesToInt(wav, 24);
|
|
||||||
|
|
||||||
// Get past all the other sub chunks to get to the data subchunk:
|
|
||||||
int pos = 12; // First Subchunk ID from 12 to 16
|
|
||||||
|
|
||||||
// Keep iterating until we find the data chunk (i.e. 64 61 74 61 ...... (i.e. 100 97 116 97 in decimal))
|
|
||||||
while (!(wav[pos] == 100 && wav[pos + 1] == 97 && wav[pos + 2] == 116 && wav[pos + 3] == 97))
|
|
||||||
{
|
{
|
||||||
pos += 4;
|
return DownloadHandlerAudioClip.GetContent(www);
|
||||||
int chunkSize = wav[pos] + wav[pos + 1] * 256 + wav[pos + 2] * 65536 + wav[pos + 3] * 16777216;
|
}
|
||||||
pos += 4 + chunkSize;
|
}
|
||||||
}
|
|
||||||
pos += 8;
|
|
||||||
|
|
||||||
// Pos is now positioned to start of actual sound data.
|
|
||||||
var SampleCount = (wav.Length - pos) / 2; // 2 bytes per sample (16 bit sound mono)
|
|
||||||
if (ChannelCount == 2) SampleCount /= 2; // 4 bytes per sample (16 bit stereo)
|
|
||||||
|
|
||||||
// Allocate memory (right will be null if only mono sound)
|
|
||||||
var LeftChannel = new float[SampleCount];
|
|
||||||
float[] RightChannel;
|
|
||||||
if (ChannelCount == 2) RightChannel = new float[SampleCount];
|
|
||||||
else RightChannel = null;
|
|
||||||
|
|
||||||
// Write to double array/s:
|
|
||||||
int i = 0;
|
|
||||||
while (pos < wav.Length)
|
|
||||||
{
|
|
||||||
LeftChannel[i] = bytesToFloat(wav[pos], wav[pos + 1]);
|
|
||||||
pos += 2;
|
|
||||||
if (ChannelCount == 2)
|
|
||||||
{
|
|
||||||
RightChannel[i] = bytesToFloat(wav[pos], wav[pos + 1]);
|
|
||||||
pos += 2;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioClip audioClip = AudioClip.Create("testSound", SampleCount, 1, Frequency, false);
|
|
||||||
audioClip.SetData(LeftChannel, 0);
|
|
||||||
return audioClip;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"author": "xen",
|
"author": "xen",
|
||||||
"name": "New Horizons",
|
"name": "New Horizons",
|
||||||
"uniqueName": "xen.NewHorizons",
|
"uniqueName": "xen.NewHorizons",
|
||||||
"version": "0.8.0",
|
"version": "0.8.1",
|
||||||
"owmlVersion": "2.1.0",
|
"owmlVersion": "2.1.0",
|
||||||
"dependencies": [ "PacificEngine.OW_CommonResources" ],
|
"dependencies": [ "PacificEngine.OW_CommonResources" ],
|
||||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ]
|
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ]
|
||||||
|
|||||||
@ -1107,7 +1107,7 @@
|
|||||||
"Star"
|
"Star"
|
||||||
],
|
],
|
||||||
"default": "Sand"
|
"default": "Sand"
|
||||||
}
|
},
|
||||||
"tint": {
|
"tint": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user