56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using InnerSpaceAPI;
|
|
using LavishVMAPI;
|
|
using MRBot.IsxEq2;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace MRBot.Bot.AbilityExporter
|
|
{
|
|
internal class AbilityExporter
|
|
{
|
|
public void ExportAbilities()
|
|
{
|
|
var abilities = new AbilityList();
|
|
for (var idx = 1; idx <= Extension.Me.NumAbilities; idx++)
|
|
{
|
|
InnerSpace.Echo($"Exporting Ability {idx} of {Extension.Me.NumAbilities}");
|
|
|
|
var count = 0;
|
|
ExportableAbility exportableExportableAbility;
|
|
using (new FrameLock(true))
|
|
{
|
|
var ability = Extension.Me.Ability(idx);
|
|
while (!ability.IsAbilityInfoAvailable && count < 10)
|
|
{
|
|
Frame.Wait(false);
|
|
count++;
|
|
}
|
|
|
|
if (count >= 10)
|
|
{
|
|
InnerSpace.Echo($"Ability {idx} info never became available");
|
|
continue;
|
|
}
|
|
exportableExportableAbility = new ExportableAbility(ability);
|
|
}
|
|
|
|
abilities.AddAbility(exportableExportableAbility);
|
|
}
|
|
|
|
var path = Path.Combine(
|
|
InnerSpace.Path,
|
|
"scripts",
|
|
"mr",
|
|
"bot",
|
|
"ability_exports",
|
|
$"{Extension.Me.Name}_{Extension.Me.SubClass}.json");
|
|
using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
|
|
using (var writer = new StreamWriter(fileStream))
|
|
{
|
|
writer.Write(JsonConvert.SerializeObject(abilities));
|
|
}
|
|
}
|
|
}
|
|
} |