-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Bug fixes - Fix softlock affecting The Machine due to a secret hidden slide reel that destroyed everything (thanks Damian for finding this) - More than one cloak can now work at a time, and it only took me over a year (Fixes #108) - Stranger cloak will no longer appear in other systems (Fixes #600) - Fixed cloaks breaking if the planet has no ReferenceFrame enabled
- Loading branch information
Showing
19 changed files
with
315 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using NewHorizons.Components.Stars; | ||
using NewHorizons.Handlers; | ||
using NewHorizons.Utility.OWML; | ||
using UnityEngine; | ||
|
||
namespace NewHorizons.Components.EOTE | ||
{ | ||
internal class CloakLocatorController : MonoBehaviour | ||
{ | ||
private float _currentAngle = float.MaxValue; | ||
private CloakFieldController _currentController; | ||
|
||
public void Start() | ||
{ | ||
// Enable and disable all cloaks, else Stranger state is weird at the start | ||
foreach (var cloak in CloakHandler.Cloaks) | ||
{ | ||
SetCurrentCloak(cloak); | ||
cloak.enabled = false; | ||
} | ||
} | ||
|
||
// Always makes sure the Locator's cloak field controller is the one that is between the player and the sun | ||
public void Update() | ||
{ | ||
var sun = SunLightEffectsController.Instance?.transform; | ||
if (sun != null) | ||
{ | ||
// Keep tracking the angle to the current cloak | ||
if (_currentController != null) | ||
{ | ||
_currentAngle = CalculateAngleToCloak(_currentController.transform, sun); | ||
} | ||
|
||
// Compare the current cloak to all the other ones | ||
foreach (var cloak in CloakHandler.Cloaks) | ||
{ | ||
if (cloak == _currentController) continue; | ||
|
||
var angle = CalculateAngleToCloak(cloak.transform, sun); | ||
|
||
if (angle < _currentAngle && cloak != _currentController) | ||
{ | ||
_currentAngle = angle; | ||
SetCurrentCloak(cloak); | ||
NHLogger.LogVerbose($"Changed cloak controller to {_currentController.GetAttachedOWRigidbody().name} angle {_currentAngle}"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void SetCurrentCloak(CloakFieldController cloak) | ||
{ | ||
if (_currentController != null) | ||
{ | ||
_currentController.enabled = false; | ||
} | ||
|
||
_currentController = cloak; | ||
|
||
if (_currentController != null) | ||
{ | ||
_currentController.enabled = true; | ||
Locator.RegisterCloakFieldController(_currentController); | ||
_currentController.UpdateCloakVisualsState(); | ||
} | ||
} | ||
|
||
private float CalculateAngleToCloak(Transform cloak, Transform sun) | ||
{ | ||
var playerVector = Locator.GetPlayerTransform().position - sun.position; | ||
var cloakVector = cloak.position - sun.position; | ||
|
||
return Vector3.Angle(playerVector, cloakVector); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.