v1.2.1: fixed autotargeting not working with right click menus

This commit is contained in:
Evan Debenham 2022-03-28 22:12:59 -04:00
parent e8d33abb73
commit 1a4378d1b7
2 changed files with 8 additions and 1 deletions

View File

@ -372,7 +372,9 @@ public class InventoryPane extends Component {
}
public static void useTargeting(){
if (lastTarget != null &&
if (instance != null &&
instance.visible &&
lastTarget != null &&
Actor.chars().contains( lastTarget ) &&
lastTarget.isAlive() &&
lastTarget.alignment != Char.Alignment.ALLY &&
@ -531,6 +533,7 @@ public class InventoryPane extends Component {
}
if (selector == null){
targetingSlot = this;
RightClickMenu r = new RightClickMenu(item);
parent.addToFront(r);
r.camera = camera();

View File

@ -104,6 +104,10 @@ public class RightClickMenu extends Component {
super.onClick();
if (item != null){
item.execute(Dungeon.hero, options[finalI]);
if (options[finalI].equals(item.defaultAction) && item.usesTargeting){
InventoryPane.useTargeting();
}
}
onSelect(finalI);
RightClickMenu.this.destroy();