This commit is contained in:
Nick 2022-09-30 22:45:39 -04:00
parent 24eedc887a
commit 70467b76a1

View File

@ -19,24 +19,31 @@ namespace NewHorizons.Utility.DebugUtilities
private ScreenPrompt _raycastPrompt; private ScreenPrompt _raycastPrompt;
private void Awake() private void Start()
{ {
_rb = this.GetRequiredComponent<OWRigidbody>(); _rb = this.GetRequiredComponent<OWRigidbody>();
if (_raycastPrompt == null)
{
_raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P)); _raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P));
Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false); Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false);
} }
}
private void OnDestroy() private void OnDestroy()
{
if (_raycastPrompt != null)
{ {
Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight); Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight);
} }
}
private void Update() private void Update()
{ {
UpdatePromptVisibility(); UpdatePromptVisibility();
if (!Main.Debug) return; if (!Main.Debug) return;
if (Keyboard.current == null) return; if (Keyboard.current == null) return;
if (Keyboard.current[Key.P].wasReleasedThisFrame) if (Keyboard.current[Key.P].wasReleasedThisFrame)
@ -47,9 +54,12 @@ namespace NewHorizons.Utility.DebugUtilities
public void UpdatePromptVisibility() public void UpdatePromptVisibility()
{
if (_raycastPrompt != null)
{ {
_raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug); _raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug);
} }
}
internal void PrintRaycast() internal void PrintRaycast()