一些修复和优化
This commit is contained in:
@@ -25,6 +25,7 @@ public sealed class PackagingBuildGuard : IPreprocessBuildWithReport
|
||||
var problems = new List<string>();
|
||||
|
||||
CheckPlayers(problems);
|
||||
CheckPlayerSkills(problems);
|
||||
CheckHeroes(problems);
|
||||
CheckSongs(problems);
|
||||
CheckMails(problems);
|
||||
@@ -85,6 +86,24 @@ public sealed class PackagingBuildGuard : IPreprocessBuildWithReport
|
||||
problems.Add(path + " :: uRankingScore = " + rank.floatValue);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerExperienceRuntimeProbe expProbe;
|
||||
if (SecureSaveVault.TryLoadJson("player_experience", "runtime", out expProbe) && expProbe != null && expProbe.playerExp != 0)
|
||||
{
|
||||
problems.Add("player_experience/runtime :: playerExp = " + expProbe.playerExp);
|
||||
}
|
||||
|
||||
int backupExp;
|
||||
if (PlayerProgressBackupService.TryRestorePlayerExperience(out backupExp) && backupExp != 0)
|
||||
{
|
||||
problems.Add("player progress backup :: playerExperience = " + backupExp);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private sealed class PlayerExperienceRuntimeProbe
|
||||
{
|
||||
public int playerExp;
|
||||
}
|
||||
|
||||
private static void CheckHeroes(List<string> problems)
|
||||
@@ -118,6 +137,62 @@ public sealed class PackagingBuildGuard : IPreprocessBuildWithReport
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckPlayerSkills(List<string> problems)
|
||||
{
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:userLevel_skills_SO"))
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var so = AssetDatabase.LoadAssetAtPath<userLevel_skills_SO>(path);
|
||||
if (so == null || so.skills == null || so.skills.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int enabledCount = 0;
|
||||
int enabledIndex = -1;
|
||||
for (int i = 0; i < so.skills.Count; i++)
|
||||
{
|
||||
var entry = so.skills[i];
|
||||
if (entry != null && entry.isEnabled)
|
||||
{
|
||||
enabledCount++;
|
||||
enabledIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (enabledCount != 1 || enabledIndex != 0)
|
||||
{
|
||||
problems.Add(path + " :: player skill selection must ship with only index 0 enabled, current enabledIndex=" + enabledIndex + ", enabledCount=" + enabledCount);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSkillSaveData runtimeSkillData;
|
||||
if (SecureSaveVault.TryLoadJson("player_skills", "runtime", out runtimeSkillData) && runtimeSkillData != null)
|
||||
{
|
||||
if (runtimeSkillData.selectedSkillIndex != 0 ||
|
||||
runtimeSkillData.postMatchRewardCounter != 0 ||
|
||||
runtimeSkillData.skillSwitchCooldownRemainingMatches != 0)
|
||||
{
|
||||
problems.Add("player_skills/runtime :: selectedSkillIndex=" + runtimeSkillData.selectedSkillIndex
|
||||
+ ", postMatchRewardCounter=" + runtimeSkillData.postMatchRewardCounter
|
||||
+ ", skillSwitchCooldownRemainingMatches=" + runtimeSkillData.skillSwitchCooldownRemainingMatches);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSkillSaveData backupSkillData;
|
||||
if (PlayerProgressBackupService.TryRestorePlayerSkill(out backupSkillData) && backupSkillData != null)
|
||||
{
|
||||
if (backupSkillData.selectedSkillIndex != 0 ||
|
||||
backupSkillData.postMatchRewardCounter != 0 ||
|
||||
backupSkillData.skillSwitchCooldownRemainingMatches != 0)
|
||||
{
|
||||
problems.Add("player progress backup :: playerSkill selectedSkillIndex=" + backupSkillData.selectedSkillIndex
|
||||
+ ", postMatchRewardCounter=" + backupSkillData.postMatchRewardCounter
|
||||
+ ", skillSwitchCooldownRemainingMatches=" + backupSkillData.skillSwitchCooldownRemainingMatches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckSongs(List<string> problems)
|
||||
{
|
||||
string[] recordFields =
|
||||
|
||||
@@ -41,7 +41,7 @@ public static class PackagingResetTool
|
||||
"2.5 歌曲:游玩次数、累计时长、各难度成绩记录清零(歌曲解锁/谱面配置不动)\n" +
|
||||
"3. 装备:删除 " + GeneratedEquipmentFolder + " 下所有生成装备,清除英雄已装备引用\n" +
|
||||
"4. 商店:所有物品 purchasedCount、user_has_read 清零(限购配置 itemPurchaseQuota 不动)\n" +
|
||||
"5. 清理本机测试存档(.cache_bridge 货币/成长/经验瓶/突破材料/装备消耗品、player_rks、player_experience、装备/商店存档,不含拥有权账本)与相关 PlayerPrefs\n\n" +
|
||||
"5. 清理本机测试存档(.cache_bridge 货币/成长/经验瓶/突破材料/装备消耗品、player_rks、player_experience、player_skills、装备/商店存档,不含拥有权账本)与相关 PlayerPrefs\n\n" +
|
||||
"此操作会修改并保存资产文件,建议在版本控制下执行。是否继续?",
|
||||
"执行重置",
|
||||
"取消");
|
||||
@@ -65,6 +65,7 @@ public static class PackagingResetTool
|
||||
AssetDatabase.StartAssetEditing();
|
||||
|
||||
errors += ResetPlayers(report);
|
||||
errors += ResetPlayerSkills(report);
|
||||
errors += ResetHeroes(report);
|
||||
errors += ResetSongs(report);
|
||||
errors += DeleteGeneratedEquipmentAssets(report);
|
||||
@@ -129,9 +130,53 @@ public static class PackagingResetTool
|
||||
}
|
||||
|
||||
report.AppendLine("玩家资产已重置:" + count + " 个 Player_SO。");
|
||||
try
|
||||
{
|
||||
SecureSaveVault.Delete("player_skills", "runtime");
|
||||
PlayerProgressBackupService.ClearPlayerSkillBackup();
|
||||
report.AppendLine("已清理 player_skills 运行时存档与备份(player_skills/runtime)。");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errors++;
|
||||
report.AppendLine("清理 player_skills 存档失败:" + ex.Message);
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
private static int ResetPlayerSkills(StringBuilder report)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var guid in AssetDatabase.FindAssets("t:userLevel_skills_SO"))
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var so = AssetDatabase.LoadAssetAtPath<userLevel_skills_SO>(path);
|
||||
if (so == null || so.skills == null || so.skills.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var serialized = new SerializedObject(so);
|
||||
var skills = serialized.FindProperty("skills");
|
||||
if (skills != null && skills.isArray)
|
||||
{
|
||||
for (int i = 0; i < skills.arraySize; i++)
|
||||
{
|
||||
var entry = skills.GetArrayElementAtIndex(i);
|
||||
SetChildBool(entry, "isEnabled", i == 0);
|
||||
}
|
||||
}
|
||||
|
||||
serialized.ApplyModifiedPropertiesWithoutUndo();
|
||||
EditorUtility.SetDirty(so);
|
||||
count++;
|
||||
}
|
||||
|
||||
report.AppendLine("玩家技能资产已重置:" + count + " 个 userLevel_skills_SO(仅启用第 0 个技能)。");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int ResetHeroes(StringBuilder report)
|
||||
{
|
||||
int count = 0;
|
||||
@@ -237,6 +282,15 @@ public static class PackagingResetTool
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetChildBool(SerializedProperty parent, string field, bool value)
|
||||
{
|
||||
var prop = parent.FindPropertyRelative(field);
|
||||
if (prop != null)
|
||||
{
|
||||
prop.boolValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static int DeleteGeneratedEquipmentAssets(StringBuilder report)
|
||||
{
|
||||
if (!AssetDatabase.IsValidFolder(GeneratedEquipmentFolder))
|
||||
@@ -383,6 +437,7 @@ public static class PackagingResetTool
|
||||
{
|
||||
string legacyExpPath = Path.Combine(Application.persistentDataPath, "player_experience.json");
|
||||
SecureSaveVault.Delete("player_experience", "runtime", legacyExpPath);
|
||||
PlayerProgressBackupService.ClearPlayerExperienceBackup();
|
||||
report.AppendLine("已清理 player_experience 运行时存档(player_experience/runtime)。");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user