44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System;
|
|
using VOID.Generic.Objects.Unit.Actions;
|
|
using VOID.Generic.Player.Util;
|
|
using VOID.UserInterface.Game;
|
|
using VOID.ScriptableObjects.Abilities;
|
|
|
|
namespace VOID.Generic.Player.CursorOperation
|
|
{
|
|
public class OnAbilityCursorOperation : AbstractCursorOperation
|
|
{
|
|
public override Type ForType() => typeof(BasicAbility);
|
|
|
|
public override bool Check(SelectUtilResult select)
|
|
{
|
|
return select.selectAbility;
|
|
}
|
|
|
|
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
|
{
|
|
if (isAlternate) return;
|
|
|
|
var selectAbility = select.selectAbility;
|
|
var activeUnit = PlayerController.current.activeUnit;
|
|
|
|
activeUnit.OrderStop();
|
|
activeUnit.Order(new CastingAction(activeUnit, selectAbility));
|
|
}
|
|
|
|
public override void DoContext(SelectUtilResult select)
|
|
{
|
|
var activeUnit = PlayerController.current.activeUnit;
|
|
|
|
ContextMenuUI.current.Prepare();
|
|
|
|
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
|
|
|
ContextMenuUI.current.AddOption("Use Ability", () =>
|
|
{
|
|
activeUnit.Order(new CastingAction(activeUnit, select.selectAbility));
|
|
});
|
|
ContextMenuUI.current.Open();
|
|
}
|
|
}
|
|
} |