mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
forgot idgaf and am commiting to dev these days (#650)
…o solar system <!-- 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 - <!-- Be sure to reference the existing issue if it exists --> ## Bug fixes -
This commit is contained in:
commit
a755f150d3
@ -15,6 +15,11 @@ namespace NewHorizons.External.Configs
|
||||
[JsonObject]
|
||||
public class StarSystemConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// In this system should the player be able to rotate their map camera freely or be stuck above the plane of the solar system?
|
||||
/// </summary>
|
||||
public bool freeMapAngle;
|
||||
|
||||
/// <summary>
|
||||
/// An override value for the far clip plane. Allows you to see farther.
|
||||
/// </summary>
|
||||
|
||||
@ -30,9 +30,14 @@ namespace NewHorizons.Handlers
|
||||
// Custom bodies being created
|
||||
private static Dictionary<NHAstroObject, NewHorizonsBody> _customBodyDict;
|
||||
|
||||
// Farthest distance from the center of the solar system
|
||||
public static float FurthestOrbit { get; private set; }
|
||||
public static float DefaultFurthestOrbit => 30000f;
|
||||
|
||||
public static void Init(List<NewHorizonsBody> bodies)
|
||||
{
|
||||
Main.FurthestOrbit = 30000;
|
||||
// Base game value
|
||||
FurthestOrbit = DefaultFurthestOrbit;
|
||||
|
||||
_existingBodyDict = new();
|
||||
_customBodyDict = new();
|
||||
@ -848,9 +853,10 @@ namespace NewHorizons.Handlers
|
||||
go.transform.position = position;
|
||||
}
|
||||
|
||||
if (go.transform.position.magnitude > Main.FurthestOrbit)
|
||||
var distanceToCenter = go.transform.position.magnitude;
|
||||
if (distanceToCenter > FurthestOrbit)
|
||||
{
|
||||
Main.FurthestOrbit = go.transform.position.magnitude + 30000f;
|
||||
FurthestOrbit = distanceToCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -107,5 +107,7 @@ namespace NewHorizons.Handlers
|
||||
_starSystemToFactID.Add(system, factID);
|
||||
_factIDToStarSystem.Add(factID, system);
|
||||
}
|
||||
|
||||
public static bool IsWarpDriveLockedOn() => StarChartHandler.ShipLogStarChartMode.GetTargetStarSystem() != null;
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,6 @@ namespace NewHorizons
|
||||
public static float SecondsElapsedInLoop = -1;
|
||||
|
||||
public static bool IsSystemReady { get; private set; }
|
||||
public static float FurthestOrbit { get; set; } = 50000f;
|
||||
|
||||
public string DefaultStarSystem => SystemDict.ContainsKey(_defaultSystemOverride) ? _defaultSystemOverride : _defaultStarSystem;
|
||||
public string CurrentStarSystem => _currentStarSystem;
|
||||
@ -449,9 +448,6 @@ namespace NewHorizons
|
||||
DidWarpFromShip = shouldWarpInFromShip;
|
||||
DidWarpFromVessel = shouldWarpInFromVessel;
|
||||
|
||||
var map = FindObjectOfType<MapController>();
|
||||
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
||||
|
||||
// Fix the map satellite
|
||||
SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>();
|
||||
|
||||
@ -524,7 +520,7 @@ namespace NewHorizons
|
||||
var ssrLight = solarSystemRoot.AddComponent<Light>();
|
||||
ssrLight.innerSpotAngle = 0;
|
||||
ssrLight.spotAngle = 179;
|
||||
ssrLight.range = FurthestOrbit * (4f / 3f);
|
||||
ssrLight.range = PlanetCreationHandler.FurthestOrbit * (4f / 3f);
|
||||
ssrLight.intensity = 0.001f;
|
||||
|
||||
var fluid = playerBody.FindChild("PlayerDetector").GetComponent<DynamicFluidDetector>();
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.456" />
|
||||
<PackageReference Include="HarmonyX" Version="2.10.1" />
|
||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.457" />
|
||||
<PackageReference Include="OWML" Version="2.9.3" />
|
||||
<Reference Include="../Lib/System.ComponentModel.Annotations.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@ -8,14 +9,20 @@ namespace NewHorizons.Patches.MapPatches
|
||||
public static class MapControllerPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(MapController.Awake))]
|
||||
public static void MapController_Awake(MapController __instance)
|
||||
[HarmonyPatch(nameof(MapController.Start))]
|
||||
public static void MapController_Start(MapController __instance)
|
||||
{
|
||||
__instance._maxPanDistance = Mathf.Max(__instance._maxPanDistance, Main.FurthestOrbit * 1.5f);
|
||||
__instance._maxZoomDistance *= 6f;
|
||||
__instance._minPitchAngle = -90f;
|
||||
__instance._zoomSpeed *= 4f;
|
||||
__instance._mapCamera.farClipPlane = Mathf.Max(__instance._mapCamera.farClipPlane, Main.FurthestOrbit * 10f);
|
||||
var modifier = Mathf.Max(1f, PlanetCreationHandler.FurthestOrbit / PlanetCreationHandler.DefaultFurthestOrbit);
|
||||
|
||||
__instance._maxPanDistance *= modifier;
|
||||
__instance._maxZoomDistance *= modifier;
|
||||
__instance._zoomSpeed *= modifier;
|
||||
__instance._mapCamera.farClipPlane *= modifier * 4f;
|
||||
|
||||
if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.freeMapAngle)
|
||||
{
|
||||
__instance._minPitchAngle = -90f;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Patches.PlayerPatches
|
||||
{
|
||||
@ -13,10 +14,10 @@ namespace NewHorizons.Patches.PlayerPatches
|
||||
|
||||
// Stop the game from trying to recall your ship when you're visiting far away planets
|
||||
|
||||
Transform sunTransform = Locator.GetSunTransform();
|
||||
OWRigidbody shipBody = Locator.GetShipBody();
|
||||
var maxDist2 = Mathf.Max(900000000f, Main.FurthestOrbit * Main.FurthestOrbit * 2f);
|
||||
__result = sunTransform != null && shipBody != null && (sunTransform.position - shipBody.transform.position).sqrMagnitude > maxDist2;
|
||||
var centerTransform = Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().transform;
|
||||
var shipBody = Locator.GetShipBody();
|
||||
var maxDist = Mathf.Max(PlanetCreationHandler.DefaultFurthestOrbit, PlanetCreationHandler.FurthestOrbit);
|
||||
__result = centerTransform != null && shipBody != null && (shipBody.transform.position - centerTransform.position).sqrMagnitude > maxDist * maxDist;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace NewHorizons.Patches.WarpPatches
|
||||
{
|
||||
@ -24,5 +28,36 @@ namespace NewHorizons.Patches.WarpPatches
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(nameof(ShipCockpitController.FixedUpdate))]
|
||||
public static IEnumerable<CodeInstruction> ShipCockpitController_FixedUpdate(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
// Instead of targetting the Sun target the center of the universe
|
||||
return new CodeMatcher(instructions, generator)
|
||||
// Have to create a label that goes to the method return for the if statement logic
|
||||
.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ret)
|
||||
)
|
||||
.CreateLabel(out Label returnLabel)
|
||||
.Start()
|
||||
.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldc_I4_2),
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Locator), nameof(Locator.GetAstroObject), new Type[] {typeof(AstroObject.Name)})),
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(AstroObject), nameof(AstroObject.GetOWRigidbody)))
|
||||
)
|
||||
.SetOpcodeAndAdvance(OpCodes.Nop) // Have to set to Nop since the Ldc_I4_2 operation is a label
|
||||
.RemoveInstructions(2)
|
||||
.Insert(
|
||||
// First do an if statement to see if the warp drive is locked on
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StarChartHandler), nameof(StarChartHandler.IsWarpDriveLockedOn))),
|
||||
new CodeInstruction(OpCodes.Brtrue_S, returnLabel),
|
||||
|
||||
// Then get the center of the universe and its reference frame
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Locator), nameof(Locator.GetCenterOfTheUniverse))),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(CenterOfTheUniverse), nameof(CenterOfTheUniverse.GetStaticReferenceFrame)))
|
||||
)
|
||||
.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
</None>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NJsonSchema" Version="10.9.0" />
|
||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.456" IncludeAssets="compile" />
|
||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.457" IncludeAssets="compile" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user