Skip to content

Commit

Permalink
Mission Dumping
Browse files Browse the repository at this point in the history
also some debug commands
  • Loading branch information
BlazingTwist committed Dec 21, 2021
1 parent 0d8a8d6 commit e44f2dd
Show file tree
Hide file tree
Showing 6 changed files with 328 additions and 26 deletions.
3 changes: 3 additions & 0 deletions SoD_BaseMod/SoD_BaseMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<Compile Include="src\asm\EREelPatcher.cs" />
<Compile Include="src\asm\Extensions\EelRoastManagerExtensions.cs" />
<Compile Include="src\asm\Extensions\KAConsoleExtensions.cs" />
<Compile Include="src\asm\Extensions\MissionManager_Extensions.cs" />
<Compile Include="src\asm\Extensions\SanctuaryPet_Extensions.cs" />
<Compile Include="src\asm\Extensions\UiAvatarControlsExtensions.cs" />
<Compile Include="src\asm\Extensions\UiBackpackExtensions.cs" />
Expand All @@ -143,6 +144,7 @@
<Compile Include="src\asm\UiEndDBPatcher.cs" />
<Compile Include="src\asm\UiSelectProfilePatcher.cs" />
<Compile Include="src\asm\WeaponManagerPatcher.cs" />
<Compile Include="src\asm\WorldEventScoutAttackPatches.cs" />
<Compile Include="src\basemod\BTAnimationPlayerManager.cs" />
<Compile Include="src\basemod\BTConfigHolder.cs" />
<Compile Include="src\basemod\BTCutsceneManager.cs" />
Expand Down Expand Up @@ -208,6 +210,7 @@
<Compile Include="src\basemod\extensions\StringBuilderExtensions.cs" />
<Compile Include="src\basemod\HackLogic.cs" />
<Compile Include="src\basemod\utils\LoggerUtils.cs" />
<Compile Include="src\basemod\utils\TableUtils.cs" />
<Compile Include="src\SodBaseMod.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
17 changes: 17 additions & 0 deletions SoD_BaseMod/src/asm/Extensions/MissionManager_Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using HarmonyLib;

namespace SoD_BaseMod.Extensions {
[HarmonyPatch(declaringType: typeof(MissionManager))]
public static class MissionManager_Extensions {
[HarmonyReversePatch,
HarmonyPatch(methodName: "GetUserMissionStaticEventHandler", argumentTypes: new[] {
typeof(WsServiceType), typeof(WsServiceEvent), typeof(float), typeof(object), typeof(object)
})]
public static void GetUserMissionStaticEventHandler(this MissionManager __instance,
WsServiceType inType, WsServiceEvent inEvent, float inProgress, object inObject, object inUserData) {
/* dummy content */
throw new NotImplementedException("Stub called, reverse patch has not been applied!");
}
}
}
33 changes: 33 additions & 0 deletions SoD_BaseMod/src/asm/WorldEventScoutAttackPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using HarmonyLib;
using SoD_BaseMod.console;

namespace SoD_BaseMod {
[HarmonyPatch(declaringType: typeof(WorldEventScoutAttack))]
public static class WorldEventScoutAttackPatches {
[HarmonyPostfix, HarmonyPatch(methodName: "PopulateScore", argumentTypes: new[] { typeof(string[]), typeof(bool) })]
private static void PopulateScore_Postfix(WorldEventScoutAttack __instance, string[] playersData, bool eventWon) {
WorldEventManager.WorldEventAchievementRewardInfo[] rewardInfo = new Traverse(__instance)
.Field("mCurrentRewardInfo")
.GetValue<WorldEventManager.WorldEventAchievementRewardInfo[]>();
if (rewardInfo == null) {
BTConsole.WriteLine("rewardInfo was null!");
return;
}

BTConsole.WriteLine($" Found {rewardInfo.Length} rewardInfos");
foreach (WorldEventManager.WorldEventAchievementRewardInfo info in rewardInfo) {
if (info == null) {
BTConsole.WriteLine("info was null!");
continue;
}
BTConsole.WriteLine(
" "
+ "_RewardNameText = " + info._RewardNameText + " | "
+ "_RewardTier = " + info._RewardTier + " | "
+ "_AchievementID = " + info._AchievementID + " | "
+ "_AdRewardAchievementID = " + info._AdRewardAchievementID
);
}
}
}
}
114 changes: 99 additions & 15 deletions SoD_BaseMod/src/basemod/console/commands/BTDebugCommands.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Text;
using HarmonyLib;
using KA.Framework;
using KnowledgeAdventure.Multiplayer.Utility;
using SoD_BaseMod.Extensions;
Expand Down Expand Up @@ -64,10 +65,28 @@ public static void Register() {
));
BTConsole.AddCommand(new BTConsoleCommand(
new List<string> { "DebugCommand" },
new BTDebugCommandInput(),
"debug command used for executing test code on command",
new BTNoArgsInput(),
"debug command used for executing test code on command (currently logging pet shader details)",
OnExecuteDebugCommand
));
BTConsole.AddCommand(new BTConsoleCommand(
new List<string> { "DebugCommand2" },
new BTNoArgsInput(),
"debug command used for executing test code on command (currently mission data logging)",
OnExecuteDebugCommand2
));
BTConsole.AddCommand(new BTConsoleCommand(
new List<string> { "DebugCommand3" },
new BTNoArgsInput(),
"debug command used for executing test code on command",
OnExecuteDebugCommand3
));
BTConsole.AddCommand(new BTConsoleCommand(
new List<string> { "DebugCommand4" },
new BTNoArgsInput(),
"debug command used for executing test code on command",
OnExecuteDebugCommand4
));
}

private static void OnExecuteDebugUnload(BTConsoleCommand.BTCommandInput input) {
Expand All @@ -86,7 +105,7 @@ private static void OnExecuteDebugFix(BTConsoleCommand.BTCommandInput input) {
}

private static void OnExecuteDebugInfo(BTConsoleCommand.BTCommandInput input) {
var cmdInput = (BTDebugInfoInput) input;
var cmdInput = (BTDebugInfoInput)input;
GameObject debugUI = GameObject.Find("PfUiDebugInfo");
if (debugUI == null) {
BTConsole.WriteLine("error - Can't find debug UI");
Expand All @@ -101,7 +120,7 @@ private class BTDebugInfoInput : BTConsoleCommand.BTCommandInput {
public bool show;

private void SetShow(object show, bool isPresent) {
this.show = (bool) show;
this.show = (bool)show;
}

protected override IEnumerable<BTConsoleCommand.BTConsoleArgument> BuildConsoleArguments() {
Expand All @@ -123,7 +142,7 @@ private static void OnExecuteDebugDeletePlayerPrefs(BTConsoleCommand.BTCommandIn
}

private static void OnExecuteDebugMemDump(BTConsoleCommand.BTCommandInput input) {
var cmdInput = (BTDebugMemDumpInput) input;
var cmdInput = (BTDebugMemDumpInput)input;
string outputFileName = MemDump.WriteToFile(cmdInput.fileName);
BTConsole.WriteLine("Dumping Memory to file " + outputFileName);
}
Expand All @@ -132,7 +151,7 @@ private class BTDebugMemDumpInput : BTConsoleCommand.BTCommandInput {
public string fileName;

private void SetFileName(object fileName, bool isPresent) {
this.fileName = isPresent ? "_" + (string) fileName : "";
this.fileName = isPresent ? "_" + (string)fileName : "";
}

protected override IEnumerable<BTConsoleCommand.BTConsoleArgument> BuildConsoleArguments() {
Expand Down Expand Up @@ -165,7 +184,7 @@ private static void OnExecuteDebugSceneObjects(BTConsoleCommand.BTCommandInput i
}

private static void OnExecuteDebugParticles(BTConsoleCommand.BTCommandInput input) {
var cmdInput = (BTDebugParticlesInput) input;
var cmdInput = (BTDebugParticlesInput)input;
if (!(Resources.FindObjectsOfTypeAll(typeof(ParticleSystem)) is ParticleSystem[] allParticleSystems)) {
BTConsole.WriteLine("Did not find any particle systems!");
return;
Expand All @@ -184,7 +203,7 @@ private class BTDebugParticlesInput : BTConsoleCommand.BTCommandInput {
public bool enable;

private void SetEnable(object enable, bool isPresent) {
this.enable = (bool) enable;
this.enable = (bool)enable;
}

protected override IEnumerable<BTConsoleCommand.BTConsoleArgument> BuildConsoleArguments() {
Expand All @@ -201,7 +220,7 @@ private void SetEnable(object enable, bool isPresent) {
}

private static void OnExecuteDebugMask(BTConsoleCommand.BTCommandInput input) {
var cmdInput = (BTDebugMaskInput) input;
var cmdInput = (BTDebugMaskInput)input;
if (cmdInput.add) {
UtDebug._Mask |= cmdInput.mask;
BTConsole.WriteLine("DebugMask " + cmdInput.mask + " added.");
Expand All @@ -219,11 +238,11 @@ private class BTDebugMaskInput : BTConsoleCommand.BTCommandInput {
public bool add;

private void SetMask(object mask, bool isPresent) {
this.mask = (uint) mask;
this.mask = (uint)mask;
}

private void SetAdd(object add, bool isPresent) {
this.add = (bool) add;
this.add = (bool)add;
}

protected override IEnumerable<BTConsoleCommand.BTConsoleArgument> BuildConsoleArguments() {
Expand All @@ -247,7 +266,6 @@ private void SetAdd(object add, bool isPresent) {
}

private static void OnExecuteDebugCommand(BTConsoleCommand.BTCommandInput input) {
var cmdInput = (BTDebugCommandInput) input;
StringBuilder outputBuilder = new StringBuilder();
Dictionary<string, SkinnedMeshRenderer> rendererMap = SanctuaryManager.pCurPetInstance.GetRendererMap();
foreach (KeyValuePair<string, SkinnedMeshRenderer> skinnedMeshRenderer in rendererMap) {
Expand Down Expand Up @@ -276,9 +294,75 @@ private static void OnExecuteDebugCommand(BTConsoleCommand.BTCommandInput input)
BTConsole.WriteLine(outputBuilder.ToString());
}

private class BTDebugCommandInput : BTConsoleCommand.BTCommandInput {
protected override IEnumerable<BTConsoleCommand.BTConsoleArgument> BuildConsoleArguments() {
return new List<BTConsoleCommand.BTConsoleArgument>();
private static void OnExecuteDebugCommand2(BTConsoleCommand.BTCommandInput input) {
List<int> achievementIDs = new List<int> { /*206051, 206052, 206053, 206054, 206055, 206056,*/ 206057 };

foreach (int achievementID in achievementIDs) {
WsWebService.SetAchievementAndGetReward(achievementID, "", (inType, inEvent, progress, inObject, data) => {
if (inEvent == WsServiceEvent.ERROR) {
BTConsole.WriteLine($"AchievementID: '{(int)data}' returned Error!");
return;
}
if (inEvent == WsServiceEvent.COMPLETE) {
if (inObject == null) {
BTConsole.WriteLine($"AchievementID: '{(int)data}' received no data!");
return;
}

BTConsole.WriteLine($"AchievementID: '{(int)data}' returned data:");
BTConsole.WriteLine(UtUtilities.SerializeToXml(inObject));
}
}, achievementID);
}
}

private static void OnExecuteDebugCommand3(BTConsoleCommand.BTCommandInput input) {
WsWebService.GetUserAchievements((inType, inEvent, progress, inObject, data) => {
if (inEvent != WsServiceEvent.COMPLETE) {
return;
}
ArrayOfUserAchievementInfo info = (ArrayOfUserAchievementInfo)inObject;
if (info == null) {
BTConsole.WriteLine("info was null!");
return;
}

BTConsole.WriteLine(UtUtilities.SerializeToXml(info));
}, null);
}

private static void OnExecuteDebugCommand4(BTConsoleCommand.BTCommandInput input) {
WorldEventScoutAttack[] eventManagers = Object.FindObjectsOfType<WorldEventScoutAttack>();
BTConsole.WriteLine($"Found {eventManagers.Length} instances.");
foreach (WorldEventScoutAttack worldEventScoutAttack in eventManagers) {
if (worldEventScoutAttack == null) {
BTConsole.WriteLine("instance was null!");
continue;
}

WorldEventManager.WorldEventAchievementRewardInfo[] rewardInfo = new Traverse(worldEventScoutAttack)
.Field("mCurrentRewardInfo")
.GetValue<WorldEventManager.WorldEventAchievementRewardInfo[]>();
if (rewardInfo == null) {
BTConsole.WriteLine("rewardInfo was null!");
continue;
}

BTConsole.WriteLine($" Found {rewardInfo.Length} rewardInfos");
foreach (WorldEventManager.WorldEventAchievementRewardInfo info in rewardInfo) {
if (info == null) {
BTConsole.WriteLine("info was null!");
continue;
}
BTConsole.WriteLine(
" "
+ "_RewardNameText = " + info._RewardNameText + " | "
+ "_RewardTier = " + info._RewardTier + " | "
+ "_AchievementID = " + info._AchievementID + " | "
+ "_AdRewardAchievementID = " + info._AdRewardAchievementID
);
}
BTConsole.WriteLine("-----");
}
}
}
Expand Down
Loading

0 comments on commit e44f2dd

Please sign in to comment.