ActionWithDelay class
Пакет: com.hypixel.hytale.server.npc.corecomponents
Файл: com/hypixel/hytale/server/npc/corecomponents/ActionWithDelay.java
extends: ActionBase
Поля (1)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
double[] |
delayRange |
Методы (7)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
protected |
void |
clearDelayvoid clearDelay() |
|
|
if if(!this.isDelaying) |
protected |
boolean |
isDelayPreparedboolean isDelayPrepared() |
protected |
boolean |
isDelayingboolean isDelaying() |
protected |
void |
prepareDelayvoid prepareDelay() |
protected |
void |
startDelayvoid startDelay(@Nonnull EntitySupport var1) |
abstract |
|
super super(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents;
class="kw">import com.hypixel.hytale.math.random.RandomExtra;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderActionWithDelay;
class="kw">import com.hypixel.hytale.server.npc.role.support.EntitySupport;
class="kw">import javax.annotation.Nonnull;
class="kw">public class="kw">abstract class ActionWithDelay class="kw">extends ActionBase {
class="kw">private class="kw">final double[] delayRange;
class="kw">private double delay;
class="kw">private boolean isDelaying;
class="kw">public ActionWithDelay(@Nonnull BuilderActionWithDelay var1, @Nonnull BuilderSupport var2) {
super(var1);
this.delayRange = var1.getDelayRange(var2);
}
@Override
class="kw">public boolean processDelay(float var1) {
if (!this.isDelaying) {
class="kw">return true;
}
if ((this.delay -= var1) <= 0.0) {
this.isDelaying = false;
}
class="kw">return !this.isDelaying;
}
@Override
class="kw">public boolean isBusy() {
class="kw">return this.isDelaying;
}
class="kw">protected boolean isDelaying() {
class="kw">return this.isDelaying;
}
class="kw">protected boolean isDelayPrepared() {
class="kw">return this.delay > 0.0;
}
class="kw">protected void prepareDelay() {
this.delay = RandomExtra.randomRange(this.delayRange);
this.isDelaying = false;
}
class="kw">protected void clearDelay() {
this.delay = 0.0;
this.isDelaying = false;
}
class="kw">protected void startDelay(@Nonnull EntitySupport var1) {
var1.registerDelay(this);
this.isDelaying = true;
}
}