mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 10:47:30 +00:00
a buncha IAction adjustments
This commit is contained in:
1 parent
44d76b638d
commit
7786d8e271
6 files changed
+34
-17
No files matched your search
@@ -140,6 +140,18 @@ public class Action implements IAction {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction everyTick() {
|
||||
this.updateEveryXTick = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction everySecond() {
|
||||
this.updateEveryXTick = 20;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return count;
|
||||
|
||||
@@ -27,9 +27,9 @@ public class ActionManager implements IActionManager {
|
||||
protected final ActionQueue sequentialQueue = new ActionQueue(this, "mainSequential");
|
||||
protected final ActionQueue parallelQueue = new ActionQueue(this, "mainParallel", true);
|
||||
protected final ActionQueue conditionalQueue = new ActionQueue(this, "mainConditional", true);
|
||||
|
||||
protected final Map<String, IActionQueue> otherQueues = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public IActionManager start() {
|
||||
isWorking = true;
|
||||
@@ -145,6 +145,11 @@ public class ActionManager implements IActionManager {
|
||||
return otherQueues.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasQueue(String name) {
|
||||
return otherQueues.containsKey(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeQueue(String name) {
|
||||
IActionQueue queue = otherQueues.get(name);
|
||||
@@ -394,7 +399,7 @@ public class ActionManager implements IActionManager {
|
||||
IActionQueue other = it.next();
|
||||
((ActionQueue) other).tick();
|
||||
|
||||
if (other.isKilled()) {
|
||||
if (other.isDead()) {
|
||||
other.clear();
|
||||
it.remove();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ public class ActionQueue implements IActionQueue {
|
||||
protected boolean isWorking = true;
|
||||
protected boolean isParallel;
|
||||
|
||||
protected boolean kill;
|
||||
protected boolean isDead;
|
||||
protected boolean killWhenEmpty;
|
||||
protected int killWhenEmptyAfter = 100;
|
||||
|
||||
private Action autoKill;
|
||||
protected Action autoKill;
|
||||
|
||||
public ActionQueue(ActionManager manager, String name) {
|
||||
this.manager = manager;
|
||||
@@ -93,13 +93,13 @@ public class ActionQueue implements IActionQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKilled() {
|
||||
return kill;
|
||||
public boolean isDead() {
|
||||
return isDead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IActionQueue kill() {
|
||||
this.kill = true;
|
||||
this.isDead = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ public class ActionQueue implements IActionQueue {
|
||||
// Handling
|
||||
|
||||
protected void tick() {
|
||||
if (!isWorking)
|
||||
if (!isWorking || isDead)
|
||||
return;
|
||||
|
||||
if (!isParallel) {
|
||||
@@ -299,7 +299,7 @@ public class ActionQueue implements IActionQueue {
|
||||
return;
|
||||
|
||||
manager.removeQueue(name);
|
||||
}).updateEvery(1).once();
|
||||
}).everyTick().once();
|
||||
|
||||
if (autoKill != null) {
|
||||
autoKill.tick();
|
||||
|
||||
@@ -11,12 +11,12 @@ import java.util.function.Function;
|
||||
|
||||
|
||||
public class ConditionalAction extends Action implements IConditionalAction {
|
||||
private Function<IAction, Boolean> condition;
|
||||
private Function<IAction, Boolean> terminateWhen;
|
||||
private Consumer<IAction> onTermination;
|
||||
private int maxChecks = -1;
|
||||
private int checkCount;
|
||||
private boolean taskExecuted;
|
||||
protected Function<IAction, Boolean> condition;
|
||||
protected Function<IAction, Boolean> terminateWhen;
|
||||
protected Consumer<IAction> onTermination;
|
||||
protected int maxChecks = -1;
|
||||
protected int checkCount;
|
||||
protected boolean taskExecuted;
|
||||
|
||||
public ConditionalAction(ActionManager manager, Function<IAction, Boolean> condition, Consumer<IAction> task) {
|
||||
super(manager, task);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ActionChain implements IActionChain {
|
||||
@Override
|
||||
public IActionChain after(int delay, String name, Consumer<IAction> task) {
|
||||
offset = queue.isParallel() ? offset + delay : delay;
|
||||
queue.schedule(name, offset, task).updateEvery(1).once();
|
||||
queue.schedule(name, offset, task).everyTick().once();
|
||||
index++;
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user