mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Allow comet tails on vanilla bodies (#1069)
Made this because I tried to add a comet tail to ember twin but it kept saying `Comet CaveTwin_Body does not orbit anything. That makes no sense` because Orbit.primaryBody didn't have anything. So now it grabs the primary body from the astro object but also takes into account Orbit.primaryBody  ## Bug fixes - Fixed a bug that didn't allow comet tails to be made on unmoved vanilla planets/moons.
This commit is contained in:
commit
a4066db80b
@ -60,14 +60,22 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config)
|
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config, AstroObject ao)
|
||||||
{
|
{
|
||||||
if (config.Orbit.primaryBody == null)
|
var primaryBody = ao.GetPrimaryBody();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(config.Orbit.primaryBody)) primaryBody = AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody);
|
||||||
|
|
||||||
|
if (primaryBody == null)
|
||||||
{
|
{
|
||||||
NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense");
|
NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(cometTailModule.primaryBody))
|
||||||
|
cometTailModule.primaryBody = !string.IsNullOrEmpty(config.Orbit.primaryBody) ? config.Orbit.primaryBody
|
||||||
|
: primaryBody.GetKey();
|
||||||
|
|
||||||
var rootObj = new GameObject("CometRoot");
|
var rootObj = new GameObject("CometRoot");
|
||||||
rootObj.SetActive(false);
|
rootObj.SetActive(false);
|
||||||
rootObj.transform.parent = sector?.transform ?? planetGO.transform;
|
rootObj.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
@ -79,13 +87,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
if (cometTailModule.rotationOverride != null) controller.SetRotationOverride(cometTailModule.rotationOverride);
|
if (cometTailModule.rotationOverride != null) controller.SetRotationOverride(cometTailModule.rotationOverride);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(cometTailModule.primaryBody)) cometTailModule.primaryBody = config.Orbit.primaryBody;
|
|
||||||
|
|
||||||
Delay.FireOnNextUpdate(() =>
|
Delay.FireOnNextUpdate(() =>
|
||||||
{
|
{
|
||||||
controller.SetPrimaryBody(
|
controller.SetPrimaryBody(
|
||||||
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
|
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
|
||||||
AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody).GetAttachedOWRigidbody()
|
primaryBody.GetAttachedOWRigidbody()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -203,7 +203,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
if (body.Config.CometTail != null)
|
if (body.Config.CometTail != null)
|
||||||
{
|
{
|
||||||
CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config);
|
CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config, planetGO.GetComponent<AstroObject>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.Config.Props?.proxyDetails != null)
|
if (body.Config.Props?.proxyDetails != null)
|
||||||
|
|||||||
@ -657,7 +657,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
if (body.Config.CometTail != null)
|
if (body.Config.CometTail != null)
|
||||||
{
|
{
|
||||||
CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config);
|
CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config, go.GetComponent<AstroObject>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.Config.Lava != null)
|
if (body.Config.Lava != null)
|
||||||
|
|||||||
@ -445,6 +445,11 @@ namespace NewHorizons.Utility
|
|||||||
return globalMusicController._endTimesSource.clip.length;
|
return globalMusicController._endTimesSource.clip.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetKey(this AstroObject ao)
|
||||||
|
{
|
||||||
|
return ao._name == AstroObject.Name.CustomString ? ao.GetCustomName() : ao._name.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
public static CodeMatcher LogInstructions(this CodeMatcher matcher, string prefix)
|
public static CodeMatcher LogInstructions(this CodeMatcher matcher, string prefix)
|
||||||
{
|
{
|
||||||
matcher.InstructionEnumeration().LogInstructions(prefix);
|
matcher.InstructionEnumeration().LogInstructions(prefix);
|
||||||
|
|||||||
@ -65,7 +65,7 @@ namespace NewHorizons.Utility.OuterWilds
|
|||||||
|
|
||||||
public static void RegisterCustomAstroObject(AstroObject ao)
|
public static void RegisterCustomAstroObject(AstroObject ao)
|
||||||
{
|
{
|
||||||
var key = ao._name == AstroObject.Name.CustomString ? ao.GetCustomName() : ao._name.ToString();
|
var key = ao.GetKey();
|
||||||
|
|
||||||
if (_customAstroObjectDictionary.ContainsKey(key))
|
if (_customAstroObjectDictionary.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@ -81,7 +81,7 @@ namespace NewHorizons.Utility.OuterWilds
|
|||||||
|
|
||||||
public static void DeregisterCustomAstroObject(AstroObject ao)
|
public static void DeregisterCustomAstroObject(AstroObject ao)
|
||||||
{
|
{
|
||||||
var key = ao._name == AstroObject.Name.CustomString ? ao.GetCustomName() : ao._name.ToString();
|
var key = ao.GetKey();
|
||||||
_customAstroObjectDictionary.Remove(key);
|
_customAstroObjectDictionary.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user