feat(battle-engine): close the AI-simulation subsystem (verbatim)
Copied the 89 uncopied AI*SimulationUtility/extension files defining the AIVirtualCard/AIVirtualField extension methods; the compile loop then auto-closed the revealed type deps (~3049 files total, drift-clean). 10.0k -> 62 errors.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
using Wizard.Battle.View.Vfx;
|
||||
|
||||
namespace Wizard.Battle.Recovery;
|
||||
|
||||
public class NullRecoveryManager : IRecoveryManager
|
||||
{
|
||||
public DataMgr.BattleType BattleType => DataMgr.BattleType.None;
|
||||
|
||||
public bool? DidPlayerGoFirst => null;
|
||||
|
||||
public int RandomSeed => 0;
|
||||
|
||||
public bool HasMulliganInfo => false;
|
||||
|
||||
public int BackGroundId => -1;
|
||||
|
||||
public string BgmId => "NONE";
|
||||
|
||||
public long RecordTime => 0L;
|
||||
|
||||
public int IdxChangeSeed => -1;
|
||||
|
||||
public event Action OnStartRecovery;
|
||||
|
||||
public event Action OnEndDataRecovery;
|
||||
|
||||
public event Action OnEndRecovery;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
this.OnStartRecovery.Call();
|
||||
this.OnEndDataRecovery.Call();
|
||||
this.OnEndRecovery.Call();
|
||||
}
|
||||
|
||||
public VfxBase Recovery(BattlePlayer battlePlayer, BattleEnemy battleEnemy, Func<IEnumerator, Coroutine> startCoroutine)
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
|
||||
public VfxBase UpdateRecovery()
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
|
||||
public void RecoveryBeforeMulligan()
|
||||
{
|
||||
}
|
||||
|
||||
public VfxBase RecoveryMulligan(BattlePlayer battlePlayer, BattleEnemy battleEnemy)
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
|
||||
public string RecoveryPopSkillTargetCardName()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wizard.Battle.Recovery;
|
||||
|
||||
public class NullRecoveryRecordManager : IRecoveryRecordManager
|
||||
{
|
||||
public void SetupRecording(BattleManagerBase battleMgr, DataMgr.BattleType battleType, int randomSeed, int backGroundId, string bgmId = "NONE")
|
||||
{
|
||||
}
|
||||
|
||||
public void RecordSkillTarget(IEnumerable<BattleCardBase> targetCards)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetupMulliganStartTimeRecorderEvent(BattleManagerBase battleMgr)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
using Wizard.Battle.Mulligan;
|
||||
using Wizard.Battle.Operation;
|
||||
using Wizard.Battle.View;
|
||||
using Wizard.Battle.View.Vfx;
|
||||
|
||||
namespace Wizard.Battle.Recovery;
|
||||
|
||||
public class SingleBattleRecoveryManager : RecoveryManagerBase
|
||||
{
|
||||
protected BattlePlayer _battlePlayer;
|
||||
|
||||
protected BattleEnemy _battleEnemy;
|
||||
|
||||
protected IEnumerable<IOperationCommand> _commands;
|
||||
|
||||
protected bool _isBeforeFramePlayerTurn = true;
|
||||
|
||||
private EnemyAI ai;
|
||||
|
||||
public SingleBattleRecoveryManager(string filePath)
|
||||
: base(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<int> CreateEnemyDeckIDList(BattleConditionEnemyInfo enemyInfo)
|
||||
{
|
||||
return enemyInfo.DeckCardInfos.Select((DeckCardInfo i) => i.CardId.Value).ToList();
|
||||
}
|
||||
|
||||
public override VfxBase Recovery(BattlePlayer battlePlayer, BattleEnemy battleEnemy, Func<IEnumerator, Coroutine> startCoroutine)
|
||||
{
|
||||
BattleManagerBase ins = BattleManagerBase.GetIns();
|
||||
ins.IsPreRecovery = true;
|
||||
_battlePlayer = battlePlayer;
|
||||
_battleEnemy = battleEnemy;
|
||||
ai = BattleManagerBase.GetIns().EnemyAI as EnemyAI;
|
||||
_ = ai;
|
||||
_battleEnemy.EnableEnemyAI = false;
|
||||
_battlePlayer.Emotion.Enable = false;
|
||||
_battleEnemy.Emotion.Enable = false;
|
||||
BattleManagerBase.GetIns().SetupEvolCount(_operationInfo.SetupInfo.DidPlayerGoFirst);
|
||||
SingleMulliganMgr singleMulliganMgr = new SingleMulliganMgr();
|
||||
MulliganInfoControl component = GameMgr.GetIns().GetGameObjMgr().AddUIContainerChildPrefab("Prefab/UI/MulliganInfo")
|
||||
.GetComponent<MulliganInfoControl>();
|
||||
singleMulliganMgr.InitMulligan(component, battlePlayer.PlayerBattleView);
|
||||
StartRecoveryEvent.Call();
|
||||
if (!base.HasMulliganInfo)
|
||||
{
|
||||
EndDataRecoveryEvent.Call();
|
||||
EndRecoveryEvent.Call();
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
SkillProcessor skillProcessor = new SkillProcessor();
|
||||
singleMulliganMgr.MulliganStartDraw(_operationInfo.SetupInfo.DidPlayerGoFirst, skillProcessor);
|
||||
foreach (int playerMulliganReplaceCard in _operationInfo.SetupInfo.PlayerMulliganReplaceCards)
|
||||
{
|
||||
int cardIndex = playerMulliganReplaceCard;
|
||||
BattleCardBase battleCardBase = battlePlayer.HandCardList.SingleOrDefault((BattleCardBase c) => c.Index == cardIndex);
|
||||
if (battleCardBase != null)
|
||||
{
|
||||
singleMulliganMgr.AbandonList.Add(battleCardBase);
|
||||
}
|
||||
}
|
||||
singleMulliganMgr.Submit(BattleManagerBase.GetIns());
|
||||
singleMulliganMgr.GetMulliganInfo().SetPlayerReady();
|
||||
_commands = _operationInfo.ActionCommands;
|
||||
_needUpdate = true;
|
||||
ins.IsPreRecovery = false;
|
||||
ins.IsRecovery = true;
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
|
||||
public override VfxBase UpdateRecovery()
|
||||
{
|
||||
if (!_needUpdate)
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
BattleManagerBase ins = BattleManagerBase.GetIns();
|
||||
if (_isBeforeFramePlayerTurn)
|
||||
{
|
||||
_ = _battleEnemy.IsSelfTurn;
|
||||
}
|
||||
if (_battleEnemy.IsSelfTurn)
|
||||
{
|
||||
foreach (BattleCardBase handCard in _battleEnemy.HandCardList)
|
||||
{
|
||||
handCard.SetOnDraw(draw: false);
|
||||
}
|
||||
}
|
||||
_isBeforeFramePlayerTurn = _battlePlayer.IsSelfTurn;
|
||||
IOperationCommand operationCommand = _commands.FirstOrDefault();
|
||||
if (operationCommand != null)
|
||||
{
|
||||
if (ai != null)
|
||||
{
|
||||
ai.UpdateAICurrentVirtualField();
|
||||
}
|
||||
operationCommand.Operation(ins);
|
||||
}
|
||||
_commands = _commands.Skip(1);
|
||||
if (_commands.Any() || _commands is TurnEndOperationCommand)
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
if (ins is SingleBattleMgr)
|
||||
{
|
||||
((SingleBattleMgr)ins).LifeZeroActivateLeonSkillIfNeeded();
|
||||
}
|
||||
if (ai != null)
|
||||
{
|
||||
ai.UpdateAICurrentVirtualField();
|
||||
}
|
||||
EndDataRecovery();
|
||||
RecoveryTurnStartPanel();
|
||||
_battlePlayer.PlayerBattleView.ClearPlayQueue();
|
||||
if (_battlePlayer.IsSelfTurn)
|
||||
{
|
||||
_battlePlayer.TurnStartEffectEnd();
|
||||
_battlePlayer._isPlayerActive = true;
|
||||
}
|
||||
_battleEnemy.BattleEnemyView.ClearPlayQueue();
|
||||
ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create(InstantVfx.Create(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetBattleCtrl().StartCoroutine(FontChanger.FontChange(null));
|
||||
}), _battlePlayer.BattleView.Recovery(_operationInfo.SetupInfo.DidPlayerGoFirst, _battlePlayer.HandCardList.Count > 0), _battleEnemy.BattleView.Recovery(!_operationInfo.SetupInfo.DidPlayerGoFirst), _battlePlayer.Recovery(), _battleEnemy.Recovery());
|
||||
string path = GameMgr.GetIns().GetDataMgr().GetPlayerSkinId()
|
||||
.ToString("00");
|
||||
string path2 = GameMgr.GetIns().GetDataMgr().GetEnemySkinId()
|
||||
.ToString("00");
|
||||
parallelVfxPlayer.Register(new WaitLoadResourceVfx(Toolbox.ResourcesManager.GetAssetTypePath(path, ResourcesManager.AssetLoadPathType.ClassCharaBase)));
|
||||
parallelVfxPlayer.Register(new WaitLoadResourceVfx(Toolbox.ResourcesManager.GetAssetTypePath(path2, ResourcesManager.AssetLoadPathType.ClassCharaBase)));
|
||||
IBattlePlayerView battlePlayerView = (_battleEnemy.IsSelfTurn ? _battleEnemy.BattleView : _battlePlayer.BattleView);
|
||||
SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
|
||||
sequentialVfxPlayer.Register(parallelVfxPlayer);
|
||||
sequentialVfxPlayer.Register(HandViewBase.CreateHideCardMeshesVfx(_battleEnemy.HandCardList));
|
||||
sequentialVfxPlayer.Register(InstantVfx.Create(delegate
|
||||
{
|
||||
_battleEnemy.EnableEnemyAI = true;
|
||||
_battlePlayer.Emotion.Enable = true;
|
||||
_battleEnemy.Emotion.Enable = true;
|
||||
ResetLeaderAnimation(_battlePlayer, _battleEnemy);
|
||||
_battlePlayer.UpdateHandCardsPlayability();
|
||||
Dump(_battlePlayer, _battleEnemy);
|
||||
EndRecoveryEvent.Call();
|
||||
}));
|
||||
sequentialVfxPlayer.Register(battlePlayerView.RecoveryTurnStart());
|
||||
ins.IsRecovery = false;
|
||||
return sequentialVfxPlayer;
|
||||
}
|
||||
|
||||
public SetupConditionInfo GetSetupConditionInfo()
|
||||
{
|
||||
if (_operationInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _operationInfo.SetupInfo;
|
||||
}
|
||||
|
||||
public void CreateRecoveryFileFromTempFile()
|
||||
{
|
||||
if (SingleBattleRecoveryRecordManager.IsExistsTempSingleRecoveryFile())
|
||||
{
|
||||
string recordDirectoryPath = OperationRecorderBase.RecordDirectoryPath;
|
||||
string sourceFileName = recordDirectoryPath + "temp_recovery_single.json";
|
||||
string destFileName = recordDirectoryPath + "recovery_single.json";
|
||||
File.Copy(sourceFileName, destFileName, overwrite: true);
|
||||
SingleBattleRecoveryRecordManager.DeleteTempRecoveryFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Wizard.Battle.Recovery;
|
||||
|
||||
public class SingleBattleRecoveryRecordManager : RecoveryRecordManagerBase
|
||||
{
|
||||
public const string TEMP_RECOVERY_SINGLE_FILE_NAME = "temp_recovery_single.json";
|
||||
|
||||
protected override string DefaultRecoveryFileName => "recovery_single.json";
|
||||
|
||||
public SingleBattleRecoveryRecordManager()
|
||||
{
|
||||
}
|
||||
|
||||
public SingleBattleRecoveryRecordManager(string filePath)
|
||||
: base(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetupRecording(BattleManagerBase battleMgr, DataMgr.BattleType battleType, int randomSeed, int backGroundId, string bgmId = "NONE")
|
||||
{
|
||||
base.SetupRecording(battleMgr, battleType, randomSeed, backGroundId, bgmId);
|
||||
RecordSingleBattleSettings(_recorder, battleType, randomSeed, backGroundId, bgmId);
|
||||
}
|
||||
|
||||
protected override OperationRecorderBase CreateOperationRecorder()
|
||||
{
|
||||
if (RecoveryRecordManagerBase.IsExistsSingleRecoveryFile())
|
||||
{
|
||||
string tempFilePath = OperationRecorderBase.RecordDirectoryPath + "temp_recovery_single.json";
|
||||
RecoveryRecordManagerBase.DeleteRecoveryFile();
|
||||
return new SingleBattleOperationRecorder(_recoveryFilePath, tempFilePath);
|
||||
}
|
||||
return new SingleBattleOperationRecorder(_recoveryFilePath);
|
||||
}
|
||||
|
||||
public static void DeleteTempRecoveryFile()
|
||||
{
|
||||
if (File.Exists(OperationRecorderBase.RecordDirectoryPath + "temp_recovery_single.json"))
|
||||
{
|
||||
File.Delete(OperationRecorderBase.RecordDirectoryPath + "temp_recovery_single.json");
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearRecoderTempFilePath()
|
||||
{
|
||||
((SingleBattleOperationRecorder)_recorder).ClearTempRecoveryFilePath();
|
||||
}
|
||||
|
||||
protected override void SetupRecorderEvents(OperationRecorderBase operationRecorder, BattleManagerBase battleMgr)
|
||||
{
|
||||
base.SetupRecorderEvents(operationRecorder, battleMgr);
|
||||
battleMgr.OperateMgr.OnTurnEnd += operationRecorder.RecordTurnEnd;
|
||||
}
|
||||
|
||||
protected void RecordSingleBattleSettings(OperationRecorderBase operationRecorder, DataMgr.BattleType battleType, int randomSeed, int backGroundId, string bgmId)
|
||||
{
|
||||
DataMgr dataMgr = _gameMgr.GetDataMgr();
|
||||
operationRecorder.RecordBattleType(battleType);
|
||||
operationRecorder.RecordRandomSeed(randomSeed);
|
||||
operationRecorder.RecordBackGroundId(backGroundId);
|
||||
operationRecorder.RecordBgmId(bgmId);
|
||||
operationRecorder.RecordClass("player", dataMgr.GetPlayerClassId());
|
||||
operationRecorder.RecordSubClass("player", dataMgr.GetPlayerSubClassId());
|
||||
if (dataMgr.TryGetPlayerMyRotationInfo(out var myRotationInfo))
|
||||
{
|
||||
operationRecorder.RecordMyRotationId("player", myRotationInfo.Id);
|
||||
}
|
||||
operationRecorder.RecordClass("enemy", dataMgr.GetEnemyClassId());
|
||||
operationRecorder.RecordSubClass("enemy", dataMgr.GetEnemySubClassId());
|
||||
if (dataMgr.TryGetEnemyMyRotationInfo(out var myRotationInfo2))
|
||||
{
|
||||
operationRecorder.RecordMyRotationId("enemy", myRotationInfo2.Id);
|
||||
}
|
||||
operationRecorder.RecordChara("player", dataMgr.GetPlayerCharaId());
|
||||
operationRecorder.RecordChara("enemy", dataMgr.GetEnemyCharaId());
|
||||
operationRecorder.RecordSleeve("player", dataMgr.GetPlayerSleeveId());
|
||||
operationRecorder.RecordSleeve("enemy", dataMgr.GetEnemySleeveId());
|
||||
operationRecorder.RecordDeck("player", 'p', dataMgr.GetCurrentDeckData());
|
||||
operationRecorder.RecordDeck("enemy", 'e', dataMgr.GetCurrentEnemyDeckData());
|
||||
operationRecorder.RecordEnemyAIDifficulty(dataMgr.m_EnemyAIDifficulty);
|
||||
operationRecorder.RecordEnemyAILogicLevel(dataMgr.m_EnemyAILogicLevel);
|
||||
operationRecorder.RecordEnemyAIMaxLife(dataMgr.m_EnemyAIMaxLife);
|
||||
operationRecorder.RecordEnemyAIDeckId(dataMgr.m_EnemyAIDeckId);
|
||||
operationRecorder.RecordEnemyAIStyleId(dataMgr.m_EnemyAIStyleId);
|
||||
operationRecorder.RecordEnemyAIEmoteId(dataMgr.m_EnemyAIEmoteId);
|
||||
operationRecorder.RecordEnemyAIUseInnerEmote(dataMgr.m_EnemyAIUseInnerEmote);
|
||||
operationRecorder.RecordPracticeDifficultyDegreeId(dataMgr.PracticeDifficultyDegreeId);
|
||||
operationRecorder.RecordIsPreBuildDeck(dataMgr.IsLastSelectDeckAttributeType(DeckAttributeType.BuildDeck));
|
||||
operationRecorder.RecordIsTrialDeck(dataMgr.IsLastSelectDeckAttributeType(DeckAttributeType.TrialDeck));
|
||||
operationRecorder.RecordIsDefaultDeck(dataMgr.GetSelectDefDeck());
|
||||
operationRecorder.RecordMissionNecessaryInformation(dataMgr.MissionNecessaryInformation);
|
||||
switch (battleType)
|
||||
{
|
||||
case DataMgr.BattleType.Quest:
|
||||
operationRecorder.RecordQuestStageId(dataMgr.QuestBattleData.QuestStageId);
|
||||
operationRecorder.RecordQuestEnemyAiId(dataMgr.QuestBattleData.EnemyAiId);
|
||||
operationRecorder.RecordQuestEnemyEmblemId(dataMgr.QuestBattleData.EmblemId);
|
||||
operationRecorder.RecordQuestEnemyDegreeId(dataMgr.QuestBattleData.DegreeId);
|
||||
operationRecorder.RecordQuestEnemyEmotionOverride(dataMgr.QuestBattleData.EnemyEmotionOverride);
|
||||
operationRecorder.RecordQuestPlayerEmotionOverride(dataMgr.QuestBattleData.PlayerEmotionOverride);
|
||||
operationRecorder.RecordQuestIsExtra(dataMgr.QuestBattleData.IsExtra);
|
||||
operationRecorder.RecordQuestIsMockBattle(dataMgr.QuestBattleData.IsMockBattle);
|
||||
operationRecorder.RecordQuestExtraDeckScheduleId(dataMgr.QuestBattleData.ExtraDeckScheduleId);
|
||||
break;
|
||||
case DataMgr.BattleType.BossRushQuest:
|
||||
operationRecorder.RecordQuestStageId(dataMgr.BossRushBattleData.QuestStageId);
|
||||
operationRecorder.RecordQuestEnemyAiId(dataMgr.BossRushBattleData.EnemyAiId);
|
||||
operationRecorder.RecordQuestEnemyEmblemId(dataMgr.BossRushBattleData.EmblemId);
|
||||
operationRecorder.RecordQuestEnemyDegreeId(dataMgr.BossRushBattleData.DegreeId);
|
||||
operationRecorder.RecordQuestRecoveryPoint(dataMgr.BossRushBattleData.RecoveryPointWhenFinish);
|
||||
operationRecorder.RecordQuestPlayerSkillList(dataMgr.BossRushBattleData.PlayerSkillList);
|
||||
operationRecorder.RecordQuestEnemySkill(dataMgr.BossRushBattleData.EnemySkill);
|
||||
operationRecorder.RecordQuestMaxBattleCount(dataMgr.BossRushBattleData.MaxBattleCount);
|
||||
operationRecorder.RecordQuestCurrentWinCount(dataMgr.BossRushBattleData.CurrentWinCount);
|
||||
break;
|
||||
case DataMgr.BattleType.SecretBossQuest:
|
||||
operationRecorder.RecordQuestStageId(dataMgr.BossRushBattleData.QuestStageId);
|
||||
operationRecorder.RecordQuestEnemyAiId(dataMgr.BossRushBattleData.EnemyAiId);
|
||||
operationRecorder.RecordQuestEnemyEmblemId(dataMgr.BossRushBattleData.EmblemId);
|
||||
operationRecorder.RecordQuestEnemyDegreeId(dataMgr.BossRushBattleData.DegreeId);
|
||||
operationRecorder.RecordQuestPlayerSkillList(dataMgr.BossRushBattleData.PlayerSkillList);
|
||||
operationRecorder.RecordQuestEnemySkill(dataMgr.BossRushBattleData.EnemySkill);
|
||||
break;
|
||||
case DataMgr.BattleType.Practice:
|
||||
operationRecorder.RecordPractice3DFieldId(dataMgr.GetSoroPlay3DFieldID());
|
||||
break;
|
||||
case DataMgr.BattleType.Story:
|
||||
operationRecorder.RecordStoryData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecordChangeAI(string logicName, int operationQueueCount)
|
||||
{
|
||||
if (_recorder is SingleBattleOperationRecorder singleBattleOperationRecorder)
|
||||
{
|
||||
singleBattleOperationRecorder.RecordChangeAI(logicName, operationQueueCount);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsExistsTempSingleRecoveryFile()
|
||||
{
|
||||
return File.Exists(OperationRecorderBase.RecordDirectoryPath + "temp_recovery_single.json");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user