punish v6.8.18.0
This commit is contained in:
commit
060278c1b7
317 changed files with 554155 additions and 0 deletions
150
Questionable/Questionable.External/BossModIpc.cs
Normal file
150
Questionable/Questionable.External/BossModIpc.cs
Normal file
|
@ -0,0 +1,150 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Plugin.Ipc.Exceptions;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Questionable.Data;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.External;
|
||||
|
||||
internal sealed class BossModIpc
|
||||
{
|
||||
public enum EPreset
|
||||
{
|
||||
Overworld,
|
||||
QuestBattle
|
||||
}
|
||||
|
||||
private sealed class PresetDefinition
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public string Content { get; }
|
||||
|
||||
public PresetDefinition(string name, string fileName)
|
||||
{
|
||||
Name = name;
|
||||
Content = LoadPreset(fileName);
|
||||
base._002Ector();
|
||||
}
|
||||
|
||||
private static string LoadPreset(string name)
|
||||
{
|
||||
using StreamReader streamReader = new StreamReader(typeof(BossModIpc).Assembly.GetManifestResourceStream("Questionable.Controller.CombatModules.BossModPreset." + name) ?? throw new InvalidOperationException("Preset " + name + " was not found"));
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private const string PluginName = "BossMod";
|
||||
|
||||
private static readonly ReadOnlyDictionary<EPreset, PresetDefinition> PresetDefinitions = new Dictionary<EPreset, PresetDefinition>
|
||||
{
|
||||
{
|
||||
EPreset.Overworld,
|
||||
new PresetDefinition("Questionable", "Overworld")
|
||||
},
|
||||
{
|
||||
EPreset.QuestBattle,
|
||||
new PresetDefinition("Questionable - Quest Battles", "QuestBattle")
|
||||
}
|
||||
}.AsReadOnly();
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
private readonly ICommandManager _commandManager;
|
||||
|
||||
private readonly TerritoryData _territoryData;
|
||||
|
||||
private readonly ICallGateSubscriber<string, string?> _getPreset;
|
||||
|
||||
private readonly ICallGateSubscriber<string, bool, bool> _createPreset;
|
||||
|
||||
private readonly ICallGateSubscriber<string, bool> _setPreset;
|
||||
|
||||
private readonly ICallGateSubscriber<bool> _clearPreset;
|
||||
|
||||
public BossModIpc(IDalamudPluginInterface pluginInterface, Configuration configuration, ICommandManager commandManager, TerritoryData territoryData)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_commandManager = commandManager;
|
||||
_territoryData = territoryData;
|
||||
_getPreset = pluginInterface.GetIpcSubscriber<string, string>("BossMod.Presets.Get");
|
||||
_createPreset = pluginInterface.GetIpcSubscriber<string, bool, bool>("BossMod.Presets.Create");
|
||||
_setPreset = pluginInterface.GetIpcSubscriber<string, bool>("BossMod.Presets.SetActive");
|
||||
_clearPreset = pluginInterface.GetIpcSubscriber<bool>("BossMod.Presets.ClearActive");
|
||||
}
|
||||
|
||||
public bool IsSupported()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _getPreset.HasFunction;
|
||||
}
|
||||
catch (IpcError)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPreset(EPreset preset)
|
||||
{
|
||||
PresetDefinition presetDefinition = PresetDefinitions[preset];
|
||||
if (_getPreset.InvokeFunc(presetDefinition.Name) == null)
|
||||
{
|
||||
_createPreset.InvokeFunc(presetDefinition.Content, arg2: true);
|
||||
}
|
||||
_setPreset.InvokeFunc(presetDefinition.Name);
|
||||
}
|
||||
|
||||
public void ClearPreset()
|
||||
{
|
||||
_clearPreset.InvokeFunc();
|
||||
}
|
||||
|
||||
public void EnableAi(bool passive)
|
||||
{
|
||||
_commandManager.ProcessCommand("/vbmai on");
|
||||
_commandManager.ProcessCommand("/vbm cfg ZoneModuleConfig EnableQuestBattles true");
|
||||
SetPreset((!passive) ? EPreset.QuestBattle : EPreset.Overworld);
|
||||
}
|
||||
|
||||
public void DisableAi()
|
||||
{
|
||||
_commandManager.ProcessCommand("/vbmai off");
|
||||
_commandManager.ProcessCommand("/vbm cfg ZoneModuleConfig EnableQuestBattles false");
|
||||
ClearPreset();
|
||||
}
|
||||
|
||||
public bool IsConfiguredToRunSoloInstance(ElementId questId, SinglePlayerDutyOptions? dutyOptions)
|
||||
{
|
||||
if (!IsSupported())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!_configuration.SinglePlayerDuties.RunSoloInstancesWithBossMod)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (dutyOptions == null)
|
||||
{
|
||||
dutyOptions = new SinglePlayerDutyOptions();
|
||||
}
|
||||
if (!_territoryData.TryGetContentFinderConditionForSoloInstance(questId, dutyOptions.Index, out TerritoryData.ContentFinderConditionData contentFinderConditionData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_configuration.SinglePlayerDuties.BlacklistedSinglePlayerDutyCfcIds.Contains(contentFinderConditionData.ContentFinderConditionId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_configuration.SinglePlayerDuties.WhitelistedSinglePlayerDutyCfcIds.Contains(contentFinderConditionData.ContentFinderConditionId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return dutyOptions.Enabled;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue