Merge pull request #82 from xen-42/dev

Dev
This commit is contained in:
Nick 2022-04-09 18:17:48 -04:00 committed by GitHub
commit 49e6f43e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 2 deletions

View File

@ -30,11 +30,19 @@ namespace NewHorizons.Components
private ScreenPrompt _detectiveModePrompt; private ScreenPrompt _detectiveModePrompt;
private ScreenPrompt _targetSystemPrompt; private ScreenPrompt _targetSystemPrompt;
private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, "<CMD> Warp to system");
private ShipLogEntryCard _target = null; private ShipLogEntryCard _target = null;
private NotificationData _warpNotificationData = null; private NotificationData _warpNotificationData = null;
private int _nextCardIndex; private int _nextCardIndex;
private bool _isAtFlightConsole;
private void Awake()
{
// Prompts
Locator.GetPromptManager().AddScreenPrompt(_warpPrompt, PromptPosition.UpperLeft, false);
}
public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource) public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource)
{ {
@ -49,6 +57,9 @@ namespace NewHorizons.Components
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame)); GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole)); GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
GlobalMessenger.AddListener("ExitFlightConsole", new Callback(OnExitFlightConsole));
GlobalMessenger.AddListener("GamePaused", new Callback(OnGamePaused));
GlobalMessenger.AddListener("GameUnpaused", new Callback(OnGameUnpaused));
_nextCardIndex = 0; _nextCardIndex = 0;
foreach (var starSystem in Main.SystemDict.Keys) foreach (var starSystem in Main.SystemDict.Keys)
@ -91,11 +102,39 @@ namespace NewHorizons.Components
{ {
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame)); GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
GlobalMessenger<OWRigidbody>.RemoveListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole)); GlobalMessenger<OWRigidbody>.RemoveListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
GlobalMessenger.RemoveListener("ExitFlightConsole", new Callback(OnExitFlightConsole));
GlobalMessenger.RemoveListener("GamePaused", new Callback(OnGamePaused));
GlobalMessenger.RemoveListener("GameUnpaused", new Callback(OnGameUnpaused));
Locator.GetPromptManager().RemoveScreenPrompt(_warpPrompt, PromptPosition.UpperLeft);
} }
private void OnEnterFlightConsole(OWRigidbody _) private void OnEnterFlightConsole(OWRigidbody _)
{ {
if (_target == null) GlobalMessenger.FireEvent("UntargetReferenceFrame"); _isAtFlightConsole = true;
if(_target != null)
{
_warpPrompt.SetVisibility(true);
}
}
private void OnExitFlightConsole()
{
_isAtFlightConsole = false;
_warpPrompt.SetVisibility(false);
}
private void OnGamePaused()
{
_warpPrompt.SetVisibility(false);
}
private void OnGameUnpaused()
{
if(_target != null && _isAtFlightConsole)
{
_warpPrompt.SetVisibility(true);
}
} }
public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position) public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position)
@ -271,9 +310,13 @@ namespace NewHorizons.Components
_oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f); _oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f);
_target = shipLogEntryCard; _target = shipLogEntryCard;
_target.SetMarkedOnHUD(true); _target.SetMarkedOnHUD(true);
Locator._rfTracker.UntargetReferenceFrame();
GlobalMessenger.FireEvent("UntargetReferenceFrame"); GlobalMessenger.FireEvent("UntargetReferenceFrame");
_warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueNameToString(shipLogEntryCard.name).ToUpper()}"); _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueNameToString(shipLogEntryCard.name).ToUpper()}");
NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true); NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true);
_warpPrompt.SetText($"<CMD> Engage Warp To {UniqueNameToString(shipLogEntryCard.name)}");
} }
private void RemoveWarpTarget(bool playSound = false) private void RemoveWarpTarget(bool playSound = false)
@ -283,11 +326,24 @@ namespace NewHorizons.Components
if(playSound) _oneShotSource.PlayOneShot(global::AudioType.ShipLogMarkLocation, 1f); if(playSound) _oneShotSource.PlayOneShot(global::AudioType.ShipLogMarkLocation, 1f);
_target.SetMarkedOnHUD(false); _target.SetMarkedOnHUD(false);
_target = null; _target = null;
_warpPrompt.SetVisibility(false);
} }
public string GetTargetStarSystem() public string GetTargetStarSystem()
{ {
return _target?.name; return _target?.name;
} }
private bool IsWarpDriveAvailable()
{
return OWInput.IsInputMode(InputMode.ShipCockpit) && _target != null;
}
private void Update()
{
Logger.Log("???");
_warpPrompt.SetVisibility(IsWarpDriveAvailable());
}
} }
} }

View File

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