Add prototype gameplay loop with character/battlefield assets and server game APIs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace HotUpdate.Gameplay
|
||||
{
|
||||
/// <summary>Input behaviour on authored formation buttons; creates no UI objects.</summary>
|
||||
public sealed class FormationDragHandle : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public Func<bool> CanBegin;
|
||||
public Action<PointerEventData> Begin, Move, End;
|
||||
bool _dragging;
|
||||
public void OnBeginDrag(PointerEventData data)
|
||||
{
|
||||
if (data.button != PointerEventData.InputButton.Left || CanBegin?.Invoke() != true) return;
|
||||
_dragging = true; data.eligibleForClick = false; Begin?.Invoke(data);
|
||||
}
|
||||
public void OnDrag(PointerEventData data) { if (_dragging) Move?.Invoke(data); }
|
||||
public void OnEndDrag(PointerEventData data) { if (!_dragging) return; _dragging = false; End?.Invoke(data); }
|
||||
void OnDisable() { _dragging = false; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user