Add sidereal to remnant

This commit is contained in:
Noah Pilarski 2022-08-18 12:39:21 -04:00
parent 21eb5b7fed
commit 7a00409f6c
2 changed files with 23 additions and 11 deletions

View File

@ -16,6 +16,7 @@ namespace NewHorizons.Components
private StarController _starController;
private float _siderealPeriod = 0;
private float _surfaceGravity = 0;
private float _surfaceSize = 0;
private float _sphereOfInfluence = 0;
@ -24,6 +25,7 @@ namespace NewHorizons.Components
public RemnantType GetRemnantType() => _type;
public void SetRemnantType(RemnantType type) => _type = type;
public void SetSiderealPeriod(float siderealPeriod) => _siderealPeriod = siderealPeriod;
public void SetSurfaceGravity(float surfaceGravity) => _surfaceGravity = surfaceGravity;
public void SetSurfaceSize(float surfaceSize) => _surfaceSize = surfaceSize;
public void SetAlignmentRadius(float alignmentRadius) => _alignmentRadius = alignmentRadius;
@ -43,19 +45,25 @@ namespace NewHorizons.Components
{
if (!gameObject.activeSelf) gameObject.SetActive(true);
var gravityVolume = this.GetAttachedOWRigidbody().GetAttachedGravityVolume();
if (gravityVolume != null)
var owrb = this.GetAttachedOWRigidbody();
if (owrb != null)
{
gravityVolume._alignmentRadius = _alignmentRadius;
gravityVolume._upperSurfaceRadius = _surfaceSize;
gravityVolume._surfaceAcceleration = _surfaceGravity;
}
owrb.SetAngularVelocity(Vector3.up * (_siderealPeriod == 0 ? 0 : 2 * Mathf.PI / (_siderealPeriod * 60)));
var referenceFrameVolume = this.GetAttachedOWRigidbody()._attachedRFVolume;
if (referenceFrameVolume != null)
{
referenceFrameVolume.GetComponent<SphereCollider>().radius = _sphereOfInfluence * 2;
referenceFrameVolume._maxColliderRadius = _sphereOfInfluence * 2;
var gravityVolume = owrb.GetAttachedGravityVolume();
if (gravityVolume != null)
{
gravityVolume._alignmentRadius = _alignmentRadius;
gravityVolume._upperSurfaceRadius = _surfaceSize;
gravityVolume._surfaceAcceleration = _surfaceGravity;
}
var referenceFrameVolume = owrb._attachedRFVolume;
if (referenceFrameVolume != null)
{
referenceFrameVolume.GetComponent<SphereCollider>().radius = _sphereOfInfluence * 2;
referenceFrameVolume._maxColliderRadius = _sphereOfInfluence * 2;
}
}
if (_starController != null) StarLightController.AddStar(_starController);

View File

@ -525,6 +525,7 @@ namespace NewHorizons.Handlers
stellarRemnantController.SetRemnantType(StellarRemnantController.RemnantType.Custom);
stellarRemnantController.SetSurfaceSize(srBody.Config.Base.surfaceSize);
stellarRemnantController.SetSurfaceGravity(srBody.Config.Base.surfaceGravity);
stellarRemnantController.SetSiderealPeriod(srBody.Config.Orbit.siderealPeriod);
var srSphereOfInfluence = GetSphereOfInfluence(srBody);
stellarRemnantController.SetSphereOfInfluence(srSphereOfInfluence);
ss.radius = srSphereOfInfluence + 10;
@ -541,6 +542,7 @@ namespace NewHorizons.Handlers
stellarRemnantController.SetSurfaceSize(bhSurfaceSize);
stellarRemnantController.SetSurfaceGravity(body.Config.Base.surfaceGravity * 4);
stellarRemnantController.SetSphereOfInfluence(bhSurfaceSize * 2);
stellarRemnantController.SetSiderealPeriod(0.1f);
ss.radius = (bhSurfaceSize * 2) + 10;
stellarRemnantController.SetAlignmentRadius(bhSurfaceSize * 1.5f);
SingularityBuilder.MakeBlackHole(go, srSector, Vector3.zero, bhSurfaceSize, true, string.Empty, new External.Modules.VariableSize.VariableSizeModule.TimeValuePair[0]);
@ -555,6 +557,7 @@ namespace NewHorizons.Handlers
stellarRemnantController.SetSphereOfInfluence(nsSurfaceSize * 2);
ss.radius = (nsSurfaceSize * 2) + 10;
stellarRemnantController.SetAlignmentRadius(nsSurfaceSize * 1.5f);
stellarRemnantController.SetSiderealPeriod(0.1f);
stellarRemnantController.SetStarController(StarBuilder.Make(go, srSector, new External.Modules.VariableSize.StarModule
{
size = nsSurfaceSize,
@ -571,6 +574,7 @@ namespace NewHorizons.Handlers
stellarRemnantController.SetSphereOfInfluence(wdSurfaceSize * 2);
ss.radius = (wdSurfaceSize * 2) + 10;
stellarRemnantController.SetAlignmentRadius(wdSurfaceSize * 1.5f);
stellarRemnantController.SetSiderealPeriod(body.Config.Orbit.siderealPeriod);
stellarRemnantController.SetStarController(StarBuilder.Make(go, srSector, new External.Modules.VariableSize.StarModule
{
size = wdSurfaceSize,