Skip to content

Instantly share code, notes, and snippets.

@slippycheeze
Created December 6, 2022 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slippycheeze/4140fdcdeffced0c17fe712ac6d23837 to your computer and use it in GitHub Desktop.
Save slippycheeze/4140fdcdeffced0c17fe712ac6d23837 to your computer and use it in GitHub Desktop.
public class PrintUnlockableTechTrees: cmk.NMS.Script.QueryClass {
protected override void Execute() {
var Unlockable = Game.ExtractMbin<GcUnlockableTrees>("METADATA/REALITY/TABLES/UNLOCKABLEITEMTREES.MBIN");
foreach (var tree in Enum.GetValues<UnlockableItemTreeEnum>()) {
Log.AddHeading(Enum.GetName<UnlockableItemTreeEnum>(tree));
PrintTree(Unlockable.Trees[(int)tree]);
}
}
string Translate(string id) => Game.FindLanguageData(id)?.Text ?? id;
void PrintTree(GcUnlockableItemTrees tree) {
Log.AddInformation($"UnlockableItemTree: {Translate(tree.Title)} ({tree.Title})");
foreach (var branch in tree.Trees)
PrintTree(branch);
}
void PrintTree(GcUnlockableItemTree tree) {
Log.AddInformation($" {Translate(tree.Title)} cost={tree.CostTypeID} ({tree.Title})");
PrintTree(tree.Root);
}
void PrintTree(GcUnlockableItemTreeNode node, int depth = 2) {
Log.AddInformation(
new StringBuilder(80)
.Insert(0, " ", depth) // why this isn't part of Append I can't even
.Append(node.Unlockable)
.Append(" (")
.Append(Translate(node.Unlockable))
.Append(")")
.ToString()
);
foreach (var child in node.Children)
PrintTree(child, depth + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment