mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Warp drive works
Also basic cloud shader + unlimited signals
This commit is contained in:
parent
067996f80f
commit
8d0bccb607
@ -10,6 +10,7 @@ namespace NewHorizons.Atmosphere
|
|||||||
{
|
{
|
||||||
static class CloudsBuilder
|
static class CloudsBuilder
|
||||||
{
|
{
|
||||||
|
private static Shader _sphereShader = null;
|
||||||
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo, IModAssets assets)
|
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo, IModAssets assets)
|
||||||
{
|
{
|
||||||
Texture2D image, cap, ramp;
|
Texture2D image, cap, ramp;
|
||||||
@ -20,10 +21,10 @@ namespace NewHorizons.Atmosphere
|
|||||||
|
|
||||||
if (atmo.CloudCap == null) cap = ImageUtilities.ClearTexture(128, 128);
|
if (atmo.CloudCap == null) cap = ImageUtilities.ClearTexture(128, 128);
|
||||||
else cap = assets.GetTexture(atmo.CloudCap);
|
else cap = assets.GetTexture(atmo.CloudCap);
|
||||||
if(atmo.CloudRamp == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height);
|
if (atmo.CloudRamp == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height);
|
||||||
else ramp = assets.GetTexture(atmo.CloudRamp);
|
else ramp = assets.GetTexture(atmo.CloudRamp);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.LogError($"Couldn't load Cloud textures, {e.Message}, {e.StackTrace}");
|
Logger.LogError($"Couldn't load Cloud textures, {e.Message}, {e.StackTrace}");
|
||||||
return;
|
return;
|
||||||
@ -45,15 +46,22 @@ namespace NewHorizons.Atmosphere
|
|||||||
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
|
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
|
||||||
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||||
|
|
||||||
var tempArray = new Material[2];
|
|
||||||
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
|
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
|
||||||
for (int i = 0; i < 2; i++)
|
if (!atmo.UseBasicCloudShader)
|
||||||
{
|
{
|
||||||
tempArray[i] = GameObject.Instantiate(GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials[i]);
|
var tempArray = new Material[2];
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
tempArray[i] = new Material(GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials[i]);
|
||||||
|
}
|
||||||
|
topMR.sharedMaterials = tempArray;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_sphereShader == null) _sphereShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
|
||||||
|
topMR.material = new Material(_sphereShader);
|
||||||
}
|
}
|
||||||
topMR.sharedMaterials = tempArray;
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var material in topMR.sharedMaterials)
|
foreach (var material in topMR.sharedMaterials)
|
||||||
{
|
{
|
||||||
material.SetColor("_Color", cloudTint);
|
material.SetColor("_Color", cloudTint);
|
||||||
@ -63,7 +71,7 @@ namespace NewHorizons.Atmosphere
|
|||||||
material.SetTexture("_RampTex", ramp);
|
material.SetTexture("_RampTex", ramp);
|
||||||
material.SetTexture("_CapTex", cap);
|
material.SetTexture("_CapTex", cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>();
|
RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>();
|
||||||
topRT.SetValue("_localAxis", Vector3.up);
|
topRT.SetValue("_localAxis", Vector3.up);
|
||||||
@ -78,20 +86,23 @@ namespace NewHorizons.Atmosphere
|
|||||||
|
|
||||||
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
|
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
|
||||||
bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
|
bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
|
||||||
bottomTSR.sharedMaterials = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
|
var bottomTSRMaterials = GameObject.Find("CloudsBottomLayer_GD").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
|
||||||
|
var bottomTSRTempArray = new Material[bottomTSRMaterials.Length];
|
||||||
|
|
||||||
|
// It's a bit too green
|
||||||
|
var bottomColor = atmo.CloudTint.ToColor32();
|
||||||
|
bottomColor.g = (byte)(bottomColor.g * 0.5f);
|
||||||
|
for (int i = 0; i < bottomTSRMaterials.Length; i++)
|
||||||
|
{
|
||||||
|
bottomTSRTempArray[i] = new Material(bottomTSRMaterials[i]);
|
||||||
|
bottomTSRTempArray[i].SetColor("_Color", bottomColor);
|
||||||
|
bottomTSRTempArray[i].SetColor("_TintColor", bottomColor);
|
||||||
|
}
|
||||||
|
bottomTSR.sharedMaterials = bottomTSRTempArray;
|
||||||
bottomTSR.maxLOD = 6;
|
bottomTSR.maxLOD = 6;
|
||||||
bottomTSR.LODBias = 0;
|
bottomTSR.LODBias = 0;
|
||||||
bottomTSR.LODRadius = 1f;
|
bottomTSR.LODRadius = 1f;
|
||||||
|
|
||||||
// It's always more green than expected
|
|
||||||
var bottomCloudTint = cloudTint;
|
|
||||||
bottomCloudTint.g = (byte)(bottomCloudTint.g * 0.8f);
|
|
||||||
foreach (Material material in bottomTSR.sharedMaterials)
|
|
||||||
{
|
|
||||||
material.SetColor("_Color", bottomCloudTint);
|
|
||||||
material.SetColor("_TintColor", bottomCloudTint);
|
|
||||||
}
|
|
||||||
|
|
||||||
TessSphereSectorToggle bottomTSST = cloudsBottomGO.AddComponent<TessSphereSectorToggle>();
|
TessSphereSectorToggle bottomTSST = cloudsBottomGO.AddComponent<TessSphereSectorToggle>();
|
||||||
bottomTSST.SetValue("_sector", sector);
|
bottomTSST.SetValue("_sector", sector);
|
||||||
|
|
||||||
@ -118,6 +129,8 @@ namespace NewHorizons.Atmosphere
|
|||||||
|
|
||||||
// Fix the rotations once the rest is done
|
// Fix the rotations once the rest is done
|
||||||
cloudsMainGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
cloudsMainGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
// For the base shader it has to be rotated idk
|
||||||
|
if(atmo.UseBasicCloudShader) cloudsMainGO.transform.localRotation = Quaternion.Euler(90, 0, 0);
|
||||||
|
|
||||||
cloudsMainGO.transform.localPosition = Vector3.zero;
|
cloudsMainGO.transform.localPosition = Vector3.zero;
|
||||||
cloudsBottomGO.transform.localPosition = Vector3.zero;
|
cloudsBottomGO.transform.localPosition = Vector3.zero;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
{
|
{
|
||||||
static class AsteroidBeltBuilder
|
static class AsteroidBeltBuilder
|
||||||
{
|
{
|
||||||
public static void Make(string bodyName, IPlanetConfig parentConfig, IModAssets assets, string uniqueName)
|
public static void Make(string bodyName, IPlanetConfig parentConfig, IModHelper mod)
|
||||||
{
|
{
|
||||||
var belt = parentConfig.AsteroidBelt;
|
var belt = parentConfig.AsteroidBelt;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
var asteroidConfig = new PlanetConfig(config);
|
var asteroidConfig = new PlanetConfig(config);
|
||||||
if (belt.ProcGen != null) asteroidConfig.ProcGen = belt.ProcGen;
|
if (belt.ProcGen != null) asteroidConfig.ProcGen = belt.ProcGen;
|
||||||
var asteroid = new NewHorizonsBody(new PlanetConfig(config), assets, uniqueName);
|
var asteroid = new NewHorizonsBody(new PlanetConfig(config), mod);
|
||||||
Main.NextPassBodies.Add(asteroid);
|
Main.NextPassBodies.Add(asteroid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,27 +51,20 @@ namespace NewHorizons.Builder.Body
|
|||||||
if (RingShader1Pixel == null) RingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring1Pixel.shader");
|
if (RingShader1Pixel == null) RingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring1Pixel.shader");
|
||||||
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
|
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
|
||||||
|
|
||||||
bool doubleSided = false;
|
|
||||||
var mat = new Material(ring.Unlit ? UnlitRingShader : RingShader);
|
var mat = new Material(ring.Unlit ? UnlitRingShader : RingShader);
|
||||||
if(texture.width == 1)
|
if(texture.width == 1)
|
||||||
{
|
{
|
||||||
mat = new Material(ring.Unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
|
mat = new Material(ring.Unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
|
||||||
mat.SetFloat("_InnerRadius", 0);
|
mat.SetFloat("_InnerRadius", 0);
|
||||||
doubleSided = true;
|
|
||||||
}
|
}
|
||||||
ringMR.receiveShadows = !ring.Unlit;
|
ringMR.receiveShadows = !ring.Unlit;
|
||||||
|
|
||||||
mat.mainTexture = texture;
|
mat.mainTexture = texture;
|
||||||
mat.renderQueue = 2895;
|
mat.renderQueue = 3000;
|
||||||
ringMR.material = mat;
|
ringMR.material = mat;
|
||||||
|
|
||||||
// Make mesh
|
// Make mesh
|
||||||
var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 2000);
|
var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 2000);
|
||||||
|
|
||||||
//BuildQuadMesh(ringMesh, ring.OuterRadius * 2);
|
|
||||||
//BuildCircleMesh(ringMesh, segments, ring.OuterRadius);
|
|
||||||
//ringGO.AddComponent<MakeMeshDoubleFaced>();
|
|
||||||
|
|
||||||
BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius);
|
BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius);
|
||||||
|
|
||||||
if(ring.RotationSpeed != 0)
|
if(ring.RotationSpeed != 0)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace NewHorizons.Builder.General
|
|||||||
public static SpawnPoint Make(GameObject body, SpawnModule module, OWRigidbody rb)
|
public static SpawnPoint Make(GameObject body, SpawnModule module, OWRigidbody rb)
|
||||||
{
|
{
|
||||||
SpawnPoint playerSpawn = null;
|
SpawnPoint playerSpawn = null;
|
||||||
if(module.PlayerSpawnPoint != null)
|
if(!Main.IsWarping && module.PlayerSpawnPoint != null)
|
||||||
{
|
{
|
||||||
GameObject spawnGO = new GameObject("PlayerSpawnPoint");
|
GameObject spawnGO = new GameObject("PlayerSpawnPoint");
|
||||||
spawnGO.transform.parent = body.transform;
|
spawnGO.transform.parent = body.transform;
|
||||||
@ -44,8 +44,22 @@ namespace NewHorizons.Builder.General
|
|||||||
ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 5f;
|
ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 5f;
|
||||||
|
|
||||||
ship.GetRequiredComponent<MatchInitialMotion>().SetBodyToMatch(rb);
|
ship.GetRequiredComponent<MatchInitialMotion>().SetBodyToMatch(rb);
|
||||||
|
|
||||||
|
if(Main.IsWarping)
|
||||||
|
{
|
||||||
|
GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint");
|
||||||
|
playerSpawnGO.transform.parent = ship.transform;
|
||||||
|
playerSpawnGO.layer = 8;
|
||||||
|
|
||||||
|
playerSpawnGO.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
playerSpawn = playerSpawnGO.AddComponent<SpawnPoint>();
|
||||||
|
playerSpawnGO.transform.localRotation = Quaternion.Euler(0,0,0);
|
||||||
|
|
||||||
|
GameObject.FindObjectOfType<PlayerSpawner>().SetInitialSpawnPoint(playerSpawn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(module.StartWithSuit && !suitUpQueued)
|
if(!Main.IsWarping && module.StartWithSuit && !suitUpQueued)
|
||||||
{
|
{
|
||||||
suitUpQueued = true;
|
suitUpQueued = true;
|
||||||
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SuitUp(), 4);
|
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SuitUp(), 4);
|
||||||
@ -55,9 +69,10 @@ namespace NewHorizons.Builder.General
|
|||||||
return playerSpawn;
|
return playerSpawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SuitUp()
|
public static void SuitUp()
|
||||||
{
|
{
|
||||||
suitUpQueued = false;
|
suitUpQueued = false;
|
||||||
|
if (Locator.GetPlayerController()._isWearingSuit) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear").GetComponent<SuitPickupVolume>();
|
var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear").GetComponent<SuitPickupVolume>();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace NewHorizons.Builder.Orbital
|
|||||||
// Rotation
|
// Rotation
|
||||||
initialMotion.SetValue("_initAngularSpeed", orbit.SiderealPeriod == 0 ? 0f : 1.0f / orbit.SiderealPeriod);
|
initialMotion.SetValue("_initAngularSpeed", orbit.SiderealPeriod == 0 ? 0f : 1.0f / orbit.SiderealPeriod);
|
||||||
|
|
||||||
var rotationAxis = Quaternion.AngleAxis(orbit.AxialTilt + orbit.Inclination + 90f, Vector3.right) * Vector3.up;
|
var rotationAxis = Quaternion.AngleAxis(orbit.AxialTilt + 90f, Vector3.right) * Vector3.up;
|
||||||
body.transform.rotation = Quaternion.FromToRotation(Vector3.up, rotationAxis);
|
body.transform.rotation = Quaternion.FromToRotation(Vector3.up, rotationAxis);
|
||||||
|
|
||||||
initialMotion._orbitImpulseScalar = 0f;
|
initialMotion._orbitImpulseScalar = 0f;
|
||||||
|
|||||||
@ -21,6 +21,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static Dictionary<SignalFrequency, string> SignalFrequencyOverrides;
|
public static Dictionary<SignalFrequency, string> SignalFrequencyOverrides;
|
||||||
|
|
||||||
|
private static int _nextCustomSignalName;
|
||||||
|
|
||||||
public static void Reset()
|
public static void Reset()
|
||||||
{
|
{
|
||||||
_customSignalNames = new Dictionary<SignalName, string>();
|
_customSignalNames = new Dictionary<SignalName, string>();
|
||||||
@ -66,18 +68,17 @@ namespace NewHorizons.Builder.Props
|
|||||||
{ SignalFrequency.Default, "???" },
|
{ SignalFrequency.Default, "???" },
|
||||||
{ SignalFrequency.WarpCore, "ANTI-GRAVITON FLUX" }
|
{ SignalFrequency.WarpCore, "ANTI-GRAVITON FLUX" }
|
||||||
};
|
};
|
||||||
|
_nextCustomSignalName = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SignalName AddSignalName(string str)
|
public static SignalName AddSignalName(string str)
|
||||||
{
|
{
|
||||||
if (_availableSignalNames.Count == 0)
|
|
||||||
{
|
|
||||||
Logger.LogWarning($"There are no more available SignalName spots. Cannot use name [{str}].");
|
|
||||||
return SignalName.Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Log($"Registering new signal name [{str}]");
|
Logger.Log($"Registering new signal name [{str}]");
|
||||||
var newName = _availableSignalNames.Pop();
|
SignalName newName;
|
||||||
|
|
||||||
|
if (_availableSignalNames.Count == 0) newName = (SignalName)_nextCustomSignalName++;
|
||||||
|
else newName = _availableSignalNames.Pop();
|
||||||
|
|
||||||
_customSignalNames.Add(newName, str.ToUpper());
|
_customSignalNames.Add(newName, str.ToUpper());
|
||||||
return newName;
|
return newName;
|
||||||
}
|
}
|
||||||
@ -88,15 +89,15 @@ namespace NewHorizons.Builder.Props
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject body, Sector sector, SignalModule module, IModAssets assets)
|
public static void Make(GameObject body, Sector sector, SignalModule module, IModHelper mod)
|
||||||
{
|
{
|
||||||
foreach(var info in module.Signals)
|
foreach(var info in module.Signals)
|
||||||
{
|
{
|
||||||
Make(body, sector, info, assets);
|
Make(body, sector, info, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject body, Sector sector, SignalModule.SignalInfo info, IModAssets assets)
|
public static void Make(GameObject body, Sector sector, SignalModule.SignalInfo info, IModHelper mod)
|
||||||
{
|
{
|
||||||
var signalGO = new GameObject($"Signal_{info.Name}");
|
var signalGO = new GameObject($"Signal_{info.Name}");
|
||||||
signalGO.SetActive(false);
|
signalGO.SetActive(false);
|
||||||
@ -120,7 +121,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
clip = assets.GetAudio(info.AudioFilePath);
|
clip = mod.Assets.GetAudio(info.AudioFilePath);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -41,22 +41,47 @@ namespace NewHorizons.Components
|
|||||||
_centerPromptList = centerPromptList;
|
_centerPromptList = centerPromptList;
|
||||||
_upperRightPromptList = upperRightPromptList;
|
_upperRightPromptList = upperRightPromptList;
|
||||||
|
|
||||||
_detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, "Detective Mode", 0, ScreenPrompt.DisplayState.Normal, false);
|
_detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, "Rumor Mode", 0, ScreenPrompt.DisplayState.Normal, false);
|
||||||
_targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, "Target", 0, ScreenPrompt.DisplayState.Normal, false);
|
_targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, "Target", 0, ScreenPrompt.DisplayState.Normal, false);
|
||||||
|
|
||||||
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||||
|
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
foreach (var starSystem in Main.BodyDict.Keys)
|
foreach (var starSystem in Main.BodyDict.Keys)
|
||||||
{
|
{
|
||||||
var card = CreateCard(starSystem, root.transform, new Vector2(x++ * 256, 0));
|
// Conditions to allow warping into that system (either no planets (stock system) or has a ship spawn point)
|
||||||
_starSystemCards.Add(card);
|
var flag = false;
|
||||||
|
if (starSystem.Equals("SolarSystem")) flag = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach(var body in Main.BodyDict[starSystem])
|
||||||
|
{
|
||||||
|
if(body.Config?.Spawn?.ShipSpawnPoint != null)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag)
|
||||||
|
{
|
||||||
|
var card = CreateCard(starSystem, root.transform, new Vector2(x++ * 200, 0));
|
||||||
|
_starSystemCards.Add(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||||
|
GlobalMessenger<OWRigidbody>.RemoveListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnterFlightConsole(OWRigidbody _)
|
||||||
|
{
|
||||||
|
if (_target == null) GlobalMessenger.FireEvent("UntargetReferenceFrame");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position)
|
public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position)
|
||||||
@ -72,7 +97,7 @@ namespace NewHorizons.Components
|
|||||||
newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>().text = UniqueNameToString(uniqueName);
|
newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>().text = UniqueNameToString(uniqueName);
|
||||||
newCard.SetActive(true);
|
newCard.SetActive(true);
|
||||||
newCard.transform.name = uniqueName;
|
newCard.transform.name = uniqueName;
|
||||||
newCard.transform.localPosition = new Vector3(position.x, position.y, 0);
|
newCard.transform.localPosition = new Vector3(position.x, position.y, 40);
|
||||||
newCard.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
newCard.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
|
||||||
var shipLogEntryCard = newCard.GetComponent<ShipLogEntryCard>();
|
var shipLogEntryCard = newCard.GetComponent<ShipLogEntryCard>();
|
||||||
@ -87,7 +112,7 @@ namespace NewHorizons.Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IModAssets assets = Main.BodyDict[uniqueName][0].Assets;
|
IModAssets assets = Main.BodyDict[uniqueName][0].Mod.Assets;
|
||||||
var path = $"planets/{uniqueName}.png";
|
var path = $"planets/{uniqueName}.png";
|
||||||
Logger.Log($"Trying to load {path}");
|
Logger.Log($"Trying to load {path}");
|
||||||
texture = assets.GetTexture(path);
|
texture = assets.GetTexture(path);
|
||||||
@ -136,7 +161,7 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
public override string GetFocusedEntryID()
|
public override string GetFocusedEntryID()
|
||||||
{
|
{
|
||||||
return "0";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEnterComputer()
|
public override void OnEnterComputer()
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using NewHorizons.Builder.General;
|
||||||
|
using PacificEngine.OW_CommonResources.Game.Player;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -9,28 +11,150 @@ namespace NewHorizons.Components
|
|||||||
{
|
{
|
||||||
public class ShipWarpController : MonoBehaviour
|
public class ShipWarpController : MonoBehaviour
|
||||||
{
|
{
|
||||||
private SingularityController _singularityController;
|
private SingularityController _blackhole;
|
||||||
|
private SingularityController _whitehole;
|
||||||
private OWAudioSource _oneShotSource;
|
private OWAudioSource _oneShotSource;
|
||||||
|
|
||||||
|
private bool _isWarpingIn;
|
||||||
|
private bool _waitingToBeSeated;
|
||||||
|
private bool _eyesOpen = false;
|
||||||
|
|
||||||
|
private float _impactDeathSpeed;
|
||||||
|
|
||||||
|
private const float size = 14f;
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
GameObject singularityGO = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity"), GameObject.Find("Ship_Body").transform);
|
MakeBlackHole();
|
||||||
singularityGO.transform.localPosition = new Vector3(0f, 0f, 5f);
|
MakeWhiteHole();
|
||||||
singularityGO.transform.localScale = Vector3.one * 10f;
|
|
||||||
_singularityController = singularityGO.GetComponent<SingularityController>();
|
|
||||||
|
|
||||||
_oneShotSource = singularityGO.AddComponent<OWAudioSource>();
|
_oneShotSource = base.gameObject.AddComponent<OWAudioSource>();
|
||||||
|
|
||||||
|
GlobalMessenger.AddListener("FinishOpenEyes", new Callback(OnFinishOpenEyes));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeBlackHole()
|
||||||
|
{
|
||||||
|
var blackHoleShader = GameObject.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity").GetComponent<MeshRenderer>().material.shader;
|
||||||
|
|
||||||
|
var blackHoleRender = new GameObject("BlackHoleRender");
|
||||||
|
blackHoleRender.transform.parent = base.transform;
|
||||||
|
blackHoleRender.transform.localPosition = new Vector3(0, 1, 0);
|
||||||
|
blackHoleRender.transform.localScale = Vector3.one * size;
|
||||||
|
|
||||||
|
var meshFilter = blackHoleRender.AddComponent<MeshFilter>();
|
||||||
|
meshFilter.mesh = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshFilter>().mesh;
|
||||||
|
|
||||||
|
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
|
||||||
|
if (blackHoleShader == null) blackHoleShader = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshRenderer>().sharedMaterial.shader;
|
||||||
|
meshRenderer.material = new Material(blackHoleShader);
|
||||||
|
meshRenderer.material.SetFloat("_Radius", size * 0.4f);
|
||||||
|
meshRenderer.material.SetFloat("_MaxDistortRadius", size * 0.95f);
|
||||||
|
meshRenderer.material.SetFloat("_MassScale", 1);
|
||||||
|
meshRenderer.material.SetFloat("_DistortFadeDist", size * 0.55f);
|
||||||
|
|
||||||
|
_blackhole = blackHoleRender.AddComponent<SingularityController>();
|
||||||
|
blackHoleRender.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeWhiteHole()
|
||||||
|
{
|
||||||
|
var whiteHoleShader = GameObject.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_CT/Prefab_NOM_WarpTransmitter/WhiteHole/WhiteHoleSingularity").GetComponent<MeshRenderer>().material.shader;
|
||||||
|
|
||||||
|
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
|
||||||
|
whiteHoleRenderer.transform.parent = base.transform;
|
||||||
|
whiteHoleRenderer.transform.localPosition = new Vector3(0, 1, 0);
|
||||||
|
whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f;
|
||||||
|
|
||||||
|
var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>();
|
||||||
|
meshFilter.mesh = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshFilter>().mesh;
|
||||||
|
|
||||||
|
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
|
||||||
|
if (whiteHoleShader == null) whiteHoleShader = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshRenderer>().sharedMaterial.shader;
|
||||||
|
meshRenderer.material = new Material(whiteHoleShader);
|
||||||
|
meshRenderer.sharedMaterial.SetFloat("_Radius", size * 0.4f);
|
||||||
|
meshRenderer.sharedMaterial.SetFloat("_DistortFadeDist", size);
|
||||||
|
meshRenderer.sharedMaterial.SetFloat("_MaxDistortRadius", size * 2.8f);
|
||||||
|
meshRenderer.sharedMaterial.SetColor("_Color", new Color(1.88f, 1.88f, 1.88f, 1f));
|
||||||
|
|
||||||
|
_whitehole = whiteHoleRenderer.AddComponent<SingularityController>();
|
||||||
|
whiteHoleRenderer.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
GlobalMessenger.RemoveListener("FinishOpenEyes", new Callback(OnFinishOpenEyes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WarpIn()
|
public void WarpIn()
|
||||||
{
|
{
|
||||||
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f);
|
// Trying really hard to stop the player from dying while warping in
|
||||||
|
_impactDeathSpeed = Locator.GetDeathManager()._impactDeathSpeed;
|
||||||
|
Locator.GetDeathManager()._impactDeathSpeed = Mathf.Infinity;
|
||||||
|
Locator.GetDeathManager()._invincible = true;
|
||||||
|
|
||||||
|
_isWarpingIn = true;
|
||||||
|
_whitehole.Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WarpOut()
|
public void WarpOut()
|
||||||
{
|
{
|
||||||
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f);
|
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f);
|
||||||
_singularityController.Create();
|
_blackhole.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if(_isWarpingIn && LateInitializerManager.isDoneInitializing)
|
||||||
|
{
|
||||||
|
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f);
|
||||||
|
Locator.GetDeathManager()._invincible = true;
|
||||||
|
if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) Teleportation.teleportPlayerToShip();
|
||||||
|
_whitehole.Create();
|
||||||
|
_isWarpingIn = false;
|
||||||
|
_waitingToBeSeated = true;
|
||||||
|
if (!Locator.GetPlayerController()._isWearingSuit)
|
||||||
|
{
|
||||||
|
SpawnPointBuilder.SuitUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Idk whats making this work but now it works and idc
|
||||||
|
if(_waitingToBeSeated
|
||||||
|
&& PlayerState.IsInsideShip()
|
||||||
|
&& PlayerState.IsWearingSuit()
|
||||||
|
&& base.GetComponentInChildren<ShipCockpitController>()?._playerAttachPoint?.GetAttachedOWRigidbody() != null
|
||||||
|
&& !Locator.GetPlayerController()._isMovementLocked
|
||||||
|
&& !Locator.GetPlayerController()._isTurningLocked
|
||||||
|
&& _eyesOpen)
|
||||||
|
{
|
||||||
|
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => FinishWarp(), 4);
|
||||||
|
_waitingToBeSeated = false;
|
||||||
|
}
|
||||||
|
if (_waitingToBeSeated)
|
||||||
|
{
|
||||||
|
if (Player.getResources()._currentHealth < 100f)
|
||||||
|
{
|
||||||
|
// Means the player was killed meaning they weren't teleported in
|
||||||
|
Player.getResources()._currentHealth = 100f;
|
||||||
|
Teleportation.teleportPlayerToShip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFinishOpenEyes()
|
||||||
|
{
|
||||||
|
_eyesOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FinishWarp()
|
||||||
|
{
|
||||||
|
Locator.GetShipBody().GetComponentInChildren<ShipCockpitController>().OnPressInteract();
|
||||||
|
_waitingToBeSeated = false;
|
||||||
|
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => _whitehole.Collapse(), 30);
|
||||||
|
|
||||||
|
Locator.GetDeathManager()._impactDeathSpeed = _impactDeathSpeed;
|
||||||
|
Player.getResources()._currentHealth = 100f;
|
||||||
|
Locator.GetDeathManager()._invincible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
NewHorizons/External/AtmosphereModule.cs
vendored
1
NewHorizons/External/AtmosphereModule.cs
vendored
@ -14,6 +14,7 @@ namespace NewHorizons.External
|
|||||||
public string Cloud { get; set; }
|
public string Cloud { get; set; }
|
||||||
public string CloudCap { get; set; }
|
public string CloudCap { get; set; }
|
||||||
public string CloudRamp { get; set; }
|
public string CloudRamp { get; set; }
|
||||||
|
public bool UseBasicCloudShader { get; set; }
|
||||||
public MColor32 FogTint { get; set; }
|
public MColor32 FogTint { get; set; }
|
||||||
public float FogDensity { get; set; }
|
public float FogDensity { get; set; }
|
||||||
public float FogSize { get; set; }
|
public float FogSize { get; set; }
|
||||||
|
|||||||
@ -36,8 +36,11 @@ namespace NewHorizons
|
|||||||
public StarLightController StarLightController { get; private set; }
|
public StarLightController StarLightController { get; private set; }
|
||||||
|
|
||||||
private string _currentStarSystem = "SolarSystem";
|
private string _currentStarSystem = "SolarSystem";
|
||||||
|
public string CurrentStarSystem { get { return Instance._currentStarSystem; } }
|
||||||
|
|
||||||
private bool _isChangingStarSystem = false;
|
private bool _isChangingStarSystem = false;
|
||||||
private bool _isWarping = false;
|
private bool _isWarping = false;
|
||||||
|
public static bool IsWarping { get { return Instance._isWarping; } }
|
||||||
|
|
||||||
private ShipWarpController _shipWarpController;
|
private ShipWarpController _shipWarpController;
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ namespace NewHorizons
|
|||||||
Logger.Log("Done loading bodies");
|
Logger.Log("Done loading bodies");
|
||||||
|
|
||||||
// I don't know what these do but they look really weird from a distance
|
// I don't know what these do but they look really weird from a distance
|
||||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PlanetDestroyer.RemoveDistantProxyClones());
|
//Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PlanetDestroyer.RemoveDistantProxyClones());
|
||||||
|
|
||||||
if(!_currentStarSystem.Equals("SolarSystem")) Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PlanetDestroyer.RemoveSolarSystem());
|
if(!_currentStarSystem.Equals("SolarSystem")) Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PlanetDestroyer.RemoveSolarSystem());
|
||||||
|
|
||||||
@ -196,8 +199,7 @@ namespace NewHorizons
|
|||||||
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
||||||
|
|
||||||
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>();
|
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>();
|
||||||
|
if (_isWarping) Instance.ModHelper.Events.Unity.FireInNUpdates(() => _shipWarpController.WarpIn(), 1);
|
||||||
if(_isWarping) Instance.ModHelper.Events.Unity.FireInNUpdates(() => _shipWarpController.WarpIn(), 3);
|
|
||||||
_isWarping = false;
|
_isWarping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +274,7 @@ namespace NewHorizons
|
|||||||
heightMap.TextureMap = body.Config.Atmosphere.Cloud;
|
heightMap.TextureMap = body.Config.Atmosphere.Cloud;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeightMapBuilder.Make(titleScreenGO, heightMap, body.Assets);
|
HeightMapBuilder.Make(titleScreenGO, heightMap, body.Mod.Assets);
|
||||||
|
|
||||||
GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform);
|
GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform);
|
||||||
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
|
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
|
||||||
@ -288,7 +290,7 @@ namespace NewHorizons
|
|||||||
newRing.InnerRadius = size * 1.2f;
|
newRing.InnerRadius = size * 1.2f;
|
||||||
newRing.OuterRadius = size * 2f;
|
newRing.OuterRadius = size * 2f;
|
||||||
newRing.Texture = body.Config.Ring.Texture;
|
newRing.Texture = body.Config.Ring.Texture;
|
||||||
var ring = RingBuilder.Make(titleScreenGO, newRing, body.Assets);
|
var ring = RingBuilder.Make(titleScreenGO, newRing, body.Mod.Assets);
|
||||||
titleScreenGO.transform.localScale = Vector3.one * 0.8f;
|
titleScreenGO.transform.localScale = Vector3.one * 0.8f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +314,7 @@ namespace NewHorizons
|
|||||||
Logger.Log($"Loaded {config.Name}");
|
Logger.Log($"Loaded {config.Name}");
|
||||||
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
||||||
if (!BodyDict.ContainsKey(config.StarSystem)) BodyDict.Add(config.StarSystem, new List<NewHorizonsBody>());
|
if (!BodyDict.ContainsKey(config.StarSystem)) BodyDict.Add(config.StarSystem, new List<NewHorizonsBody>());
|
||||||
BodyDict[config.StarSystem].Add(new NewHorizonsBody(config, mod.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName));
|
BodyDict[config.StarSystem].Add(new NewHorizonsBody(config, mod.ModHelper));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -449,7 +451,7 @@ namespace NewHorizons
|
|||||||
VolumesBuilder.Make(go, body.Config.Base.SurfaceSize, sphereOfInfluence);
|
VolumesBuilder.Make(go, body.Config.Base.SurfaceSize, sphereOfInfluence);
|
||||||
|
|
||||||
if (body.Config.HeightMap != null)
|
if (body.Config.HeightMap != null)
|
||||||
HeightMapBuilder.Make(go, body.Config.HeightMap, body.Assets);
|
HeightMapBuilder.Make(go, body.Config.HeightMap, body.Mod.Assets);
|
||||||
|
|
||||||
if (body.Config.ProcGen != null)
|
if (body.Config.ProcGen != null)
|
||||||
ProcGenBuilder.Make(go, body.Config.ProcGen);
|
ProcGenBuilder.Make(go, body.Config.ProcGen);
|
||||||
@ -496,10 +498,10 @@ namespace NewHorizons
|
|||||||
private GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb)
|
private GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb)
|
||||||
{
|
{
|
||||||
if (body.Config.Ring != null)
|
if (body.Config.Ring != null)
|
||||||
RingBuilder.Make(go, body.Config.Ring, body.Assets);
|
RingBuilder.Make(go, body.Config.Ring, body.Mod.Assets);
|
||||||
|
|
||||||
if (body.Config.AsteroidBelt != null)
|
if (body.Config.AsteroidBelt != null)
|
||||||
AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Assets, body.ModUniqueName);
|
AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Mod);
|
||||||
|
|
||||||
if (body.Config.Base.HasCometTail)
|
if (body.Config.Base.HasCometTail)
|
||||||
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||||
@ -515,7 +517,7 @@ namespace NewHorizons
|
|||||||
|
|
||||||
if (body.Config.Atmosphere.Cloud != null)
|
if (body.Config.Atmosphere.Cloud != null)
|
||||||
{
|
{
|
||||||
CloudsBuilder.Make(go, sector, body.Config.Atmosphere, body.Assets);
|
CloudsBuilder.Make(go, sector, body.Config.Atmosphere, body.Mod.Assets);
|
||||||
SunOverrideBuilder.Make(go, sector, body.Config.Base.SurfaceSize, body.Config.Atmosphere);
|
SunOverrideBuilder.Make(go, sector, body.Config.Base.SurfaceSize, body.Config.Atmosphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,10 +531,10 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (body.Config.Props != null)
|
if (body.Config.Props != null)
|
||||||
PropBuilder.Make(go, sector, body.Config, body.Assets, body.ModUniqueName);
|
PropBuilder.Make(go, sector, body.Config, body.Mod.Assets, body.Mod.Manifest.UniqueName);
|
||||||
|
|
||||||
if (body.Config.Signal != null)
|
if (body.Config.Signal != null)
|
||||||
SignalBuilder.Make(go, sector, body.Config.Signal, body.Assets);
|
SignalBuilder.Make(go, sector, body.Config.Signal, body.Mod);
|
||||||
|
|
||||||
if (body.Config.Base.BlackHoleSize != 0 || body.Config.Singularity != null)
|
if (body.Config.Base.BlackHoleSize != 0 || body.Config.Singularity != null)
|
||||||
SingularityBuilder.Make(go, sector, rb, body.Config);
|
SingularityBuilder.Make(go, sector, rb, body.Config);
|
||||||
@ -549,7 +551,8 @@ namespace NewHorizons
|
|||||||
_currentStarSystem = newStarSystem;
|
_currentStarSystem = newStarSystem;
|
||||||
_isChangingStarSystem = true;
|
_isChangingStarSystem = true;
|
||||||
_isWarping = warp;
|
_isWarping = warp;
|
||||||
Locator.GetDeathManager().KillPlayer(DeathType.Meditation);
|
// If the player isn't in the ship we kill them so they don't move as much
|
||||||
|
if(!warp) Locator.GetDeathManager().KillPlayer(DeathType.Meditation);
|
||||||
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
|
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +578,7 @@ namespace NewHorizons
|
|||||||
Logger.Log("Recieved API request to create planet " + (string)config["Name"], Logger.LogType.Log);
|
Logger.Log("Recieved API request to create planet " + (string)config["Name"], Logger.LogType.Log);
|
||||||
var planetConfig = new PlanetConfig(config);
|
var planetConfig = new PlanetConfig(config);
|
||||||
|
|
||||||
var body = new NewHorizonsBody(planetConfig, mod != null ? mod.ModHelper.Assets : Main.Instance.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName);
|
var body = new NewHorizonsBody(planetConfig, mod != null ? mod.ModHelper : Main.Instance.ModHelper);
|
||||||
|
|
||||||
if (!Main.BodyDict.ContainsKey(body.Config.StarSystem)) Main.BodyDict.Add(body.Config.StarSystem, new List<NewHorizonsBody>());
|
if (!Main.BodyDict.ContainsKey(body.Config.StarSystem)) Main.BodyDict.Add(body.Config.StarSystem, new List<NewHorizonsBody>());
|
||||||
Main.BodyDict[body.Config.StarSystem].Add(body);
|
Main.BodyDict[body.Config.StarSystem].Add(body);
|
||||||
|
|||||||
91
NewHorizons/Utility/AudioUtility.cs
Normal file
91
NewHorizons/Utility/AudioUtility.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Utility
|
||||||
|
{
|
||||||
|
public static class AudioUtility
|
||||||
|
{
|
||||||
|
// Thank you https://answers.unity.com/questions/737002/wav-byte-to-audioclip.html?_ga=2.94866780.194866897.1641426110-1837936344.1635819725
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
short s = (short)((secondByte << 8) | firstByte);
|
||||||
|
// convert to range from -1 to (just below) 1
|
||||||
|
return s / 32768.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bytesToInt(byte[] bytes, int offset = 0)
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
value |= ((int)bytes[offset + i]) << (i * 8);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] GetBytes(string filename)
|
||||||
|
{
|
||||||
|
return File.ReadAllBytes(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns left and right double arrays. 'right' will be null if sound is mono.
|
||||||
|
public static AudioClip LoadWAV(string filename)
|
||||||
|
{
|
||||||
|
var wav = GetBytes(filename);
|
||||||
|
|
||||||
|
// Determine if mono or stereo
|
||||||
|
var ChannelCount = wav[22]; // Forget byte 23 as 99.999% of WAVs are 1 or 2 channels
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,16 +6,14 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
public class NewHorizonsBody
|
public class NewHorizonsBody
|
||||||
{
|
{
|
||||||
public NewHorizonsBody(IPlanetConfig config, IModAssets assets, string modUniqueName)
|
public NewHorizonsBody(IPlanetConfig config, IModHelper mod)
|
||||||
{
|
{
|
||||||
Config = config;
|
Config = config;
|
||||||
Assets = assets;
|
Mod = mod;
|
||||||
ModUniqueName = modUniqueName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPlanetConfig Config;
|
public IPlanetConfig Config;
|
||||||
public IModAssets Assets;
|
public IModHelper Mod;
|
||||||
public string ModUniqueName;
|
|
||||||
|
|
||||||
public GameObject Object;
|
public GameObject Object;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ namespace NewHorizons.Utility
|
|||||||
// Postfixes
|
// Postfixes
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("EnterMode", typeof(Patches), nameof(Patches.OnShipLogMapModeEnterMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
|
public static bool GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
|
||||||
@ -356,6 +357,8 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
ShipLogMode currentMode = __instance._currentMode;
|
ShipLogMode currentMode = __instance._currentMode;
|
||||||
string focusedEntryID = currentMode.GetFocusedEntryID();
|
string focusedEntryID = currentMode.GetFocusedEntryID();
|
||||||
|
Logger.Log($"[{focusedEntryID}]");
|
||||||
|
if (!focusedEntryID.Equals("")) return true;
|
||||||
bool flag = currentMode.Equals(__instance._mapMode);
|
bool flag = currentMode.Equals(__instance._mapMode);
|
||||||
__instance._currentMode = (flag ? __instance._detectiveMode : __instance._mapMode);
|
__instance._currentMode = (flag ? __instance._detectiveMode : __instance._mapMode);
|
||||||
|
|
||||||
@ -399,5 +402,13 @@ namespace NewHorizons.Utility
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OnShipLogMapModeEnterMode(ShipLogMapMode __instance)
|
||||||
|
{
|
||||||
|
var newPrompt = "Interstellar Mode";
|
||||||
|
__instance._detectiveModePrompt.SetText(newPrompt);
|
||||||
|
var text = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/ScreenPromptListScaleRoot/ScreenPromptList_UpperRight/ScreenPrompt/Text").GetComponent<UnityEngine.UI.Text>();
|
||||||
|
text.text = newPrompt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"author": "xen",
|
"author": "xen",
|
||||||
"name": "New Horizons",
|
"name": "New Horizons",
|
||||||
"uniqueName": "xen.NewHorizons",
|
"uniqueName": "xen.NewHorizons",
|
||||||
"version": "0.5.3",
|
"version": "0.6.0",
|
||||||
"owmlVersion": "2.1.0",
|
"owmlVersion": "2.1.0",
|
||||||
"dependencies": [ "PacificEngine.OW_CommonResources" ]
|
"dependencies": [ "PacificEngine.OW_CommonResources" ]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user