Files
SVSimServer/SVSim.BattleEngine/Engine/HandViewBase.cs
gamer147 957af3d1ec feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
2026-06-05 17:22:20 -04:00

195 lines
5.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Wizard.Battle.View;
using Wizard.Battle.View.Vfx;
public abstract class HandViewBase
{
protected readonly HandControl _handControl;
protected readonly List<IBattleCardView> _battleCardViewList;
protected const float REARRANGE_TIME = 0.2f;
protected const float WATCH_REARRANGE_TIME = 0.1f;
public HandViewBase()
{
}
public HandViewBase(GameObject handGameObject, BattleCamera battleCamera)
{
_handControl = CreateHandControl(handGameObject, battleCamera);
_battleCardViewList = new List<IBattleCardView>();
}
public virtual void SetClassBattleCardView(IBattleCardView classBattleCardView)
{
}
protected abstract void RearrangeHand(float rearrangeTime, bool isNewReplayMoveTurn = false);
protected abstract HandControl CreateHandControl(GameObject handGameObject, BattleCamera battleCamera);
public virtual void AddCardToView(IBattleCardView cardViewToAdd, float deckRearrangeTime, bool isNewReplayMoveTurn = false)
{
if (!(cardViewToAdd is NullBattleCardView))
{
if (BattleManagerBase.GetIns().IsRecovery)
{
deckRearrangeTime = 0f;
}
AddCardToViewWithoutRearrange(cardViewToAdd);
RearrangeHand(deckRearrangeTime, isNewReplayMoveTurn);
}
}
public virtual void AddCardToViewWithoutRearrange(IBattleCardView cardViewToAdd)
{
if (!_battleCardViewList.Contains(cardViewToAdd))
{
_battleCardViewList.Add(cardViewToAdd);
}
}
public void AddCardsToView(List<IBattleCardView> cardViewsToAdd, float deckRearrangeTime)
{
if (BattleManagerBase.GetIns().IsRecovery)
{
deckRearrangeTime = 0f;
}
List<IBattleCardView> list = cardViewsToAdd.FindAll((IBattleCardView cardView) => !_battleCardViewList.Contains(cardView));
if (list.Any())
{
_battleCardViewList.AddRange(list);
RearrangeHand(deckRearrangeTime);
}
}
public virtual void RemoveCardFromView(IBattleCardView cardViewToRemove, float deckRearrangeTime)
{
if (BattleManagerBase.GetIns().IsRecovery)
{
deckRearrangeTime = 0f;
}
if (_battleCardViewList.Contains(cardViewToRemove))
{
RemoveCardFromViewWithoutRearrange(cardViewToRemove);
RearrangeHand(deckRearrangeTime);
}
}
public virtual void RemoveCardFromViewWithoutRearrange(IBattleCardView cardViewToRemove)
{
if (_battleCardViewList.Remove(cardViewToRemove))
{
cardViewToRemove.isHiddenFromHandView = false;
}
}
public virtual VfxBase ShuffleHand()
{
return NullVfx.GetInstance();
}
public void HideCardFromView(IBattleCardView cardViewToHide)
{
float rearrangeTime = (BattleManagerBase.GetIns().IsRecovery ? 0f : 0.2f);
if (_battleCardViewList.Contains(cardViewToHide))
{
cardViewToHide.isHiddenFromHandView = true;
RearrangeHand(rearrangeTime);
}
}
public void UnhideCardFromView(IBattleCardView cardViewToHide, float deckRearrangeTime = 0.2f)
{
if (BattleManagerBase.GetIns().IsRecovery)
{
deckRearrangeTime = 0f;
}
if (_battleCardViewList.Contains(cardViewToHide))
{
cardViewToHide.isHiddenFromHandView = false;
RearrangeHand(deckRearrangeTime);
}
}
public void LockHandState()
{
_handControl.LockHandControlState();
}
public virtual VfxBase HandUnfocus()
{
_handControl.SetHandState(HandControl.HandState.Unfocus);
return ParallelVfxPlayer.Create(InstantVfx.Create(delegate
{
RearrangeHand(0.2f);
}), WaitVfx.Create(0.2f));
}
public virtual VfxBase HandFocus()
{
_handControl.SetHandState(HandControl.HandState.Focus);
return ParallelVfxPlayer.Create(InstantVfx.Create(delegate
{
RearrangeHand(0.2f);
}), WaitVfx.Create(0.2f));
}
public virtual VfxBase FocusRearrangeHandHand()
{
if (_handControl.IsHandStateFocus())
{
return HandFocus();
}
return HandUnfocus();
}
public HandControl GetHandControl()
{
return _handControl;
}
public void ReplaceCardInView(IBattleCardView originalView, IBattleCardView newView)
{
ReplaceCardInViewWithoutRearrange(originalView, newView);
}
public void ReplaceCardInViewWithoutRearrange(IBattleCardView originalView, IBattleCardView newView)
{
_battleCardViewList.Insert(_battleCardViewList.IndexOf(originalView), newView);
_battleCardViewList.RemoveAt(_battleCardViewList.IndexOf(originalView));
}
public int GetViewIndex(IBattleCardView viewCard)
{
return _battleCardViewList.IndexOf(viewCard);
}
public static VfxBase CreateHideCardMeshesVfx(IEnumerable<BattleCardBase> targetCards)
{
ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create();
if (!GameMgr.GetIns().IsAdmin)
{
foreach (BattleCardBase targetCard in targetCards)
{
parallelVfxPlayer.Register(new ShowCardNumberLabelVfx(targetCard.BattleCardView, isShow: false));
}
}
return parallelVfxPlayer;
}
public void ChangeArrangeType(HandControl.ArrangeType type)
{
_handControl.ChangeArrangeType(type, 0.3f, _battleCardViewList);
}
public virtual VfxBase AsyncTouchCard(GameObject card)
{
return NullVfx.GetInstance();
}
}