StateTransitionEdges class
Пакет: com.hypixel.hytale.server.npc.statetransition.builders
Файл: com/hypixel/hytale/server/npc/statetransition/builders/BuilderStateTransitionEdges.java
Поля (3)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private final int[] |
fromStateIndices |
|
private final int |
priority |
|
private final int[] |
toStateIndices |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public int[] |
getFromStateIndicespublic int[] getFromStateIndices() |
|
public int |
getPrioritypublic int getPriority() |
|
public int[] |
getToStateIndicespublic int[] getToStateIndices() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.statetransition.builders;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.Builder;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderBase;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.holder.BooleanHolder;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.IntSingleValidator;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.StringArrayNoEmptyStringsValidator;
class="kw">import com.hypixel.hytale.server.npc.util.expression.ExecutionContext;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class BuilderStateTransitionEdges class="kw">extends BuilderBase<BuilderStateTransitionEdges.StateTransitionEdges> {
@Nullable
class="kw">protected String[] fromStates;
@Nullable
class="kw">protected String[] toStates;
class="kw">protected int[] fromStateIndices;
class="kw">protected int[] toStateIndices;
class="kw">protected int priority;
class="kw">protected class="kw">final BooleanHolder enabled = new BooleanHolder();
class="kw">protected BuilderStateTransitionEdges.StateTransitionEdges builtStateTransitionEdges;
class="kw">public BuilderStateTransitionEdges() {
}
@Nonnull
@Override
class="kw">public String getShortDescription() {
class="kw">return "Sets of from and to states defining state transitions";
}
@Nonnull
@Override
class="kw">public String getLongDescription() {
class="kw">return this.getShortDescription();
}
@Nonnull
class="kw">public BuilderStateTransitionEdges.StateTransitionEdges build(BuilderSupport var1) {
if (this.builtStateTransitionEdges == null) {
this.builtStateTransitionEdges = new BuilderStateTransitionEdges.StateTransitionEdges(this);
}
class="kw">return this.builtStateTransitionEdges;
}
@Nonnull
@Override
class="kw">public Class<BuilderStateTransitionEdges.StateTransitionEdges> category() {
class="kw">return BuilderStateTransitionEdges.StateTransitionEdges.class;
}
@Nonnull
@Override
class="kw">public BuilderDescriptorState getBuilderDescriptorState() {
class="kw">return BuilderDescriptorState.Stable;
}
@Override
class="kw">public boolean isEnabled(ExecutionContext var1) {
class="kw">return this.enabled.get(var1);
}
@Nonnull
@Override
class="kw">public Builder<BuilderStateTransitionEdges.StateTransitionEdges> readConfig(@Nonnull JsonElement var1) {
this.getInt(
var1,
"Priority",
var1x -> this.priority = var1x,
0,
IntSingleValidator.greaterEqual0(),
BuilderDescriptorState.Stable,
"Priority for the actions in this transition",
null
);
this.requireStringArray(
var1,
"From",
var1x -> this.fromStates = var1x,
null,
StringArrayNoEmptyStringsValidator.get(),
BuilderDescriptorState.Stable,
null,
"A set of from states"
);
this.requireStringArray(
var1, "To", var1x -> this.toStates = var1x, null, StringArrayNoEmptyStringsValidator.get(), BuilderDescriptorState.Stable, null, "A set of to states"
);
this.getBoolean(var1, "Enabled", this.enabled, true, BuilderDescriptorState.Stable, "Whether this sensor should be enabled on the NPC", null);
if (this.fromStates != null && this.toStates != null) {
for (String var5 : this.fromStates) {
for (String var9 : this.toStates) {
if (var5.equals(var9)) {
this.addError(new IllegalStateException("State transition edge cannot be defined from a state to itself: " + var5));
}
}
}
}
if (this.fromStates != null && this.fromStates.length > 0) {
this.fromStateIndices = new int[this.fromStates.length];
int[] var10 = new int[]{0};
for (String var18 : this.fromStates) {
this.registerStateRequirer(var18, null, (var2, var3) -> this.fromStateIndices[var10[0]++] = var2);
}
this.fromStates = null;
}
if (this.toStates != null && this.toStates.length > 0) {
this.toStateIndices = new int[this.toStates.length];
int[] var11 = new int[]{0};
for (String var19 : this.toStates) {
this.registerStateRequirer(var19, null, (var2, var3) -> this.toStateIndices[var11[0]++] = var2);
}
this.toStates = null;
}
class="kw">return this;
}
class="kw">public class="kw">static class StateTransitionEdges {
class="kw">private class="kw">final int priority;
class="kw">private class="kw">final int[] fromStateIndices;
class="kw">private class="kw">final int[] toStateIndices;
class="kw">private StateTransitionEdges(@Nonnull BuilderStateTransitionEdges var1) {
this.priority = var1.priority;
this.fromStateIndices = var1.fromStateIndices;
this.toStateIndices = var1.toStateIndices;
}
class="kw">public int getPriority() {
class="kw">return this.priority;
}
class="kw">public int[] getFromStateIndices() {
class="kw">return this.fromStateIndices;
}
class="kw">public int[] getToStateIndices() {
class="kw">return this.toStateIndices;
}
}
}