2026-02-10 21:27:46 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public enum Attitude { Friendly, Neutral, Enemy }
|
|
|
|
|
|
|
|
|
|
[RequireComponent(typeof(Collider))]
|
|
|
|
|
public class Selectable : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[Header("Identification")]
|
|
|
|
|
public string displayName = "Name";
|
|
|
|
|
public Attitude attitude = Attitude.Neutral;
|
|
|
|
|
|
|
|
|
|
[Header("Optional visuals")]
|
|
|
|
|
[Tooltip("Optional child GameObject used as a 3D outline/highlight. Enable/disable to show outline.")]
|
|
|
|
|
public GameObject outlineObject;
|
|
|
|
|
|
|
|
|
|
// Called by selection system
|
|
|
|
|
public void OnSelected()
|
|
|
|
|
{
|
|
|
|
|
if (outlineObject != null) outlineObject.SetActive(true);
|
2026-02-11 17:30:49 +00:00
|
|
|
if (SelectionManager.Instance != null)
|
|
|
|
|
SelectionManager.Instance.Select(this);
|
2026-02-10 21:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called by selection system
|
|
|
|
|
public void OnDeselected()
|
|
|
|
|
{
|
|
|
|
|
if (outlineObject != null) outlineObject.SetActive(false);
|
|
|
|
|
}
|
2026-02-11 17:30:49 +00:00
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
// Clean up selection if this object is destroyed
|
|
|
|
|
if (SelectionManager.Instance != null)
|
|
|
|
|
SelectionManager.Instance.ClearSelection();
|
|
|
|
|
}
|
2026-02-10 21:27:46 +00:00
|
|
|
}
|