Merge pull request #144 from xen-42/dev

Bug fixes
This commit is contained in:
Nick 2022-05-19 18:03:23 -04:00 committed by GitHub
commit 3c30ceac89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 246 additions and 132 deletions

View File

@ -7,7 +7,6 @@ namespace NewHorizons.Builder.Atmosphere
public static void Make(GameObject planetGO, PlanetConfig config, float sphereOfInfluence)
{
var innerRadius = config.Base.SurfaceSize;
var useMiniMap = !config.Base.IsSatellite;
GameObject volumesGO = new GameObject("Volumes");
volumesGO.SetActive(false);
@ -29,8 +28,10 @@ namespace NewHorizons.Builder.Atmosphere
PlanetoidRuleset PR = rulesetGO.AddComponent<PlanetoidRuleset>();
PR._altitudeFloor = innerRadius;
PR._altitudeCeiling = sphereOfInfluence;
PR._useMinimap = useMiniMap;
PR._useAltimeter = useMiniMap;
PR._useMinimap = config.Base.ShowMinimap;
PR._useAltimeter = config.Base.ShowMinimap;
rulesetGO.AddComponent<AntiTravelMusicRuleset>();
EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>();
ER._type = EffectRuleset.BubbleType.Underwater;

View File

@ -33,7 +33,7 @@ namespace NewHorizons.Builder.Body
var ringShape = ringVolume.AddComponent<RingShape>();
ringShape.innerRadius = ring.InnerRadius;
ringShape.outerRadius = ring.OuterRadius;
ringShape.height = 2f;
ringShape.height = 20f;
ringShape.center = Vector3.zero;
ringShape.SetCollisionMode(Shape.CollisionMode.Volume);
ringShape.SetLayer(Shape.Layer.Default);
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Body
}
sfv._fluidType = fluidType;
sfv._density = 1f;
sfv._density = 5f;
ringVolume.SetActive(true);

View File

@ -3,7 +3,7 @@ namespace NewHorizons.Builder.General
{
public static class AmbientLightBuilder
{
public static void Make(GameObject planetGO, Sector sector, float scale)
public static void Make(GameObject planetGO, Sector sector, float scale, float intensity)
{
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform);
lightGO.transform.position = planetGO.transform.position;
@ -19,7 +19,7 @@ namespace NewHorizons.Builder.General
light.color = new Color(0.0f, 0.0f, 0.8f, 0.0225f);
light.range = scale;
light.intensity = 0.5f;
light.intensity = intensity;
}
}
}

View File

@ -15,7 +15,7 @@ namespace NewHorizons.Builder.General
var type = AstroObject.Type.Planet;
if (config.Orbit.IsMoon) type = AstroObject.Type.Moon;
else if (config.Base.IsSatellite) type = AstroObject.Type.Satellite;
// else if (config.Base.IsSatellite) type = AstroObject.Type.Satellite;
else if (config.Base.HasCometTail) type = AstroObject.Type.Comet;
else if (config.Star != null) type = AstroObject.Type.Star;
else if (config.FocalPoint != null) type = AstroObject.Type.None;

View File

@ -24,10 +24,12 @@ namespace NewHorizons.Builder.General
{
markerType = MapMarker.MarkerType.HourglassTwins;
}
/*
else if (config.Base.IsSatellite)
{
markerType = MapMarker.MarkerType.Probe;
}
*/
mapMarker._markerType = markerType;
}

View File

@ -18,7 +18,16 @@ namespace NewHorizons.Builder.General
spawnGO.transform.localPosition = module.PlayerSpawnPoint;
playerSpawn = spawnGO.AddComponent<SpawnPoint>();
spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (playerSpawn.transform.position - planetGO.transform.position).normalized);
if(module.PlayerSpawnRotation != null)
{
spawnGO.transform.rotation = Quaternion.Euler(module.PlayerSpawnRotation);
}
else
{
spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (playerSpawn.transform.position - planetGO.transform.position).normalized);
}
spawnGO.transform.position = spawnGO.transform.position + spawnGO.transform.TransformDirection(Vector3.up) * 4f;
}
if (module.ShipSpawnPoint != null)
@ -34,9 +43,17 @@ namespace NewHorizons.Builder.General
var ship = GameObject.Find("Ship_Body");
ship.transform.position = spawnPoint.transform.position;
ship.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - planetGO.transform.position).normalized);
// Move it up a bit more
ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 4f;
if(module.ShipSpawnRotation != null)
{
ship.transform.rotation = Quaternion.Euler(module.ShipSpawnRotation);
}
else
{
ship.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - planetGO.transform.position).normalized);
// Move it up a bit more when aligning to surface
ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 4f;
}
ship.GetRequiredComponent<MatchInitialMotion>().SetBodyToMatch(owRigidBody);

View File

@ -1,19 +1,26 @@
using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Builder.Orbital
{
public static class OrbitlineBuilder
{
private static Material _dottedLineMaterial;
private static Material _lineMaterial;
public static OrbitLine Make(GameObject planetGO, NHAstroObject astroObject, bool isMoon, PlanetConfig config)
{
if (_dottedLineMaterial == null) _dottedLineMaterial = SearchUtilities.FindResourceOfTypeAndName<Material>("Effects_SPA_OrbitLine_Dotted_mat");
if (_lineMaterial == null) _lineMaterial = SearchUtilities.FindResourceOfTypeAndName<Material>("Effects_SPA_OrbitLine_mat");
GameObject orbitGO = new GameObject("Orbit");
orbitGO.transform.parent = planetGO.transform;
orbitGO.transform.localPosition = Vector3.zero;
var lineRenderer = orbitGO.AddComponent<LineRenderer>();
lineRenderer.material = config.Orbit.DottedOrbitLine ? GameObject.Find("HearthianMapSatellite_Body/OrbitLine").GetComponent<LineRenderer>().material : GameObject.Find("OrbitLine_CO").GetComponent<LineRenderer>().material;
lineRenderer.material = new Material(config.Orbit.DottedOrbitLine ? _dottedLineMaterial : _lineMaterial);
lineRenderer.textureMode = config.Orbit.DottedOrbitLine ? LineTextureMode.RepeatPerSegment : LineTextureMode.Stretch;
var width = config.Orbit.DottedOrbitLine ? 100 : 50;
@ -53,12 +60,14 @@ namespace NewHorizons.Builder.Orbital
if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor32();
else if (config.Star != null) color = config.Star.Tint.ToColor32();
else if (config.Atmosphere != null && config.Atmosphere.CloudTint != null) color = config.Atmosphere.CloudTint.ToColor32();
else if (config.Base.BlackHoleSize != 0 || config.Singularity != null) color = new Color(1f, 0.5f, 1f);
else if (config.Base.WaterSize != 0) color = new Color(0.5f, 0.5f, 1f);
else if (config.Base.LavaSize != 0) color = new Color(1f, 0.5f, 0.5f);
else if (config.Singularity != null) color = new Color(1f, 0.5f, 1f);
else if (config.Water != null) color = new Color(0.5f, 0.5f, 1f);
else if (config.Lava != null) color = new Color(1f, 0.5f, 0.5f);
else if (config.Atmosphere != null && config.Atmosphere.FogTint != null) color = config.Atmosphere.FogTint.ToColor32();
var fade = isMoon;
/*
if (config.Base.IsSatellite)
{
if (config.Orbit.Tint != null) color = new Color(0.4082f, 0.516f, 0.4469f, 1f);
@ -66,6 +75,7 @@ namespace NewHorizons.Builder.Orbital
orbitLine._fadeEndDist = 5000;
orbitLine._fadeStartDist = 3000;
}
*/
orbitLine._color = color;

View File

@ -142,10 +142,12 @@ namespace NewHorizons.Builder.Props
var source = signalGO.AddComponent<AudioSource>();
var owAudioSource = signalGO.AddComponent<OWAudioSource>();
owAudioSource._audioSource = source;
AudioSignal audioSignal;
if (info.InsideCloak) audioSignal = signalGO.AddComponent<CloakedAudioSignal>();
else audioSignal = signalGO.AddComponent<AudioSignal>();
audioSignal._owAudioSource = owAudioSource;
var frequency = StringToFrequency(info.Frequency);
var name = StringToSignalName(info.Name);

View File

@ -107,6 +107,8 @@ namespace NewHorizons.Components
if (newState.orbit != null && newState.orbit != oldState.orbit) SetNewOrbit(primaryBody, orbitalParams);
_currentIndex = newIndex;
GlobalMessenger<OWRigidbody>.FireEvent("QuantumMoonChangeState", _rb);
}
// Be completely sure we move the visibility tracker back to our planet

View File

@ -87,9 +87,9 @@ namespace NewHorizons.Components
*/
}
public void AddSystemCard(string starSystem)
public void AddSystemCard(string uniqueID)
{
var card = CreateCard(starSystem, root.transform, new Vector2(_nextCardIndex++ * 200, 0));
var card = CreateCard(uniqueID, root.transform, new Vector2(_nextCardIndex++ * 200, 0));
_starSystemCards.Add(card);
}
@ -132,7 +132,7 @@ namespace NewHorizons.Components
}
}
public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position)
public GameObject CreateCard(string uniqueID, Transform parent, Vector2 position)
{
if (_cardTemplate == null)
{
@ -143,12 +143,14 @@ namespace NewHorizons.Components
var newCard = GameObject.Instantiate(_cardTemplate, parent);
var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>();
var name = UniqueNameToString(uniqueName);
var name = UniqueIDToName(uniqueID);
textComponent.text = name;
if (name.Length > 17) textComponent.fontSize = 10;
newCard.SetActive(true);
newCard.transform.name = uniqueName;
newCard.transform.name = uniqueID;
newCard.transform.localPosition = new Vector3(position.x, position.y, 40);
newCard.transform.localRotation = Quaternion.Euler(0, 0, 0);
@ -157,15 +159,15 @@ namespace NewHorizons.Components
Texture texture = null;
try
{
if (uniqueName.Equals("SolarSystem"))
if (uniqueID.Equals("SolarSystem"))
{
texture = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/hearthian system.png");
}
else
{
var path = $"planets/{uniqueName}.png";
var path = $"planets/{uniqueID}.png";
Logger.Log($"Trying to load {path}");
texture = ImageUtilities.GetTexture(Main.SystemDict[uniqueName].Mod, path);
texture = ImageUtilities.GetTexture(Main.SystemDict[uniqueID].Mod, path);
}
}
catch (Exception) { }
@ -272,13 +274,19 @@ namespace NewHorizons.Components
}
}
public string UniqueNameToString(string uniqueName)
public string UniqueIDToName(string uniqueID)
{
if (uniqueName.Equals("SolarSystem")) return "Hearthian System";
var name = TranslationHandler.GetTranslation(uniqueID, TranslationHandler.TextType.UI);
var splitString = uniqueName.Split('.');
// If it can't find a translation it just returns the key
if (!name.Equals(uniqueID)) return name;
// Else we return a default name
if (uniqueID.Equals("SolarSystem")) return "Hearthian System";
var splitString = uniqueID.Split('.');
if (splitString.Length > 1) splitString = splitString.Skip(1).ToArray();
var name = string.Join("", splitString).SplitCamelCase();
name = string.Join("", splitString).SplitCamelCase();
return name;
}
@ -308,10 +316,10 @@ namespace NewHorizons.Components
Locator._rfTracker.UntargetReferenceFrame();
GlobalMessenger.FireEvent("UntargetReferenceFrame");
_warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueNameToString(shipLogEntryCard.name).ToUpper()}");
_warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueIDToName(shipLogEntryCard.name).ToUpper()}");
NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true);
_warpPrompt.SetText($"<CMD> Engage Warp To {UniqueNameToString(shipLogEntryCard.name)}");
_warpPrompt.SetText($"<CMD> Engage Warp To {UniqueIDToName(shipLogEntryCard.name)}");
}
private void RemoveWarpTarget(bool playSound = false)

View File

@ -32,9 +32,9 @@ namespace NewHorizons.External.Configs
public SandModule Sand { get; set; }
public FunnelModule Funnel { get; set; }
// Obsolete
public string[] ChildrenToDestroy { get; set; }
#region Obsolete
[System.Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] public string[] ChildrenToDestroy { get; set; }
#endregion Obsolete
public PlanetConfig()
{
@ -48,6 +48,9 @@ namespace NewHorizons.External.Configs
{
if (Base.CenterOfSolarSystem) Orbit.IsStatic = true;
// Backwards compatability
// Should be the only place that obsolete things are referenced
#pragma warning disable 612, 618
if (Base.WaterSize != 0)
{
Water = new WaterModule();
@ -77,6 +80,12 @@ namespace NewHorizons.External.Configs
{
RemoveChildren = ChildrenToDestroy;
}
if (Base.HasAmbientLight)
{
Base.AmbientLight = 0.5f;
}
#pragma warning restore 612, 618
}
}
}

View File

@ -7,6 +7,7 @@
public bool destroyStockPlanets = true;
public string factRequiredForWarp;
public bool enableTimeLoop = true;
public bool mapRestricted;
public NomaiCoordinates coords;
public SkyboxConfig skybox;

View File

@ -4,7 +4,7 @@ namespace NewHorizons.External.Modules
public class BaseModule
{
public bool HasMapMarker { get; set; }
public bool HasAmbientLight { get; set; }
public float AmbientLight { get; set; }
public float SurfaceGravity { get; set; }
public string GravityFallOff { get; set; } = "linear";
public float SurfaceSize { get; set; }
@ -18,12 +18,13 @@ namespace NewHorizons.External.Modules
public bool InvulnerableToSun { get; set; }
public bool ShowMinimap { get; set; } = true;
// Obsolete
public bool IsSatellite { get; set; }
public float BlackHoleSize { get; set; }
public float LavaSize { get; set; }
public float WaterSize { get; set; }
public MColor WaterTint { get; set; }
#region Obsolete
[System.Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")] public bool IsSatellite { get; set; }
[System.Obsolete("BlackHoleSize is deprecated, please use SingularityModule instead")] public float BlackHoleSize { get; set; }
[System.Obsolete("LavaSize is deprecated, please use LavaModule instead")] public float LavaSize { get; set; }
[System.Obsolete("WaterTint is deprecated, please use WaterModule instead")] public float WaterSize { get; set; }
[System.Obsolete("WaterTint is deprecated, please use WaterModule instead")] public MColor WaterTint { get; set; }
[System.Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")] public bool HasAmbientLight { get; set; }
#endregion Obsolete
}
}

View File

@ -4,7 +4,9 @@ namespace NewHorizons.External.Modules
public class SpawnModule
{
public MVector3 PlayerSpawnPoint { get; set; }
public MVector3 PlayerSpawnRotation { get; set; }
public MVector3 ShipSpawnPoint { get; set; }
public MVector3 ShipSpawnRotation { get; set; }
public bool StartWithSuit { get; set; }
}
}

View File

@ -378,9 +378,9 @@ namespace NewHorizons.Handlers
{
var sphereOfInfluence = GetSphereOfInfluence(body);
if (body.Config.Base.HasAmbientLight)
if (body.Config.Base.AmbientLight != 0)
{
AmbientLightBuilder.Make(go, sector, sphereOfInfluence);
AmbientLightBuilder.Make(go, sector, sphereOfInfluence, body.Config.Base.AmbientLight);
}
if (body.Config.Base.GroundSize != 0)

View File

@ -69,87 +69,107 @@ namespace NewHorizons.Handlers
try
{
if (ao.GetAstroObjectName() == AstroObject.Name.BrittleHollow)
switch(ao._name)
{
RemoveBody(AstroObjectLocator.GetAstroObject(AstroObject.Name.WhiteHole.ToString()), delete, toDestroy);
}
else if (ao.GetAstroObjectName() == AstroObject.Name.CaveTwin || ao.GetAstroObjectName() == AstroObject.Name.TowerTwin)
{
DisableBody(GameObject.Find("FocalBody"), delete);
DisableBody(GameObject.Find("SandFunnel_Body"), delete);
}
else if (ao.GetAstroObjectName() == AstroObject.Name.MapSatellite)
{
DisableBody(GameObject.Find("MapSatellite_Body"), delete);
}
else if (ao.GetAstroObjectName() == AstroObject.Name.GiantsDeep)
{
foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>())
{
DisableBody(jelly.gameObject, delete);
}
}
else if (ao.GetAstroObjectName() == AstroObject.Name.TimberHearth)
{
// Always just fucking kill this one to stop THE WARP BUG!!!
DisableBody(GameObject.Find("StreamingGroup_TH"), true);
case AstroObject.Name.BrittleHollow:
RemoveBody(AstroObjectLocator.GetAstroObject(AstroObject.Name.WhiteHole.ToString()), delete, toDestroy);
// Might prevent leftover fragments from existing
// Might also prevent people from using their own detachable fragments however
foreach(var fragment in GameObject.FindObjectsOfType<DetachableFragment>())
{
DisableBody(fragment.gameObject, delete);
}
break;
case AstroObject.Name.CaveTwin:
case AstroObject.Name.TowerTwin:
DisableBody(GameObject.Find("FocalBody"), delete);
DisableBody(GameObject.Find("SandFunnel_Body"), delete);
break;
case AstroObject.Name.MapSatellite:
DisableBody(GameObject.Find("MapSatellite_Body"), delete);
break;
case AstroObject.Name.GiantsDeep:
// Might prevent leftover jellyfish from existing
// Might also prevent people from using their own jellyfish however
foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>())
{
DisableBody(jelly.gameObject, delete);
}
// Else it will re-eanble the pieces
// ao.GetComponent<OrbitalProbeLaunchController>()._realDebrisSectorProxies = null;
break;
case AstroObject.Name.TimberHearth:
// Always just fucking kill this one to stop THE WARP BUG!!!
DisableBody(GameObject.Find("StreamingGroup_TH"), true);
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
{
DisableBody(obj.gameObject, true);
}
foreach (var obj in GameObject.FindObjectsOfType<VillageMusicVolume>())
{
DisableBody(obj.gameObject, true);
}
}
else if (ao.GetAstroObjectName() == AstroObject.Name.Sun)
{
var starController = ao.gameObject.GetComponent<StarController>();
StarLightController.RemoveStar(starController);
GameObject.Destroy(starController);
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
{
DisableBody(obj.gameObject, true);
}
foreach (var obj in GameObject.FindObjectsOfType<VillageMusicVolume>())
{
DisableBody(obj.gameObject, true);
}
break;
case AstroObject.Name.Sun:
var starController = ao.gameObject.GetComponent<StarController>();
StarLightController.RemoveStar(starController);
GameObject.Destroy(starController);
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();
GameObject.Destroy(audio);
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();
GameObject.Destroy(audio);
foreach (var owAudioSource in ao.GetComponentsInChildren<OWAudioSource>())
{
owAudioSource.Stop();
GameObject.Destroy(owAudioSource);
}
foreach (var owAudioSource in ao.GetComponentsInChildren<OWAudioSource>())
{
owAudioSource.Stop();
GameObject.Destroy(owAudioSource);
}
foreach (var audioSource in ao.GetComponentsInChildren<AudioSource>())
{
audioSource.Stop();
GameObject.Destroy(audioSource);
}
foreach (var audioSource in ao.GetComponentsInChildren<AudioSource>())
{
audioSource.Stop();
GameObject.Destroy(audioSource);
}
foreach (var sunProxy in GameObject.FindObjectsOfType<SunProxy>())
{
Logger.Log($"Destroying SunProxy {sunProxy.gameObject.name}");
GameObject.Destroy(sunProxy.gameObject);
}
foreach (var sunProxy in GameObject.FindObjectsOfType<SunProxy>())
{
Logger.Log($"Destroying SunProxy {sunProxy.gameObject.name}");
GameObject.Destroy(sunProxy.gameObject);
}
// Stop the sun from breaking stuff when the supernova gets triggered
GlobalMessenger.RemoveListener("TriggerSupernova", ao.GetComponent<SunController>().OnTriggerSupernova);
// Stop the sun from breaking stuff when the supernova gets triggered
GlobalMessenger.RemoveListener("TriggerSupernova", ao.GetComponent<SunController>().OnTriggerSupernova);
break;
}
// Just delete the children
// Always delete the children
Logger.Log($"Removing Children of [{ao._name}], [{ao._customName}]");
foreach (var child in AstroObjectLocator.GetChildren(ao))
{
if (child == null) continue;
Logger.Log($"Removing child [{child.name}] of [{ao._name}]");
// Ship starts as a child of TH but obvious we want to keep that
if (child.name == "Ship_Body") continue;
DisableBody(child, true);
// Some children might be astro objects and as such can have children of their own
var childAO = child.GetComponent<AstroObject>();
if (childAO != null) RemoveBody(childAO, false, toDestroy);
else DisableBody(child, true);
}
// Delete moons
// Always delete moons
foreach (var obj in AstroObjectLocator.GetMoons(ao))
{
if (obj == null) continue;
RemoveBody(obj.GetComponent<AstroObject>(), false, toDestroy);
}
}
catch (Exception e)
{
Logger.LogWarning($"Exception thrown when trying to delete bodies related to [{ao.name}]: {e.Message}, {e.StackTrace}");
Logger.LogError($"Exception thrown when trying to delete bodies related to [{ao.name}]: {e.Message}, {e.StackTrace}");
}
// Deal with proxies
@ -188,7 +208,12 @@ namespace NewHorizons.Handlers
{
if (go == null) return;
if (delete) GameObject.Destroy(go);
Logger.Log($"Removing [{go.name}]");
if (delete)
{
GameObject.Destroy(go);
}
else
{
go.SetActive(false);

View File

@ -54,7 +54,7 @@ namespace NewHorizons.Handlers
{
if (system.Config.factRequiredForWarp != default)
{
RegisterFactForSystem(system.Config.factRequiredForWarp, system.Name);
RegisterFactForSystem(system.Config.factRequiredForWarp, system.UniqueID);
}
}
@ -68,7 +68,7 @@ namespace NewHorizons.Handlers
{
foreach (var system in _systems)
{
if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null && HasUnlockedSystem(system.Name))
if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null && HasUnlockedSystem(system.UniqueID))
{
return true;
}

View File

@ -228,8 +228,6 @@ namespace NewHorizons
SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]);
LoadTranslations(ModHelper.Manifest.ModFolderPath + "AssetBundle/", this);
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => Locator.GetPlayerBody().gameObject.AddComponent<DebugRaycaster>());
// Warp drive
StarChartHandler.Init(SystemDict.Values.ToArray());
HasWarpDrive = StarChartHandler.CanWarp();
@ -237,20 +235,9 @@ namespace NewHorizons
_shipWarpController.Init();
if (HasWarpDrive == true) EnableWarpDrive();
if (IsWarping && _shipWarpController)
{
Instance.ModHelper.Events.Unity.RunWhen(
() => IsSystemReady,
() => _shipWarpController.WarpIn(WearingSuit)
);
}
else
{
Instance.ModHelper.Events.Unity.RunWhen(
() => IsSystemReady,
() => FindObjectOfType<PlayerSpawner>().DebugWarp(SystemDict[_currentStarSystem].SpawnPoint)
);
}
var shouldWarpIn = IsWarping && _shipWarpController != null;
Instance.ModHelper.Events.Unity.RunWhen(() => IsSystemReady, () => OnSystemReady(shouldWarpIn));
IsWarping = false;
var map = GameObject.FindObjectOfType<MapController>();
@ -275,6 +262,15 @@ namespace NewHorizons
}
}
// Had a bunch of separate unity things firing stuff when the system is ready so I moved it all to here
private void OnSystemReady(bool shouldWarpIn)
{
Locator.GetPlayerBody().gameObject.AddComponent<DebugRaycaster>();
if (shouldWarpIn) _shipWarpController.WarpIn(WearingSuit);
else FindObjectOfType<PlayerSpawner>().DebugWarp(SystemDict[_currentStarSystem].SpawnPoint);
}
public void EnableWarpDrive()
{
Logger.Log("Setting up warp drive");

View File

@ -125,5 +125,12 @@ namespace NewHorizons.Patches
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(TravelerAudioManager), nameof(TravelerAudioManager.Update))]
public static void TravelerAudioManager_Update(TravelerAudioManager __instance)
{
__instance._signals.RemoveAll(signal => signal == null || signal.gameObject == null || signal._owAudioSource == null || signal._owAudioSource._audioSource == null);
}
}
}

View File

@ -21,5 +21,19 @@ namespace NewHorizons.Patches
{
__instance._isLockedOntoMapSatellite = true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MapController), nameof(MapController.MapInoperable))]
public static bool MapController_MapInoperable(MapController __instance, ref bool __result)
{
if(Main.SystemDict[Main.Instance.CurrentStarSystem]?.Config?.mapRestricted ?? false)
{
__instance._playerMapRestricted = true;
__result = true;
return false;
}
return true;
}
}
}

View File

@ -209,10 +209,10 @@
"default": false,
"description": "If the body should have a marker on the map screen."
},
"hasAmbientLight": {
"type": "boolean",
"default": false,
"description": "If the dark side of the body should have some slight amount of light"
"ambientLight": {
"type": "number",
"default": 0,
"description": "The intensity of light the dark side of the body should have. Timber Hearth has 1.4 for reference"
},
"surfaceGravity": {
"type": "number",
@ -1099,8 +1099,17 @@
"$ref": "#/$defs/vector3",
"description": "If you want the player to spawn on the new body, set a value for this. Press \"P\" in game with Debug mode on to have the game log the position you're looking at to find a good value for this."
},
"playerSpawnRotation": {
"$ref": "#/$defs/vector3",
"description": "Euler angles by which the player will be oriented."
},
"shipSpawnPoint": {
"$ref": "#/$defs/vector3"
"$ref": "#/$defs/vector3",
"description": "Required for the system to be accessible by warp drive."
},
"shipSpawnRotation": {
"$ref": "#/$defs/vector3",
"description": "Euler angles by which the ship will be oriented."
},
"startWithSuit": {
"type": "boolean",

View File

@ -25,6 +25,11 @@
"description": "Should the player be sent back in time after 22 minutes?",
"default": true
},
"mapRestricted": {
"type": "bool",
"description": "Should the player be unable to use their map in this system?",
"default": false
},
"skybox": {
"type": "object",
"description": "Options for the skybox of your system",

View File

@ -94,7 +94,7 @@ namespace NewHorizons.Utility
if (primary == null) return new GameObject[0];
var otherChildren = new List<GameObject>();
switch (primary.GetAstroObjectName())
switch (primary._name)
{
case AstroObject.Name.TowerTwin:
otherChildren.Add(GameObject.Find("TimeLoopRing_Body"));
@ -129,7 +129,10 @@ namespace NewHorizons.Utility
break;
// For some dumb reason the sun station doesn't use AstroObject.Name.SunStation
case AstroObject.Name.CustomString:
if (primary._customName.Equals("Sun Station")) otherChildren.Add(GameObject.Find("SS_Debris_Body"));
if (primary._customName.Equals("Sun Station"))
{
otherChildren.Add(GameObject.Find("SS_Debris_Body"));
}
break;
default:
break;

View File

@ -5,14 +5,14 @@ namespace NewHorizons.Utility
{
public class NewHorizonsSystem
{
public NewHorizonsSystem(string name, StarSystemConfig config, IModBehaviour mod)
public NewHorizonsSystem(string uniqueID, StarSystemConfig config, IModBehaviour mod)
{
Name = name;
UniqueID = uniqueID;
Config = config;
Mod = mod;
}
public string Name;
public string UniqueID;
public SpawnModule Spawn = null;
public SpawnPoint SpawnPoint = null;
public StarSystemConfig Config;