using System.Threading.Tasks;
using System.Windows.Controls;
using log4net;
using Loki.Common;
using Loki.Game;
namespace Loki.Bot.Logic.Plugins
{
public class WaitForESRecharge : IPlugin
{
private static readonly ILog Log = Logger.GetLoggerInstanceForType();
#region Implementation of IAuthored
/// <summary> The name of the plugin. </summary>
public string Name => "WaitForESRecharge";
/// <summary>The author of the plugin.</summary>
public string Author => "Bossland GmbH";
/// <summary> The description of the plugin. </summary>
public string Description => "A simple plugin that waits for ES to recharge after combat.";
/// <summary>The version of the plugin.</summary>
public string Version => "0.0.1.1";
#endregion
#region Implementation of IBase
/// <summary>Initializes this plugin.</summary>
public void Initialize()
{
Log.DebugFormat("[WaitForESRecharge] Initialize");
}
/// <summary>Deinitializes this object. This is called when the object is being unloaded from the bot.</summary>
public void Deinitialize()
{
Log.DebugFormat("[WaitForESRecharge] Deinitialize");
}
#endregion
#region Implementation of IRunnable
/// <summary> The plugin start callback. Do any initialization here. </summary>
public void Start()
{
Log.DebugFormat("[WaitForESRecharge] Start");
}
/// <summary> The plugin tick callback. Do any update logic here. </summary>
public void Tick()
{
}
/// <summary> The plugin stop callback. Do any pre-dispose cleanup here. </summary>
public void Stop()
{
Log.DebugFormat("[WaitForESRecharge] Stop");
}
#endregion
#region Implementation of IConfigurable
/// <summary>The settings object. This will be registered in the current configuration.</summary>
public JsonSettings Settings => null;
/// <summary> The plugin's settings control. This will be added to the Exilebuddy Settings tab.</summary>
public UserControl Control => null;
#endregion
#region Implementation of ILogic
/// <summary>
/// Coroutine logic to execute.
/// </summary>
/// <param name="type">The requested type of logic to execute.</param>
/// <param name="param">Data sent to the object from the caller.</param>
/// <returns>true if logic was executed to handle this type and false otherwise.</returns>
public async Task<bool> Logic(string type, params dynamic[] param)
{
// Only handle the "post_combat_hook" logic request.
if (type != "post_combat_hook")
return false;
// If we're less than 90% ES, just return true, which will block all other tasks running past combat from running.
// (except those that executed first before this hook)
if (LokiPoe.Me.EnergyShieldPercent < 90)
{
Log.InfoFormat("Now waiting for ES to recharge...");
return true;
}
return false;
}
/// <summary>
/// Non-coroutine logic to execute.
/// </summary>
/// <param name="name">The name of the logic to invoke.</param>
/// <param name="param">The data passed to the logic.</param>
/// <returns>Data from the executed logic.</returns>
public object Execute(string name, params dynamic[] param)
{
return null;
}
#endregion
#region Implementation of IEnableable
/// <summary> The plugin is being enabled.</summary>
public void Enable()
{
Log.DebugFormat("[WaitForESRecharge] Enable");
}
/// <summary> The plugin is being disabled.</summary>
public void Disable()
{
Log.DebugFormat("[WaitForESRecharge] Disable");
}
#endregion
#region Override of Object
/// <summary>Returns a string that represents the current object.</summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return Name + ": " + Description;
}
#endregion
}
}