init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using VOID.Generic.Player.Util;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public abstract class AbstractCursorOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="Type"/> for which this operation will work.
|
||||
/// </summary>
|
||||
public abstract Type ForType();
|
||||
|
||||
/// <summary>
|
||||
/// Returns TRUE if this operation can be executed.
|
||||
/// </summary>
|
||||
/// <param name="select">Complex information what was selected for this operation</param>
|
||||
public abstract bool Check(SelectUtilResult select);
|
||||
|
||||
/// <summary>
|
||||
/// Instantly executes default logic. Usually, by ordering currently active unit to do something.<br/>
|
||||
/// <b>On Scene:</b> single tap, no alternate available (for now)<br/>
|
||||
/// <b>On UI:</b> double tap, single tap is alternate usage<br/>
|
||||
/// </summary>
|
||||
/// <param name="select">Complex information what was selected for this operation</param>
|
||||
/// <param name="isAlternate">If operation should execute alternate logic</param>
|
||||
public abstract void DoDefault(SelectUtilResult select, bool isAlternate);
|
||||
|
||||
/// <summary>
|
||||
/// Open context menu with all available action to choose for selected target.
|
||||
/// </summary>
|
||||
/// <param name="select">Complex information what was selected for this operation</param>
|
||||
public abstract void DoContext(SelectUtilResult select);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09d69b0d1ba94919b6ddac0633be5570
|
||||
timeCreated: 1698607084
|
||||
@@ -0,0 +1,44 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11b181e8bf9a4089ba6d589728acb167
|
||||
timeCreated: 1698690680
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using VOID.Generic.Objects.Container;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnContainerCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => typeof(ContainerObject);
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return select.selectObject is ContainerObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
if (isAlternate) return;
|
||||
|
||||
var container = (ContainerObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
activeUnit.OrderStop();
|
||||
if (activeUnit.unitData.canAttack && PlayerInputManager.current.isForceAttack)
|
||||
{
|
||||
// Player forced attack action
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default operation is OPEN (+ move closer if needed)
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new OpenContainerAction(activeUnit, container));
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
var container = (ContainerObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
var carrier = container.itemState.carriedBy;
|
||||
|
||||
ContextMenuUI.current.Prepare();
|
||||
|
||||
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
||||
|
||||
ContextMenuUI.current.AddOption("Open", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new OpenContainerAction(activeUnit, container));
|
||||
});
|
||||
if (!select.onUI)
|
||||
{
|
||||
if (activeUnit.unitData.canMove)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Move", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canAttack)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Attack", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
});
|
||||
}
|
||||
}
|
||||
if (activeUnit.unitData.canTake && container.itemData.canBePicked && container.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Take", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, container));
|
||||
});
|
||||
}
|
||||
if (carrier == activeUnit)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Drop", () =>
|
||||
{
|
||||
activeUnit.Order(new DropAction(activeUnit, container));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canInspect && container.basicData.canBeInspected)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Inspect", () =>
|
||||
{
|
||||
MoveAction moveAction = new MoveAction(activeUnit, select.position, activeUnit.unitData.inspectRange);
|
||||
moveAction.OnEnd += () => activeUnit.OrderInstantly(new InspectAction(activeUnit, container));
|
||||
activeUnit.Order(moveAction);
|
||||
});
|
||||
}
|
||||
ContextMenuUI.current.Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fba87a0905344721baf1a917b4171f56
|
||||
timeCreated: 1698610850
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using VOID.Generic.Objects.Door;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnDoorCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => typeof(DoorObject);
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return select.selectObject is DoorObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
if (isAlternate) return;
|
||||
|
||||
var door = (DoorObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
activeUnit.OrderStop();
|
||||
if (activeUnit.unitData.canAttack && PlayerInputManager.current.isForceAttack)
|
||||
{
|
||||
// Player forced attack action
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
}
|
||||
else if (activeUnit.unitData.canUse)
|
||||
{
|
||||
// Default operation is USE (+ move closer if needed)
|
||||
activeUnit.Order(new MoveAction(activeUnit, door, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new UseAction(activeUnit, door));
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
var door = (DoorObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
ContextMenuUI.current.Prepare();
|
||||
|
||||
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
||||
if (activeUnit.unitData.canMove)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Move", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canAttack)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Attack", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canUse)
|
||||
{
|
||||
ContextMenuUI.current.AddOption(door.doorState.isOpen ? "Close" : "Open", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, door, activeUnit.unitData.useRange));
|
||||
activeUnit.Order(new UseAction(activeUnit, door));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canInspect && door.basicData.canBeInspected)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Inspect", () =>
|
||||
{
|
||||
MoveAction moveAction = new MoveAction(activeUnit, door, activeUnit.unitData.inspectRange);
|
||||
moveAction.OnEnd += () => activeUnit.OrderInstantly(new InspectAction(activeUnit, door));
|
||||
activeUnit.Order(moveAction);
|
||||
});
|
||||
}
|
||||
ContextMenuUI.current.Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1c09919cc7a4d7ea117cd07aa0e1db0
|
||||
timeCreated: 1707863006
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using VOID.Generic.Objects.Item;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnItemCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => typeof(ItemObject);
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return select.selectObject is ItemObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
if (isAlternate) return;
|
||||
|
||||
var item = (ItemObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var carrier = item.itemState.carriedBy;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
activeUnit.OrderStop();
|
||||
if (activeUnit.unitData.canAttack && PlayerInputManager.current.isForceAttack)
|
||||
{
|
||||
// Player forced attack action
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
}
|
||||
else if (activeUnit.unitData.canTake && item.itemData.canBePicked && item.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
// Default operation is TAKE (+ move closer if needed)
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, item));
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
var item = (ItemObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var carrier = item.itemState.carriedBy;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
ContextMenuUI.current.Prepare();
|
||||
|
||||
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
||||
|
||||
if (!select.onUI)
|
||||
{
|
||||
if (activeUnit.unitData.canMove)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Move", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canAttack)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Attack", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
});
|
||||
}
|
||||
}
|
||||
if (activeUnit.unitData.canTake && item.itemData.canBePicked && item.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Take", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, item));
|
||||
});
|
||||
}
|
||||
if (carrier == activeUnit)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Drop", () =>
|
||||
{
|
||||
activeUnit.Order(new DropAction(activeUnit, item));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canInspect && item.basicData.canBeInspected)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Inspect", () =>
|
||||
{
|
||||
MoveAction moveAction = new MoveAction(activeUnit, select.position, activeUnit.unitData.inspectRange);
|
||||
moveAction.OnEnd += () => activeUnit.OrderInstantly(new InspectAction(activeUnit, item));
|
||||
activeUnit.Order(moveAction);
|
||||
});
|
||||
}
|
||||
ContextMenuUI.current.Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5a8f39823274658831f598ba0e710aa
|
||||
timeCreated: 1698610993
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnSceneCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => null;
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return !select.onUI && !select.selectObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
if (isAlternate) return;
|
||||
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
if (activeUnit.unitData.canAttack && PlayerInputManager.current.isForceAttack)
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
return;
|
||||
}
|
||||
|
||||
activeUnit.OrderStop();
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position));
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
ContextMenuUI.current.Close();
|
||||
PlayerController.current.activeUnit.OrderStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 450710b09445433cab3979fd013bc333
|
||||
timeCreated: 1698608270
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Unit;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
using VOID.Generic.Util;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnUnitCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => typeof(UnitObject);
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return select.selectObject is UnitObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
var onPartyUI = select.partyUI != null;
|
||||
var onPortraitUI = select.unitPortraitUI != null;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
var targetUnit = (UnitObject)select.selectObject;
|
||||
var attitude = activeUnit.unitAttitude.GetAttitudeWith(targetUnit);
|
||||
|
||||
if (isAlternate && onPortraitUI && onPartyUI && targetUnit == PlayerController.current.activeUnit)
|
||||
{
|
||||
CameraManager.current.MoveTo(targetUnit.transform.position);
|
||||
}
|
||||
else if (isAlternate && onPortraitUI && onPartyUI && targetUnit == PlayerController.current.mainUnit)
|
||||
{
|
||||
PlayerController.current.SetMainUnitActive();
|
||||
}
|
||||
else if (isAlternate && onPortraitUI && onPartyUI && targetUnit == PlayerController.current.subUnit)
|
||||
{
|
||||
PlayerController.current.SetSubUnitActive();
|
||||
}
|
||||
else if (isAlternate && onPortraitUI)
|
||||
{
|
||||
CameraManager.current.MoveTo(targetUnit.transform.position);
|
||||
}
|
||||
else if (!isAlternate && onPortraitUI)
|
||||
{
|
||||
CameraManager.current.stickTo = targetUnit.transform;
|
||||
}
|
||||
|
||||
// No action to order when clicking portraits
|
||||
if (onPortraitUI) return;
|
||||
|
||||
activeUnit.OrderStop();
|
||||
|
||||
if (targetUnit.basicState.isDead)
|
||||
{
|
||||
// Open - when other unit is dead, we open him like container
|
||||
activeUnit.Order(new MoveAction(activeUnit, targetUnit, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new OpenOtherUnitAction(activeUnit, targetUnit));
|
||||
}
|
||||
else if (activeUnit.unitData.canAttack && (PlayerInputManager.current.isForceAttack || attitude <= AttitudeType.Cautious))
|
||||
{
|
||||
// Attack - when this unit can Attack AND forced attack OR target unit is hostile/cautious
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Talk - when this unit can Talk AND target unit is neutral/friendly
|
||||
activeUnit.Order(new MoveAction(activeUnit, targetUnit, activeUnit.unitData.talkRange));
|
||||
if (activeUnit.unitData.canTalk && targetUnit.unitData.canBeTalked) activeUnit.Order(new TalkAction(activeUnit, targetUnit));
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
var targetUnit = (UnitObject)select.selectObject;
|
||||
var attitude = activeUnit.unitAttitude.GetAttitudeWith(targetUnit);
|
||||
|
||||
if (targetUnit == activeUnit && select.onUI) return;
|
||||
|
||||
ContextMenuUI.current.Prepare();
|
||||
|
||||
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
||||
|
||||
if (activeUnit.unitData.canMove)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Move",
|
||||
() => activeUnit.Order(new MoveAction(activeUnit, select.position)));
|
||||
}
|
||||
if (targetUnit.basicState.isDead)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Loot", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, targetUnit, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new OpenOtherUnitAction(activeUnit, targetUnit));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canAttack)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Attack", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
});
|
||||
}
|
||||
if (attitude >= AttitudeType.Neutral && activeUnit.unitData.canTalk && targetUnit.unitData.canBeTalked)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Talk", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TalkAction(activeUnit, targetUnit));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canInspect && targetUnit.basicData.canBeInspected)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Inspect", () =>
|
||||
{
|
||||
MoveAction moveAction = new MoveAction(activeUnit, select.position, activeUnit.unitData.inspectRange);
|
||||
moveAction.OnEnd += () => activeUnit.OrderInstantly(new InspectAction(activeUnit, targetUnit));
|
||||
activeUnit.Order(moveAction);
|
||||
});
|
||||
}
|
||||
ContextMenuUI.current.Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dd2501221e74d348fbfe05dd5602955
|
||||
timeCreated: 1698610483
|
||||
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Objects.Usable;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnUsableCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => typeof(UsableObject);
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return select.selectObject is UsableObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
if (isAlternate) return;
|
||||
|
||||
var usable = (UsableObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var carrier = usable.itemState.carriedBy;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
activeUnit.OrderStop();
|
||||
if (activeUnit.unitData.canAttack && PlayerInputManager.current.isForceAttack)
|
||||
{
|
||||
// Player forced attack action
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
}
|
||||
else if (activeUnit.unitData.canTake && usable.itemData.canBePicked && usable.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
// Default operation is TAKE (+ move closer if needed)
|
||||
activeUnit.Order(new MoveAction(activeUnit, usable.transform.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, usable));
|
||||
}
|
||||
else if(activeUnit.unitData.canUse)
|
||||
{
|
||||
// If can't be taken then... USE (+ move closer if needed)
|
||||
activeUnit.Order(new MoveAction(activeUnit, usable.transform.position, activeUnit.unitData.useRange));
|
||||
activeUnit.Order(new UseAction(activeUnit, usable));
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
var usable = (UsableObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
var carrier = usable.itemState.carriedBy;
|
||||
|
||||
ContextMenuUI.current.Prepare();
|
||||
|
||||
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
||||
if (activeUnit.unitData.canUse)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Use", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, usable.transform.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new UseAction(activeUnit, usable));
|
||||
});
|
||||
}
|
||||
if (!select.onUI)
|
||||
{
|
||||
if (activeUnit.unitData.canMove)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Move", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, usable.transform.position));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canAttack)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Attack", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (activeUnit.unitData.canTake && usable.itemData.canBePicked && usable.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Take", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, usable.transform.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, usable));
|
||||
});
|
||||
}
|
||||
|
||||
if (carrier == activeUnit)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Drop", () =>
|
||||
{
|
||||
activeUnit.Order(new DropAction(activeUnit, usable));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canInspect && usable.basicData.canBeInspected)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Inspect", () =>
|
||||
{
|
||||
MoveAction moveAction = new MoveAction(activeUnit, usable.transform.position, activeUnit.unitData.inspectRange);
|
||||
moveAction.OnEnd += () => activeUnit.OrderInstantly(new InspectAction(activeUnit, usable));
|
||||
activeUnit.Order(moveAction);
|
||||
});
|
||||
}
|
||||
ContextMenuUI.current.Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9236a03e16a438aa090d6c823601dd1
|
||||
timeCreated: 1698613067
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using VOID.Generic.Objects.Unit.Actions;
|
||||
using VOID.Generic.Objects.Wearable;
|
||||
using VOID.Generic.Player.Input;
|
||||
using VOID.Generic.Player.Util;
|
||||
using VOID.UserInterface.Game;
|
||||
|
||||
namespace VOID.Generic.Player.CursorOperation
|
||||
{
|
||||
public class OnWearableCursorOperation : AbstractCursorOperation
|
||||
{
|
||||
public override Type ForType() => typeof(WearableObject);
|
||||
|
||||
public override bool Check(SelectUtilResult select)
|
||||
{
|
||||
return select.selectObject is WearableObject;
|
||||
}
|
||||
|
||||
public override void DoDefault(SelectUtilResult select, bool isAlternate)
|
||||
{
|
||||
if (isAlternate) return;
|
||||
|
||||
var wearable = (WearableObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var carrier = wearable.itemState.carriedBy;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
|
||||
activeUnit.OrderStop();
|
||||
if (activeUnit.unitData.canAttack && PlayerInputManager.current.isForceAttack)
|
||||
{
|
||||
// Player forced attack action
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
}
|
||||
else if (activeUnit.unitData.canTake && wearable.itemData.canBePicked && wearable.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
// Default operaion is Take
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, wearable));
|
||||
}
|
||||
else if (wearable.wearableState.wearerUnit == activeUnit)
|
||||
{
|
||||
// Try UNEQUIP (if currently wearing)
|
||||
activeUnit.Order(new UnEquipAction(activeUnit, wearable));
|
||||
}
|
||||
else if (wearable.itemState.carriedBy == activeUnit)
|
||||
{
|
||||
// Try EQUIP (if in backpack)
|
||||
activeUnit.Order(new EquipAction(activeUnit, wearable));
|
||||
}
|
||||
}
|
||||
|
||||
public override void DoContext(SelectUtilResult select)
|
||||
{
|
||||
var wearable = (WearableObject)select.selectObject;
|
||||
var activeUnit = PlayerController.current.activeUnit;
|
||||
var attackAbility = activeUnit.unitAbilityBook.attackAbility;
|
||||
var carrier = wearable.itemState.carriedBy;
|
||||
var wearer = wearable.wearableState.wearerUnit;
|
||||
|
||||
ContextMenuUI.current.Prepare();
|
||||
|
||||
ContextMenuUI.current.AddBeforeClick(() => activeUnit.OrderStop());
|
||||
|
||||
if (!select.onUI)
|
||||
{
|
||||
if (activeUnit.unitData.canMove)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Move", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canAttack)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Attack", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, attackAbility.range));
|
||||
activeUnit.Order(new AbilityAction(activeUnit, attackAbility, select.position));
|
||||
});
|
||||
}
|
||||
}
|
||||
if ((carrier == null) && wearer == null && activeUnit.unitData.canTake && wearable.itemData.canBePicked && wearable.itemData.canBeMoved)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Equip", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, wearable));
|
||||
activeUnit.Order(new EquipAction(activeUnit, wearable));
|
||||
});
|
||||
}
|
||||
if ((carrier == activeUnit) && wearer == null)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Equip", () =>
|
||||
{
|
||||
activeUnit.Order(new EquipAction(activeUnit, wearable));
|
||||
});
|
||||
}
|
||||
if (carrier == activeUnit && wearer == activeUnit)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("UnEquip", () =>
|
||||
{
|
||||
activeUnit.Order(new UnEquipAction(activeUnit, wearable));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canTake && wearable.itemData.canBePicked && wearable.itemData.canBeMoved && (carrier == null || carrier.basicState.isDead))
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Take", () =>
|
||||
{
|
||||
activeUnit.Order(new MoveAction(activeUnit, select.position, activeUnit.unitData.takeRange));
|
||||
activeUnit.Order(new TakeAction(activeUnit, wearable));
|
||||
});
|
||||
}
|
||||
if (carrier == activeUnit)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Drop", () =>
|
||||
{
|
||||
activeUnit.Order(new DropAction(activeUnit, wearable));
|
||||
});
|
||||
}
|
||||
if (activeUnit.unitData.canInspect && wearable.basicData.canBeInspected)
|
||||
{
|
||||
ContextMenuUI.current.AddOption("Inspect", () =>
|
||||
{
|
||||
MoveAction moveAction = new MoveAction(activeUnit, select.position, activeUnit.unitData.inspectRange);
|
||||
moveAction.OnEnd += () => activeUnit.OrderInstantly(new InspectAction(activeUnit, wearable));
|
||||
activeUnit.Order(moveAction);
|
||||
});
|
||||
}
|
||||
ContextMenuUI.current.Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e42674a58344cadbef2fad57aa3de17
|
||||
timeCreated: 1698611491
|
||||
Reference in New Issue
Block a user