2025-08-07 16:44:43 +08:00
|
|
|
using Base;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
namespace UI
|
|
|
|
{
|
|
|
|
|
|
|
|
public delegate void NonReturnCallback();
|
|
|
|
public class EntityPlacementUI:UIBase,ITickUI
|
|
|
|
{
|
|
|
|
public TMP_Text promptText;
|
|
|
|
|
|
|
|
public NonReturnCallback currentAction;
|
|
|
|
|
2025-08-11 12:45:52 +08:00
|
|
|
public GameObject focusBox;
|
|
|
|
public bool snapEnabled = false;
|
|
|
|
|
2025-08-07 16:44:43 +08:00
|
|
|
public string Prompt
|
|
|
|
{
|
|
|
|
get => promptText.text;
|
|
|
|
set => promptText.text = value;
|
|
|
|
}
|
|
|
|
public void TickUI()
|
|
|
|
{
|
|
|
|
if (!IsVisible)
|
|
|
|
return;
|
|
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
|
|
{
|
|
|
|
Base.UIInputControl.Instance.Hide(this);
|
|
|
|
}
|
|
|
|
if (currentAction!=null&&Input.GetMouseButtonDown(0))
|
|
|
|
{
|
|
|
|
currentAction();
|
|
|
|
}
|
2025-08-11 12:45:52 +08:00
|
|
|
|
|
|
|
if (snapEnabled)
|
|
|
|
{
|
|
|
|
focusBox.transform.position = Utils.MousePosition.GetSnappedWorldPosition();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
focusBox.transform.position = Utils.MousePosition.GetWorldPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Show()
|
|
|
|
{
|
|
|
|
base.Show();
|
|
|
|
focusBox.SetActive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
override public void Hide()
|
|
|
|
{
|
|
|
|
base.Hide();
|
|
|
|
focusBox.SetActive(false);
|
2025-08-07 16:44:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|