2025-12-01 16:44:19 +08:00
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2025-12-09 20:30:11 +08:00
|
|
|
namespace AlicizaX.UI
|
2025-12-01 16:44:19 +08:00
|
|
|
{
|
2026-02-26 17:14:47 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Base class for all controller states
|
|
|
|
|
/// </summary>
|
2025-12-01 16:44:19 +08:00
|
|
|
public abstract class ControllerStateBase
|
|
|
|
|
{
|
2026-02-26 17:14:47 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Initialize the state when added to a recorder
|
|
|
|
|
/// </summary>
|
2025-12-01 16:44:19 +08:00
|
|
|
public abstract void Init(UXControllerStateRecorder recorder);
|
2026-02-26 17:14:47 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Execute the state when controller index changes
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="recorder">The state recorder</param>
|
|
|
|
|
/// <param name="entryIndex">The index this state entry is bound to</param>
|
|
|
|
|
/// <param name="selectedIndex">The currently selected controller index</param>
|
|
|
|
|
public abstract void Execute(UXControllerStateRecorder recorder, int entryIndex, int selectedIndex);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validate if the state can be properly executed
|
|
|
|
|
/// </summary>
|
2025-12-01 16:44:19 +08:00
|
|
|
public abstract bool Valid(UXControllerStateRecorder recorder);
|
2026-02-26 17:14:47 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get a human-readable description of this state
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual string GetDescription()
|
|
|
|
|
{
|
|
|
|
|
return GetType().Name;
|
|
|
|
|
}
|
2025-12-01 16:44:19 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-26 17:14:47 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Attribute to define display name for a controller state type
|
|
|
|
|
/// </summary>
|
2025-12-01 16:44:19 +08:00
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
|
public class ControlerStateNameAttribute : Attribute
|
|
|
|
|
{
|
2026-02-26 17:14:47 +08:00
|
|
|
public string StateName { get; }
|
2025-12-01 16:44:19 +08:00
|
|
|
|
|
|
|
|
public ControlerStateNameAttribute(string stateName)
|
|
|
|
|
{
|
|
|
|
|
StateName = stateName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-26 17:14:47 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Attribute to define if a state can be attached multiple times to the same recorder
|
|
|
|
|
/// </summary>
|
2025-12-01 16:44:19 +08:00
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
|
public class ControlerStateAttachTypeAttribute : Attribute
|
|
|
|
|
{
|
2026-02-26 17:14:47 +08:00
|
|
|
public bool Repeat { get; }
|
2025-12-01 16:44:19 +08:00
|
|
|
|
|
|
|
|
public ControlerStateAttachTypeAttribute(bool repeat)
|
|
|
|
|
{
|
|
|
|
|
Repeat = repeat;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|