- 重构 `RepoItem`,统一点击事件
- 重构 `PlayerInventoryComponent`:
    - `PlayerInventoryStateStore`:状态与库存写模型
    - `PlayerInventoryTowerAssemblyService`:炮塔组装域
    - `PlayerInventoryTowerRosterService`:编队/耐久域
    - `InventoryParticipantUtility`/`InventoryCloneUtility`/`InventorySeedUtility`:通用工具类
This commit is contained in:
SepComet
2026-03-04 22:04:51 +08:00
parent a62309e8c1
commit 9db9aeabcd
27 changed files with 1755 additions and 1665 deletions
@@ -1,4 +1,3 @@
using System.Collections;
using GeometryTD.CustomEvent;
using GeometryTD.Definition;
using UnityEngine;
@@ -27,8 +26,6 @@ namespace GeometryTD.UI
private bool _isDragging;
private bool _dropHandled;
private bool _dropAssigned;
private Coroutine _pendingOpenDetailRoutine;
private bool _cancelPendingOpenDetail;
public RepoItemContext Context => _context;
@@ -43,7 +40,6 @@ namespace GeometryTD.UI
private void OnDisable()
{
CancelPendingOpenDetail();
ResetDragState();
}
@@ -65,7 +61,6 @@ namespace GeometryTD.UI
public void OnReset()
{
CancelPendingOpenDetail();
_context = null;
_iconArea.OnReset();
@@ -108,13 +103,7 @@ namespace GeometryTD.UI
return;
}
if (_context.ClickActionType == RepoItemClickActionType.RemoveParticipant)
{
GameEntry.Event.Fire(this, RepoParticipantRemoveRequestedEventArgs.Create(_context.InstanceId));
return;
}
StartPendingOpenDetail();
GameEntry.Event.Fire(this, RepoItemClickedEventArgs.Create(_context.InstanceId, transform.position));
}
public void OnBeginDrag(PointerEventData eventData)
@@ -133,7 +122,6 @@ namespace GeometryTD.UI
_isDragging = true;
_dropHandled = false;
_dropAssigned = false;
_cancelPendingOpenDetail = true;
CloseItemDescFormIfOpen();
@@ -224,56 +212,6 @@ namespace GeometryTD.UI
return true;
}
private void StartPendingOpenDetail()
{
CancelPendingOpenDetail();
_cancelPendingOpenDetail = false;
_pendingOpenDetailRoutine = StartCoroutine(WaitPointerReleaseAndOpenDetail());
}
private void CancelPendingOpenDetail()
{
_cancelPendingOpenDetail = true;
if (_pendingOpenDetailRoutine != null)
{
StopCoroutine(_pendingOpenDetailRoutine);
_pendingOpenDetailRoutine = null;
}
}
private IEnumerator WaitPointerReleaseAndOpenDetail()
{
while (IsPrimaryPointerPressed())
{
if (_cancelPendingOpenDetail || _isDragging)
{
_pendingOpenDetailRoutine = null;
yield break;
}
yield return null;
}
_pendingOpenDetailRoutine = null;
if (_cancelPendingOpenDetail || _isDragging || _context == null)
{
yield break;
}
GameEntry.Event.Fire(this,
RepoItemDetailRequestedEventArgs.Create(_context.InstanceId, transform.position));
}
private static bool IsPrimaryPointerPressed()
{
if (Input.GetMouseButton(0))
{
return true;
}
return Input.touchCount > 0;
}
private static void CloseItemDescFormIfOpen()
{
var itemDescForm = GameEntry.UI.GetUIForm(UIFormType.ItemDescForm);