Black hole fixes (#653)

<!-- A new module or something else important -->
## Major features
-

<!-- A new parameter added to a module, or API feature -->
## Minor features
-

<!-- Some improvement that requires no action on the part of add-on
creators i.e., improved star graphics -->
## Improvements
- Black hole vanish effects now tied to the size of the black hole.
Fixes #215.
- Black hole ambience pitch isn't weirdly high for large black holes
anymore. Fixes #226.
- Change system black holes now make a sound when entering them.

<!-- Be sure to reference the existing issue if it exists -->
## Bug fixes
-
This commit is contained in:
Nick 2023-07-19 23:24:28 -04:00 committed by GitHub
commit 2082884e02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 5 deletions

View File

@ -175,6 +175,10 @@ namespace NewHorizons.Builder.Body
var singularityAudioSource = singularityAmbience.GetComponent<AudioSource>(); var singularityAudioSource = singularityAmbience.GetComponent<AudioSource>();
singularityAudioSource.maxDistance = distort * 2.5f; singularityAudioSource.maxDistance = distort * 2.5f;
singularityAudioSource.minDistance = horizon; singularityAudioSource.minDistance = horizon;
// Sounds really weird on large black holes but isn't noticeable on small ones. #226
singularityAudioSource.dopplerLevel = 0;
singularityAmbience.transform.localPosition = Vector3.zero; singularityAmbience.transform.localPosition = Vector3.zero;
if (sizeController != null) sizeController.audioSource = singularityAudioSource; if (sizeController != null) sizeController.audioSource = singularityAudioSource;
@ -193,7 +197,15 @@ namespace NewHorizons.Builder.Body
sphereCollider.isTrigger = true; sphereCollider.isTrigger = true;
if (sizeController != null) sizeController.sphereCollider = sphereCollider; if (sizeController != null) sizeController.sphereCollider = sphereCollider;
if (hasDestructionVolume) destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>(); var audio = destructionVolumeGO.AddComponent<AudioSource>();
audio.spatialBlend = 1f;
audio.maxDistance = distort * 2.5f;
destructionVolumeGO.AddComponent<OWAudioSource>();
if (hasDestructionVolume)
{
destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>();
}
else if (targetStarSystem != null) else if (targetStarSystem != null)
{ {
var wormholeVolume = destructionVolumeGO.AddComponent<BlackHoleWarpVolume>(); var wormholeVolume = destructionVolumeGO.AddComponent<BlackHoleWarpVolume>();
@ -213,8 +225,19 @@ namespace NewHorizons.Builder.Body
var blackHoleVolume = Object.Instantiate(_blackHoleVolume, singularity.transform); var blackHoleVolume = Object.Instantiate(_blackHoleVolume, singularity.transform);
blackHoleVolume.name = "BlackHoleVolume"; blackHoleVolume.name = "BlackHoleVolume";
blackHoleVolume.SetActive(true);
// Scale vanish effect to black hole size
var bhVolume = blackHoleVolume.GetComponent<BlackHoleVolume>(); var bhVolume = blackHoleVolume.GetComponent<BlackHoleVolume>();
foreach (var ps in bhVolume._vanishEffectPrefab.GetComponentsInChildren<ParticleSystem>())
{
#pragma warning disable CS0618 // Type or member is obsolete - It tells you to use some readonly shit instead
ps.scalingMode = ParticleSystemScalingMode.Hierarchy;
#pragma warning restore CS0618 // Type or member is obsolete
}
bhVolume._vanishEffectPrefab.transform.localScale = Vector3.one * horizon / 100f;
blackHoleVolume.SetActive(true);
bhVolume._audioSector = sector; bhVolume._audioSector = sector;
bhVolume._emissionSource = oneShotOWAudioSource; bhVolume._emissionSource = oneShotOWAudioSource;
var blackHoleSphereCollider = blackHoleVolume.GetComponent<SphereCollider>(); var blackHoleSphereCollider = blackHoleVolume.GetComponent<SphereCollider>();

View File

@ -1,21 +1,28 @@
using NewHorizons.OtherMods.AchievementsPlus.NH; using NewHorizons.OtherMods.AchievementsPlus.NH;
using UnityEngine;
namespace NewHorizons.Components.Volumes namespace NewHorizons.Components.Volumes
{ {
public class BlackHoleDestructionVolume : DestructionVolume public class BlackHoleDestructionVolume : DestructionVolume
{ {
protected OWAudioSource _audio;
public override void Awake() public override void Awake()
{ {
base.Awake(); base.Awake();
_deathType = DeathType.BlackHole; _deathType = DeathType.BlackHole;
_audio = GetComponent<OWAudioSource>();
} }
public override void VanishProbe(OWRigidbody probeBody, RelativeLocationData entryLocation) public override void VanishProbe(OWRigidbody probeBody, RelativeLocationData entryLocation)
{ {
SurveyorProbe requiredComponent = probeBody.GetRequiredComponent<SurveyorProbe>(); var probe = probeBody.GetRequiredComponent<SurveyorProbe>();
if (requiredComponent.IsLaunched())
_audio.PlayOneShot(AudioType.BH_BlackHoleEmission, 1f);
if (probe.IsLaunched())
{ {
Destroy(requiredComponent.gameObject); Destroy(probe.gameObject);
ProbeLostAchievement.Earn(); ProbeLostAchievement.Earn();
} }
} }

View File

@ -17,6 +17,7 @@ namespace NewHorizons.Components.Volumes
public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation) public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation)
{ {
Locator.GetPlayerAudioController().PlayOneShotInternal(AudioType.BH_BlackHoleEmission);
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole()); Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
} }
} }