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.
This commit is contained in:
142
SVSim.BattleEngine/Engine/Wizard/CardMasterLocalFileUtility.cs
Normal file
142
SVSim.BattleEngine/Engine/Wizard/CardMasterLocalFileUtility.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Wizard;
|
||||
|
||||
public static class CardMasterLocalFileUtility
|
||||
{
|
||||
private static readonly string CARDMASTER_DIRECTORY_NAME = "cardmaster";
|
||||
|
||||
private static string CardMasterDirPath => Path.Combine(Application.persistentDataPath, CARDMASTER_DIRECTORY_NAME);
|
||||
|
||||
private static string GetCardMasterFilePath(CardMaster.CardMasterId cardMasterId)
|
||||
{
|
||||
return Path.Combine(CardMasterDirPath, $"card_master_{(int)cardMasterId}");
|
||||
}
|
||||
|
||||
public static string GetCardMasterHash()
|
||||
{
|
||||
string cardMasterFilePath = GetCardMasterFilePath(CardMaster.CardMasterId.Default);
|
||||
string result = string.Empty;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(cardMasterFilePath))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
using StreamReader streamReader = new StreamReader(cardMasterFilePath);
|
||||
result = CryptAES.decryptForNode(streamReader.ReadLine());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteClientInfoLog("CardMasater: \"" + cardMasterFilePath + "\" の読み込みに失敗\n" + ex);
|
||||
result = string.Empty;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool ReadLocalCardMasterCSV(out Dictionary<CardMaster.CardMasterId, string> dictCardMasterCsv)
|
||||
{
|
||||
dictCardMasterCsv = new Dictionary<CardMaster.CardMasterId, string>();
|
||||
foreach (CardMaster.CardMasterId value in Enum.GetValues(typeof(CardMaster.CardMasterId)))
|
||||
{
|
||||
string cardMasterFilePath = GetCardMasterFilePath(value);
|
||||
if (!File.Exists(cardMasterFilePath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
using StreamReader streamReader = new StreamReader(cardMasterFilePath);
|
||||
if (value == CardMaster.CardMasterId.Default)
|
||||
{
|
||||
streamReader.ReadLine();
|
||||
}
|
||||
dictCardMasterCsv[value] = CryptAES.decryptForNode(streamReader.ReadToEnd());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteClientInfoLog("CardMasater: \"" + cardMasterFilePath + "\" の読み込みに失敗\n" + ex);
|
||||
CreateMasterReadErrorDialog();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void CreateMasterReadErrorDialog()
|
||||
{
|
||||
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
|
||||
dialogBase.SetSize(DialogBase.Size.M);
|
||||
dialogBase.SetTitleLabel(Data.SystemText.Get("System_0055"));
|
||||
dialogBase.SetText(Data.SystemText.Get("System_0056"));
|
||||
DeleteAllCardMasterLocalFile();
|
||||
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BackToTitleBtn);
|
||||
dialogBase.SetFadeButtonEnabled(flag: false);
|
||||
}
|
||||
|
||||
public static void WriteAllCardMasterLocalFile(Dictionary<CardMaster.CardMasterId, string> dictCardMasterCSV, string cardMasterHash)
|
||||
{
|
||||
DeleteAllCardMasterLocalFile();
|
||||
Directory.CreateDirectory(CardMasterDirPath);
|
||||
foreach (KeyValuePair<CardMaster.CardMasterId, string> item in dictCardMasterCSV)
|
||||
{
|
||||
CardMaster.CardMasterId key = item.Key;
|
||||
string value = item.Value;
|
||||
if (!(value == ""))
|
||||
{
|
||||
string text = null;
|
||||
if (key == CardMaster.CardMasterId.Default)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendLine(CryptAES.encryptForNode(cardMasterHash));
|
||||
stringBuilder.AppendLine(CryptAES.encryptForNode(value));
|
||||
text = stringBuilder.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
text = CryptAES.encryptForNode(value);
|
||||
}
|
||||
WriteCardMasterLocalFile(key, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteCardMasterLocalFile(CardMaster.CardMasterId cardMasterId, string writeStr)
|
||||
{
|
||||
string cardMasterFilePath = GetCardMasterFilePath(cardMasterId);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(cardMasterFilePath, writeStr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteClientInfoLog("CardMasater: \"" + cardMasterFilePath + "\" の書き込みに失敗\n" + ex);
|
||||
DeleteAllCardMasterLocalFile();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteAllCardMasterLocalFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(CardMasterDirPath))
|
||||
{
|
||||
Directory.Delete(CardMasterDirPath, recursive: true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteClientInfoLog("CardMasaterディレクトリ: \"" + CardMasterDirPath + "\" の削除に失敗\n" + ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteClientInfoLog(string log)
|
||||
{
|
||||
LocalLog.AccumulateTraceLog(log);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user