Merge branch 'master' into add-faq

This commit is contained in:
Ben C 2022-03-12 05:06:11 -05:00
commit 0b2afc39da
16 changed files with 264 additions and 27 deletions

View File

@ -1,4 +1,5 @@
using NewHorizons.External;
using NewHorizons.External.Configs;
using OWML.Utils;
using System;
using System.Collections.Generic;
@ -11,18 +12,17 @@ namespace NewHorizons.Builder.Body
{
public static class CometTailBuilder
{
public static void Make(GameObject go, BaseModule module, AstroObject primary)
public static void Make(GameObject go, IPlanetConfig config, AstroObject primary)
{
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), go.transform);
cometTail.transform.localPosition = Vector3.zero;
cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * module.SurfaceSize / 110;
cometTail.transform.localRotation = Quaternion.Euler(0, 90, 90);
/*
var alignment = cometTail.AddComponent<AlignWithTargetBody>();
alignment.SetTargetBody(primary.GetAttachedOWRigidbody());
alignment.SetValue("_usePhysicsToRotate", true);
*/
cometTail.transform.localScale = Vector3.one * config.Base.SurfaceSize / 110;
Vector3 alignment = new Vector3(0, 270, 90);
if (config.Base.CometTailRotation != null) alignment = config.Base.CometTailRotation;
cometTail.transform.rotation = Quaternion.Euler(alignment);
}
}
}

View File

@ -1,4 +1,5 @@
using NewHorizons.Builder.Body.Geometry;
using NewHorizons.Builder.Props;
using NewHorizons.External;
using NewHorizons.Utility;
using OWML.Common;
@ -42,7 +43,9 @@ namespace NewHorizons.Builder.Body
cubeSphere.AddComponent<MeshFilter>();
cubeSphere.GetComponent<MeshFilter>().mesh = mesh;
if(PlanetShader == null) PlanetShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
// TODO: fix UVs so we can switch to the default shader
if (PlanetShader == null) PlanetShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
//if (PlanetShader == null) PlanetShader = Shader.Find("Standard");
var cubeSphereMR = cubeSphere.AddComponent<MeshRenderer>();
cubeSphereMR.material = new Material(PlanetShader);

View File

@ -66,6 +66,15 @@ namespace NewHorizons.Builder.General
var alignment = body.AddComponent<AlignWithTargetBody>();
alignment.SetTargetBody(primaryBody?.GetAttachedOWRigidbody());
alignment.SetValue("_usePhysicsToRotate", true);
if(config.Orbit.AlignmentAxis == null)
{
alignment._localAlignmentAxis = new Vector3(0, -1, 0);
}
else
{
alignment._localAlignmentAxis = config.Orbit.AlignmentAxis;
}
}
if (config.Base.CenterOfSolarSystem)

View File

@ -23,6 +23,7 @@ namespace NewHorizons.Builder.Props
if (detail.assetBundle != null)
{
var prefab = PropBuildManager.LoadPrefab(detail.assetBundle, detail.path, uniqueModName, mod);
detailGO = MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
}
else if (detail.objFilePath != null)
@ -30,6 +31,7 @@ namespace NewHorizons.Builder.Props
try
{
var prefab = mod.ModHelper.Assets.Get3DObject(detail.objFilePath, detail.mtlFilePath);
PropBuildManager.ReplaceShaders(prefab);
prefab.SetActive(false);
detailGO = MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
}

View File

@ -104,7 +104,26 @@ namespace NewHorizons.Builder.Props
return null;
}
ReplaceShaders(prefab);
return prefab;
}
public static void ReplaceShaders(GameObject prefab)
{
foreach (var renderer in prefab.GetComponentsInChildren<Renderer>(true))
{
foreach (var material in renderer.sharedMaterials)
{
if (material == null)
{
continue;
}
var replacementShader = Shader.Find(material.shader.name);
if (replacementShader != null) material.shader = replacementShader;
}
}
}
}
}

View File

@ -49,7 +49,7 @@ namespace NewHorizons.Builder.Updater
var planetoid = new Planet.Plantoid(
original.size,
original.gravity,
go.transform.rotation,
mapping[heavenlyBody].state.orbit.orientation.rotation,
InitialMotionBuilder.SiderealPeriodToAngularSpeed(body.Config.Orbit.SiderealPeriod),
parent,
coords

View File

@ -51,7 +51,7 @@ namespace NewHorizons.Components
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
_nextCardIndex = 0;
foreach (var starSystem in Main.BodyDict.Keys)
foreach (var starSystem in Main.SystemDict.Keys)
{
// Get rid of the warp option for the current system
if (starSystem == Main.Instance.CurrentStarSystem) continue;
@ -70,6 +70,15 @@ namespace NewHorizons.Components
AddSystemCard(starSystem);
}
}
//AddSystemCard("EyeOfTheUniverse");
/* Ship log manager isnt initiatiized yet
if(Locator.GetShipLogManager().IsFactRevealed("OPC_EYE_COORDINATES_X1"))
{
AddSystemCard("EyeOfTheUniverse");
}
*/
}
public void AddSystemCard(string starSystem)

View File

@ -17,6 +17,7 @@ namespace NewHorizons.External
public float SphereOfInfluence { get; set; }
public float GroundSize { get; set; }
public bool HasCometTail { get; set; }
public MVector3 CometTailRotation { get; set; }
public bool HasReferenceFrame { get; set; } = true;
public bool CenterOfSolarSystem { get; set; } = false;
public bool IsSatellite { get; set; }

View File

@ -22,6 +22,7 @@ namespace NewHorizons.External
public float AxialTilt { get; set; }
public float SiderealPeriod { get; set; }
public bool IsTidallyLocked { get; set; }
public MVector3 AlignmentAxis { get; set; }
public bool ShowOrbitLine { get; set; } = true;
public bool IsStatic { get; set; }
public MColor Tint { get; set; }

View File

@ -292,7 +292,7 @@ namespace NewHorizons.Handlers
AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Mod);
if (body.Config.Base.HasCometTail)
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
CometTailBuilder.Make(go, body.Config, go.GetComponent<AstroObject>().GetPrimaryBody());
// Backwards compatability
if (body.Config.Base.LavaSize != 0)

View File

@ -58,6 +58,8 @@ namespace NewHorizons
private bool _firstLoad = true;
private ShipWarpController _shipWarpController;
private GameObject _ship;
public override object GetApi()
{
return new NewHorizonsApi();
@ -95,6 +97,7 @@ namespace NewHorizons
GlobalMessenger.AddListener("WakeUp", new Callback(OnWakeUp));
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
BodyDict["EyeOfTheUniverse"] = new List<NewHorizonsBody>(); // Keep this empty tho fr
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this);
Tools.Patches.Apply();
@ -191,11 +194,30 @@ namespace NewHorizons
TitleSceneHandler.DisplayBodyOnTitleScreen(BodyDict.Values.ToList().SelectMany(x => x).ToList());
}
if(scene.name == "EyeOfTheUniverse" && IsWarping)
{
if(_ship != null) SceneManager.MoveGameObjectToScene(_ship, SceneManager.GetActiveScene());
_ship.transform.position = new Vector3(50, 0, 0);
_ship.SetActive(true);
}
if(scene.name == "SolarSystem")
{
foreach(var body in GameObject.FindObjectsOfType<AstroObject>())
{
Logger.Log($"{body.name}, {body.transform.rotation}");
}
if(_ship != null)
{
_ship = GameObject.Find("Ship_Body").InstantiateInactive();
DontDestroyOnLoad(_ship);
}
IsSystemReady = false;
HeavenlyBodyBuilder.Reset();
CommonResourcesFix.Apply();
NewHorizonsData.Load();
SignalBuilder.Init();
AstroObjectLocator.RefreshList();
@ -348,7 +370,15 @@ namespace NewHorizons
// We kill them so they don't move as much
Locator.GetDeathManager().KillPlayer(DeathType.Meditation);
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
if(newStarSystem == "EyeOfTheUniverse")
{
PlayerData.SaveWarpedToTheEye(60);
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToBlack, 0.1f, true);
}
else
{
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
}
}
void OnDeath(DeathType _)
@ -390,7 +420,12 @@ namespace NewHorizons
public GameObject GetPlanet(string name)
{
return Main.BodyDict.Values.SelectMany(x => x).ToList().FirstOrDefault(x => x.Config.Name == name).Object;
return Main.BodyDict.Values.SelectMany(x => x)?.ToList()?.FirstOrDefault(x => x.Config.Name == name)?.Object;
}
public string GetCurrentStarSystem()
{
return Main.Instance.CurrentStarSystem;
}
}
#endregion API

View File

@ -59,6 +59,9 @@ namespace NewHorizons.Tools
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<PlayerSpawner>("SpawnPlayer", typeof(Patches), nameof(Patches.OnPlayerSpawnerSpawnPlayerPreFix));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.OnDeathManagerKillPlayer));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipThrusterController>("ReadTranslationalInput", typeof(Patches), nameof(Patches.OnShipThrusterControllerReadTranslationalInput));
// Postfixes
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("OnTargetReferenceFrame", typeof(Patches), nameof(Patches.OnMapControllerOnTargetReferenceFrame));
@ -360,5 +363,97 @@ namespace NewHorizons.Tools
Logger.Log("Player spawning");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
}
public static bool OnDeathManagerKillPlayer()
{
return (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse");
}
public static bool OnShipThrusterControllerReadTranslationalInput(ShipThrusterController __instance, ref Vector3 __result)
{
if (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") return true;
float value = OWInput.GetValue(InputLibrary.thrustX, InputMode.All);
float value2 = OWInput.GetValue(InputLibrary.thrustZ, InputMode.All);
float value3 = OWInput.GetValue(InputLibrary.thrustUp, InputMode.All);
float value4 = OWInput.GetValue(InputLibrary.thrustDown, InputMode.All);
if (!OWInput.IsInputMode(InputMode.ShipCockpit | InputMode.LandingCam))
{
__result = Vector3.zero;
return false;
}
if (!__instance._shipResources.AreThrustersUsable())
{
__result = Vector3.zero;
return false;
}
if (__instance._autopilot.IsFlyingToDestination())
{
__result = Vector3.zero;
return false;
}
Vector3 vector = new Vector3(value, 0f, value2);
if (vector.sqrMagnitude > 1f)
{
vector.Normalize();
}
vector.y = value3 - value4;
if (__instance._requireIgnition && __instance._landingManager.IsLanded())
{
vector.x = 0f;
vector.z = 0f;
vector.y = Mathf.Clamp01(vector.y);
if (!__instance._isIgniting && __instance._lastTranslationalInput.y <= 0f && vector.y > 0f)
{
__instance._isIgniting = true;
__instance._ignitionTime = Time.time;
GlobalMessenger.FireEvent("StartShipIgnition");
}
if (__instance._isIgniting)
{
if (vector.y <= 0f)
{
__instance._isIgniting = false;
GlobalMessenger.FireEvent("CancelShipIgnition");
}
if (Time.time < __instance._ignitionTime + __instance._ignitionDuration)
{
vector.y = 0f;
}
else
{
__instance._isIgniting = false;
__instance._requireIgnition = false;
GlobalMessenger.FireEvent("CompleteShipIgnition");
RumbleManager.PlayShipIgnition();
}
}
}
float d = __instance._thrusterModel.GetMaxTranslationalThrust() / __instance._thrusterModel.GetMaxTranslationalThrust();
Vector3 vector2 = vector * d;
if (__instance._limitOrbitSpeed && vector2.magnitude > 0f)
{
Vector3 vector3 = __instance._landingRF.GetOWRigidBody().GetWorldCenterOfMass() - __instance._shipBody.GetWorldCenterOfMass();
Vector3 vector4 = __instance._shipBody.GetVelocity() - __instance._landingRF.GetVelocity();
Vector3 vector5 = vector4 - Vector3.Project(vector4, vector3);
Vector3 vector6 = Quaternion.FromToRotation(-__instance._shipBody.transform.up, vector3) * __instance._shipBody.transform.TransformDirection(vector2 * __instance._thrusterModel.GetMaxTranslationalThrust());
Vector3 vector7 = Vector3.Project(vector6, vector3);
Vector3 vector8 = vector6 - vector7;
Vector3 a = vector5 + vector8 * Time.deltaTime;
float magnitude = a.magnitude;
float orbitSpeed = __instance._landingRF.GetOrbitSpeed(vector3.magnitude);
if (magnitude > orbitSpeed)
{
a = a.normalized * orbitSpeed;
vector8 = (a - vector5) / Time.deltaTime;
vector6 = vector7 + vector8;
vector2 = __instance._shipBody.transform.InverseTransformDirection(vector6 / __instance._thrusterModel.GetMaxTranslationalThrust());
}
}
__instance._lastTranslationalInput = vector;
__result = vector2;
return false;
}
}
}

View File

@ -0,0 +1,42 @@
using PacificEngine.OW_CommonResources.Game.Resource;
using PacificEngine.OW_CommonResources.Game.State;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Utility.CommonResources
{
public static class CommonResourcesFix
{
public static void Apply()
{
var mapping = Planet.defaultMapping;
var DB = mapping[HeavenlyBodies.DarkBramble];
mapping[HeavenlyBodies.DarkBramble] = new Planet.Plantoid(
DB.size,
DB.gravity,
DB.state.orbit.orientation.rotation * Quaternion.AngleAxis(180, Vector3.left),
DB.state.orbit.orientation.angularVelocity.magnitude,
DB.state.parent,
DB.state.orbit.coordinates
);
var TT = mapping[HeavenlyBodies.AshTwin];
mapping[HeavenlyBodies.AshTwin] = new Planet.Plantoid(
TT.size,
TT.gravity,
TT.state.orbit.orientation.rotation * Quaternion.AngleAxis(180, Vector3.left),
TT.state.orbit.orientation.angularVelocity.magnitude,
TT.state.parent,
TT.state.orbit.coordinates
);
Planet.defaultMapping = mapping;
Planet.mapping = mapping;
}
}
}

View File

@ -104,5 +104,18 @@ namespace NewHorizons.Utility
"$1 $2"
);
}
public static GameObject InstantiateInactive(this GameObject original)
{
if (!original.activeSelf)
{
return UnityEngine.Object.Instantiate(original);
}
original.SetActive(false);
var copy = UnityEngine.Object.Instantiate(original);
original.SetActive(true);
return copy;
}
}
}

View File

@ -3,7 +3,7 @@
"author": "xen, Idiot, & Book",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "0.9.4",
"version": "0.9.5",
"owmlVersion": "2.1.0",
"dependencies": [ "PacificEngine.OW_CommonResources" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ]

View File

@ -131,12 +131,12 @@
"hasMapMarker": {
"type": "boolean",
"default": false,
"description" : "If the body should have a marker on the map screen."
"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 ammount of light"
"description": "If the dark side of the body should have some slight ammount of light"
},
"surfaceGravity": {
"type": "number",
@ -150,7 +150,7 @@
"inverseSquared"
],
"default": "linear",
"description" : "How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared."
"description": "How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared."
},
"surfaceSize": {
"type": "number",
@ -170,7 +170,11 @@
"hasCometTail": {
"type": "boolean",
"default": false,
"description" : "If you want the body to have a tail like the Interloper."
"description": "If you want the body to have a tail like the Interloper."
},
"cometTailRotation": {
"type": "#/$defs/vector3",
"description": "If it has a comet tail, it'll be oriented according to these Euler angles."
},
"hasReferenceFrame": {
"type": "boolean",
@ -286,41 +290,45 @@
},
"longitudeOfAscendingNode": {
"$ref": "#/$defs/angle",
"description" : "An angle (in degrees) defining the point where the orbit of the body rises above the orbital plane if it has nonzero inclination."
"description": "An angle (in degrees) defining the point where the orbit of the body rises above the orbital plane if it has nonzero inclination."
},
"eccentricity": {
"type": "number",
"default": 0,
"minimum": 0,
"maximum": 0.99999,
"description" : "At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is."
"description": "At 0 the orbit is a circle. The closer to 1 it is, the more oval-shaped the orbit is."
},
"argumentOfPeriapsis": {
"$ref": "#/$defs/angle",
"description" : "An angle (in degrees) defining the location of the periapsis (closest distance to it's primary body) if it has nonzero eccentricity."
"description": "An angle (in degrees) defining the location of the periapsis (closest distance to it's primary body) if it has nonzero eccentricity."
},
"trueAnomaly": {
"$ref": "#/$defs/angle",
"description" : "Where the planet should start off in its orbit in terms of the central angle."
"description": "Where the planet should start off in its orbit in terms of the central angle."
},
"axialTilt": {
"$ref": "#/$defs/angle",
"description" : "The angle between the normal to the orbital plane and its axis of rotation."
"description": "The angle between the normal to the orbital plane and its axis of rotation."
},
"siderealPeriod": {
"type": "number",
"default": 0,
"description" : "Rotation period in minutes."
"description": "Rotation period in minutes."
},
"isTidallyLocked": {
"type": "boolean",
"default": false,
"description" : "Should the body always have one side facing its primary?"
"description": "Should the body always have one side facing its primary?"
},
"alignmentAxis": {
"type": "#/$defs/vector3",
"description": "If it is tidally locked, this direction will face towards the primary. Ex) Interloper uses 0, -1, 0. Most planets will want something like -1, 0, 0."
},
"showOrbitLine": {
"type": "boolean",
"default": false,
"description" : "Referring to the orbit line in the map screen."
"description": "Referring to the orbit line in the map screen."
},
"isStatic": {
"type": "boolean",