AudioState class
Пакет: com.hypixel.hytale.server.core.asset.type.audiostate.config
Файл: com/hypixel/hytale/server/core/asset/type/audiostate/config/AudioState.java
implements: JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, AudioState>>,
NetworkSerializable<com.hypixel.hytale.protocol.AudioState>
Поля (10)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
ASSET_STORE |
final |
int |
EMPTY_ID |
|
int |
var1 |
|
com.hypixel.hytale.protocol.AudioState |
var1 |
|
HashSet |
var2 |
|
com.hypixel.hytale.protocol.AudioState |
var2 |
|
int |
var3 |
|
StateTransition[] |
var3 |
|
int |
var4 |
|
StateTransitionConfig |
var8 |
Методы (22)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
for for(String var6 : var0.values) |
|
|
for for(StateTransitionConfig var11 : var0.transitions) |
|
|
for for(int var4 = 0; var4 < this.transitions.length; var4++) |
static |
IndexedLookupTableAssetMap<String, AudioState> |
getAssetMapIndexedLookupTableAssetMap<String, AudioState> getAssetMap() |
static |
AssetStore<String, AudioState, IndexedLookupTableAssetMap<String, AudioState>> |
getAssetStoreAssetStore<String, AudioState, IndexedLookupTableAssetMap<String, AudioState>> getAssetStore() |
public |
int |
getDefaultValueIndexint getDefaultValueIndex() |
public |
String |
getIdString getId() |
|
|
if if(var0.values != null) |
|
|
if if(var0.transitions != null) |
|
|
if if(var0.defaultTransition != null) |
|
|
if if(var0.revertWhenInactive && var0.authority != AudioStateAuthority.Client) |
|
|
if if(var3 == -2) |
|
|
if if(var4 == -2) |
|
|
if if(ASSET_STORE == null) |
|
|
if if(this.defaultValue == null) |
|
|
if if(var1 != null) |
|
|
if if(this.transitions != null) |
|
|
if if(var1.fromValueIndex == -2) |
|
|
if if(var1.toValueIndex == -2) |
private |
StateTransition |
resolveAndToPacketStateTransition resolveAndToPacket(@Nonnull StateTransitionConfig var1) |
static |
void |
validateTransitionvoid validateTransition(@Nonnull AudioState var0, @Nonnull StateTransitionConfig var1, @Nonnull ValidationResults var2) |
abstract |
|
validateTransition validateTransition(var0, var11, var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.audiostate.config;
class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetKeyValidator;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.assetstore.AssetStore;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.validation.ValidationResults;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.protocol.AudioStateAuthority;
class="kw">import com.hypixel.hytale.protocol.StateTransition;
class="kw">import com.hypixel.hytale.protocol.SyncPoint;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import java.lang.ref.SoftReference;
class="kw">import java.util.HashSet;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class AudioState
class="kw">implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, AudioState>>,
NetworkSerializable<com.hypixel.hytale.protocol.AudioState> {
class="kw">public class="kw">static class="kw">final int EMPTY_ID = 0;
class="kw">public class="kw">static class="kw">final String EMPTY = "EMPTY";
class="kw">public class="kw">static class="kw">final AudioState EMPTY_AUDIO_STATE = new AudioState("EMPTY");
@Nonnull
class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, AudioState> CODEC = AssetBuilderCodec.<String, AudioState>builder(
AudioState.class, AudioState::new, Codec.STRING, (var0, var1) -> var0.id = var1, var0 -> var0.id, (var0, var1) -> var0.data = var1, var0 -> var0.data
)
.documentation(
"A named state axis that any audio object can subscribe to. Server-authority axes are driven by server logic and broadcast to clients. Client-authority axes are driven locally on the client (e.g. by AmbienceFX SetStates)."
)
.<AudioStateAuthority>append(
new KeyedCodec<>("Authority", AudioStateCodecs.AUTHORITY, true), (var0, var1) -> var0.authority = var1, var0 -> var0.authority
)
.documentation("Server: written on the server and broadcast. Client: written locally by AmbienceFX SetStates.")
.add()
.<String[]>append(
new KeyedCodec<>("Values", new ArrayCodec<>(Codec.STRING, String[]::new), true), (var0, var1) -> var0.values = var1, var0 -> var0.values
)
.addValidator(Validators.nonEmptyArray())
.documentation("Ordered list of state value names on this axis.")
.add()
.<String>append(new KeyedCodec<>("DefaultValue", Codec.STRING, true), (var0, var1) -> var0.defaultValue = var1, var0 -> var0.defaultValue)
.documentation("State value name the axis reports as active before any explicit setting.")
.add()
.<SyncPoint>append(new KeyedCodec<>("DefaultSyncTo", AudioStateCodecs.SYNC_POINT), (var0, var1) -> var0.defaultSyncTo = var1, var0 -> var0.defaultSyncTo)
.documentation("Default sync point for transitions on this axis. Overridden per-edge or per-call.")
.add()
.<StateTransitionConfig>append(
new KeyedCodec<>("DefaultTransition", StateTransitionConfig.CODEC), (var0, var1) -> var0.defaultTransition = var1, var0 -> var0.defaultTransition
)
.documentation("Fallback transition used when no edge matches the from/to pair. Omission means no class="kw">default is provided (transition immediately in 0 ms).")
.add()
.<StateTransitionConfig[]>append(
new KeyedCodec<>("Transitions", new ArrayCodec<>(StateTransitionConfig.CODEC, StateTransitionConfig[]::new)),
(var0, var1) -> var0.transitions = var1,
var0 -> var0.transitions
)
.documentation("Per-edge transition settings keyed by From/To state value names. '*' wildcards supported.")
.add()
.<Boolean>append(new KeyedCodec<>("RevertWhenInactive", Codec.BOOLEAN), (var0, var1) -> var0.revertWhenInactive = var1, var0 -> var0.revertWhenInactive)
.documentation(
"When true, the axis reverts to DefaultValue when every active AmbienceFX that was writing it goes inactive and no new writer claims it. Only meaningful for Authority: Client axes."
)
.add()
.validator(
(var0, var1) -> {
if (var0.values != null) {
HashSet var2 = new HashSet<>();
for (String var6 : var0.values) {
if (var6 != null && !var6.isBlank()) {
if ("*".equals(var6)) {
var1.fail("AudioState value name '*' is reserved for wildcard matching in transitions");
}
if (!var2.add(var6)) {
var1.fail("Duplicate AudioState value name '" + var6 + "'");
}
} else {
var1.fail("AudioState value name must be non-empty");
}
}
}
if (var0.defaultValue != null && AudioStateResolver.resolveValueIndex(var0.defaultValue, var0.values) < 0) {
var1.fail("DefaultValue '" + var0.defaultValue + "' is not a declared value");
}
if (var0.transitions != null) {
for (StateTransitionConfig var11 : var0.transitions) {
validateTransition(var0, var11, var1);
}
}
if (var0.defaultTransition != null) {
StateTransitionConfig var8 = var0.defaultTransition;
if (!Float.isFinite(var8.durationMs) || var8.durationMs < 0.0F) {
var1.fail("DefaultTransition DurationMs must be finite and >= 0");
}
}
if (var0.revertWhenInactive && var0.authority != AudioStateAuthority.Client) {
var1.fail(
"RevertWhenInactive requires Authority: Client (got "
+ var0.authority
+ "). Server-authority reverts should be driven by gameplay logic, not this flag"
);
}
}
)
.build();
class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(AudioState::getAssetStore));
class="kw">private class="kw">static AssetStore<String, AudioState, IndexedLookupTableAssetMap<String, AudioState>> ASSET_STORE;
class="kw">protected AssetExtraInfo.Data data;
class="kw">protected String id;
@Nonnull
class="kw">protected AudioStateAuthority authority = AudioStateAuthority.Server;
@Nullable
class="kw">protected String[] values;
@Nullable
class="kw">protected String defaultValue;
@Nonnull
class="kw">protected SyncPoint defaultSyncTo = SyncPoint.Immediate;
@Nullable
class="kw">protected StateTransitionConfig defaultTransition;
@Nullable
class="kw">protected StateTransitionConfig[] transitions;
class="kw">protected boolean revertWhenInactive;
class="kw">private SoftReference<com.hypixel.hytale.protocol.AudioState> cachedPacket;
class="kw">private class="kw">static void validateTransition(@Nonnull AudioState var0, @Nonnull StateTransitionConfig var1, @Nonnull ValidationResults var2) {
int var3 = AudioStateResolver.resolveValueIndex(var1.fromValueName, var0.values);
int var4 = AudioStateResolver.resolveValueIndex(var1.toValueName, var0.values);
if (var3 == -2) {
var2.fail("Transition From '" + var1.fromValueName + "' is not a declared value");
}
if (var4 == -2) {
var2.fail("Transition To '" + var1.toValueName + "' is not a declared value");
}
if (!Float.isFinite(var1.durationMs) || var1.durationMs < 0.0F) {
var2.fail("Transition DurationMs must be finite and >= 0");
}
}
class="kw">public class="kw">static AssetStore<String, AudioState, IndexedLookupTableAssetMap<String, AudioState>> getAssetStore() {
if (ASSET_STORE == null) {
ASSET_STORE = AssetRegistry.getAssetStore(AudioState.class);
}
class="kw">return ASSET_STORE;
}
class="kw">public class="kw">static IndexedLookupTableAssetMap<String, AudioState> getAssetMap() {
class="kw">return (IndexedLookupTableAssetMap<String, AudioState>)getAssetStore().getAssetMap();
}
class="kw">public AudioState(@Nonnull String var1) {
this.id = var1;
}
class="kw">protected AudioState() {
}
class="kw">public String getId() {
class="kw">return this.id;
}
@Nonnull
class="kw">public AudioStateAuthority getAuthority() {
class="kw">return this.authority;
}
@Nullable
class="kw">public String[] getValues() {
class="kw">return this.values;
}
@Nullable
class="kw">public String getDefaultValue() {
class="kw">return this.defaultValue;
}
class="kw">public int getDefaultValueIndex() {
if (this.defaultValue == null) {
class="kw">return 0;
}
int var1 = AudioStateResolver.resolveValueIndex(this.defaultValue, this.values);
class="kw">return Math.max(var1, 0);
}
@Nonnull
class="kw">public com.hypixel.hytale.protocol.AudioState toPacket() {
com.hypixel.hytale.protocol.AudioState var1 = this.cachedPacket == null ? null : this.cachedPacket.get();
if (var1 != null) {
class="kw">return var1;
}
com.hypixel.hytale.protocol.AudioState var2 = new com.hypixel.hytale.protocol.AudioState();
var2.id = this.id;
var2.authority = this.authority;
var2.values = this.values;
var2.defaultValueIndex = this.getDefaultValueIndex();
var2.defaultSyncTo = this.defaultSyncTo;
var2.defaultTransition = this.defaultTransition != null ? this.resolveAndToPacket(this.defaultTransition) : null;
var2.revertWhenInactive = this.revertWhenInactive;
if (this.transitions != null) {
StateTransition[] var3 = new StateTransition[this.transitions.length];
for (int var4 = 0; var4 < this.transitions.length; var4++) {
var3[var4] = this.resolveAndToPacket(this.transitions[var4]);
}
var2.transitions = var3;
}
this.cachedPacket = new SoftReference<>(var2);
class="kw">return var2;
}
class="kw">private StateTransition resolveAndToPacket(@Nonnull StateTransitionConfig var1) {
var1.fromValueIndex = AudioStateResolver.resolveValueIndex(var1.fromValueName, this.values);
if (var1.fromValueIndex == -2) {
var1.fromValueIndex = -1;
}
var1.toValueIndex = AudioStateResolver.resolveValueIndex(var1.toValueName, this.values);
if (var1.toValueIndex == -2) {
var1.toValueIndex = -1;
}
class="kw">return var1.toPacket();
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "AudioState{id='" + this.id + "', authority=" + this.authority + "}";
}
}