com/hypixel/hytale/component/AddReason.java
package com.hypixel.hytale.component;
public enum AddReason {
SPAWN,
LOAD;
private AddReason () {
}
}
com/hypixel/hytale/component/Archetype.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.data.unknown.UnknownComponents;
import com.hypixel.hytale.component.query.ExactArchetypeQuery;
import com.hypixel.hytale.component.query.Query;
import java.util.Arrays;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class Archetype <ECS_TYPE> implements Query <ECS_TYPE> {
@Nonnull
private static final Archetype EMPTY;
private final int minIndex;
private final int count;
@Nonnull
private final ComponentType<ECS_TYPE, ?>[] componentTypes;
@Nonnull
private final ExactArchetypeQuery<ECS_TYPE> exactQuery = new ExactArchetypeQuery <ECS_TYPE>(this );
public static <ECS_TYPE> Archetype<ECS_TYPE> empty () {
return EMPTY;
}
private Archetype (int minIndex, int count, @Nonnull ComponentType<ECS_TYPE, ?>[] componentTypes) {
this .minIndex = minIndex;
this .count = count;
this .componentTypes = componentTypes;
}
public int getMinIndex () {
return this .minIndex;
}
public int count () {
return this .count;
}
public int length () {
return this .componentTypes.length;
}
@Nullable
public ComponentType<ECS_TYPE, ?> get(int index) {
return this .componentTypes[index];
}
public boolean isEmpty () {
return this .componentTypes.length == 0 ;
}
public boolean contains (@Nonnull ComponentType<ECS_TYPE, ?> componentType) {
int index = componentType.getIndex();
return index < this .componentTypes.length && this .componentTypes[index] == componentType;
}
public boolean contains (@Nonnull Archetype<ECS_TYPE> archetype) {
if (this != archetype && !archetype.isEmpty()) {
for (int i = archetype.minIndex; i < archetype.componentTypes.length; ++i) {
ComponentType<ECS_TYPE, ?> componentType = archetype.componentTypes[i];
if (componentType != null && !this .contains(componentType)) {
return false ;
}
}
return true ;
} else {
return true ;
}
}
public void validateComponentType (@Nonnull ComponentType<ECS_TYPE, ?> componentType) {
if (!this .contains(componentType)) {
String var10002 = String.valueOf(componentType);
throw new IllegalArgumentException ("ComponentType is not in archetype: " + var10002 + ", " + String.valueOf(this ));
}
}
public void validateComponents (@Nonnull Component<ECS_TYPE>[] components, @Nullable ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> ignore) {
int len = Math.max(this .componentTypes.length, components.length);
for (int index = 0 ; index < len; ++index) {
ComponentType<ECS_TYPE, ?> componentType = index >= this .componentTypes.length ? null : this .componentTypes[index];
Component<ECS_TYPE> component = index >= components.length ? null : components[index];
if (componentType == null ) {
if (component != null && (ignore == null || index != ignore.getIndex())) {
throw new IllegalStateException ("Invalid component at index " + index + " expected null but found " + String.valueOf(component.getClass()));
}
} else {
Class<?> typeClass = componentType.getTypeClass();
if (component == null ) {
throw new IllegalStateException ("Invalid component at index " + index + " expected " + String.valueOf(typeClass) + " but found null" );
}
Class<? extends Component > aClass = component.getClass();
if (!aClass.equals(typeClass)) {
throw new IllegalStateException ("Invalid component at index " + index + " expected " + String.valueOf(typeClass) + " but found " + String.valueOf(aClass));
}
}
}
}
public boolean hasSerializableComponents (@Nonnull ComponentRegistry.Data<ECS_TYPE> data) {
if (this .isEmpty()) {
return false ;
} else if (this .contains(data.getRegistry().getNonSerializedComponentType())) {
return false ;
} else {
for (int index = this .minIndex; index < this .componentTypes.length; ++index) {
ComponentType<ECS_TYPE, ?> componentType = this .componentTypes[index];
if (componentType != null && data.getComponentCodec(componentType) != null ) {
return true ;
}
}
return false ;
}
}
public Archetype<ECS_TYPE> getSerializableArchetype (@Nonnull ComponentRegistry.Data<ECS_TYPE> data) {
if (this .isEmpty()) {
return EMPTY;
} else if (this .contains(data.getRegistry().getNonSerializedComponentType())) {
return EMPTY;
} else {
int lastSerializableIndex = this .componentTypes.length - 1 ;
for (int index = this .componentTypes.length - 1 ; index >= this .minIndex; --index) {
ComponentType<ECS_TYPE, ?> componentType = this .componentTypes[index];
if (componentType != null && data.getComponentCodec(componentType) != null ) {
lastSerializableIndex = index;
break ;
}
}
if (lastSerializableIndex < this .minIndex) {
return EMPTY;
} else {
ComponentType<ECS_TYPE, ?>[] serializableComponentTypes = new ComponentType [lastSerializableIndex + 1 ];
int serializableMinIndex = this .minIndex;
for (int index = serializableMinIndex; index < serializableComponentTypes.length; ++index) {
ComponentType<ECS_TYPE, ?> componentType = this .componentTypes[index];
if (componentType != null && data.getComponentCodec(componentType) != null ) {
serializableMinIndex = Math.min(serializableMinIndex, index);
serializableComponentTypes[index] = componentType;
}
}
return new Archetype <ECS_TYPE>(this .minIndex, serializableComponentTypes.length, serializableComponentTypes);
}
}
}
@Nonnull
public ExactArchetypeQuery<ECS_TYPE> asExactQuery () {
return this .exactQuery;
}
@Nonnull
public static <ECS_TYPE> Archetype<ECS_TYPE> of (@Nonnull ComponentType<ECS_TYPE, ?> componentTypes) {
int index = componentTypes.getIndex();
ComponentType<ECS_TYPE, ?>[] arr = new ComponentType [index + 1 ];
arr[index] = componentTypes;
return new Archetype <ECS_TYPE>(index, 1 , arr);
}
@SafeVarargs
public static <ECS_TYPE> Archetype<ECS_TYPE> of (@Nonnull ComponentType<ECS_TYPE, ?>... componentTypes) {
if (componentTypes.length == 0 ) {
return EMPTY;
} else {
ComponentRegistry<ECS_TYPE> registry = componentTypes[0 ].getRegistry();
int minIndex = 2147483647 ;
int maxIndex = -2147483648 ;
for (int i = 0 ; i < componentTypes.length; ++i) {
componentTypes[i].validateRegistry(registry);
int index = componentTypes[i].getIndex();
if (index < minIndex) {
minIndex = index;
}
if (index > maxIndex) {
maxIndex = index;
}
for (int n = i + 1 ; n < componentTypes.length; ++n) {
if (componentTypes[i] == componentTypes[n]) {
throw new IllegalArgumentException ("ComponentType provided multiple times! " + Arrays.toString(componentTypes));
}
}
}
ComponentType<ECS_TYPE, ?>[] arr = new ComponentType [maxIndex + 1 ];
for (ComponentType<ECS_TYPE, ?> componentType : componentTypes) {
arr[componentType.getIndex()] = componentType;
}
return new Archetype <ECS_TYPE>(minIndex, componentTypes.length, arr);
}
}
@Nonnull
public static <ECS_TYPE, T extends Component <ECS_TYPE>> Archetype<ECS_TYPE> add (@Nonnull Archetype<ECS_TYPE> archetype, @Nonnull ComponentType<ECS_TYPE, T> componentType) {
if (archetype.isEmpty()) {
return of(componentType);
} else if (archetype.contains(componentType)) {
String var10002 = String.valueOf(archetype);
throw new IllegalArgumentException ("ComponentType is already in Archetype! " + var10002 + ", " + String.valueOf(componentType));
} else {
archetype.validateRegistry(componentType.getRegistry());
int index = componentType.getIndex();
int minIndex = Math.min(index, archetype.minIndex);
int newLength = Math.max(index + 1 , archetype.componentTypes.length);
ComponentType<ECS_TYPE, ?>[] arr = (ComponentType[])Arrays.copyOf(archetype.componentTypes, newLength);
arr[index] = componentType;
return new Archetype <ECS_TYPE>(minIndex, archetype.count + 1 , arr);
}
}
public static <ECS_TYPE, T extends Component <ECS_TYPE>> Archetype<ECS_TYPE> remove (@Nonnull Archetype<ECS_TYPE> archetype, @Nonnull ComponentType<ECS_TYPE, T> componentType) {
if (archetype.isEmpty()) {
throw new IllegalArgumentException ("Archetype is already empty!" );
} else if (!archetype.contains(componentType)) {
String var10002 = String.valueOf(archetype);
throw new IllegalArgumentException ("Archetype doesn't contain ComponentType! " + var10002 + ", " + String.valueOf(componentType));
} else {
int oldLength = archetype.componentTypes.length;
int oldMinIndex = archetype.minIndex;
int oldMaxIndex = oldLength - 1 ;
if (oldMinIndex == oldMaxIndex) {
return EMPTY;
} else {
int newCount = archetype.count - 1 ;
int index = componentType.getIndex();
if (index == oldMaxIndex) {
int maxIndex;
for (maxIndex = index - 1 ; maxIndex > oldMinIndex && archetype.componentTypes[maxIndex] == null ; --maxIndex) {
}
return new Archetype <ECS_TYPE>(oldMinIndex, newCount, (ComponentType[])Arrays.copyOf(archetype.componentTypes, maxIndex + 1 ));
} else {
ComponentType<ECS_TYPE, ?>[] arr = (ComponentType[])Arrays.copyOf(archetype.componentTypes, oldLength);
arr[index] = null ;
if (index != oldMinIndex) {
return new Archetype <ECS_TYPE>(oldMinIndex, newCount, arr);
} else {
int minIndex;
for (minIndex = index + 1 ; minIndex < oldLength && arr[minIndex] == null ; ++minIndex) {
}
return new Archetype <ECS_TYPE>(minIndex, newCount, arr);
}
}
}
}
}
public boolean test (@Nonnull Archetype<ECS_TYPE> archetype) {
return archetype.contains(this );
}
public boolean requiresComponentType (@Nonnull ComponentType<ECS_TYPE, ?> componentType) {
return this .contains(componentType);
}
public void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
if (!this .isEmpty()) {
this .componentTypes[this .minIndex].validateRegistry(registry);
}
}
public void validate () {
for (int i = this .minIndex; i < this .componentTypes.length; ++i) {
ComponentType<ECS_TYPE, ?> componentType = this .componentTypes[i];
if (componentType != null ) {
componentType.validate();
}
}
}
public boolean equals (@Nullable Object o) {
if (this == o) {
return true ;
} else if (o != null && this .getClass() == o.getClass()) {
Archetype<?> archetype = (Archetype)o;
return Arrays.equals(this .componentTypes, archetype.componentTypes);
} else {
return false ;
}
}
public int hashCode () {
return Arrays.hashCode(this .componentTypes);
}
@Nonnull
public String toString () {
return "Archetype{componentTypes=" + Arrays.toString(this .componentTypes) + "}" ;
}
static {
EMPTY = new Archetype (0 , 0 , ComponentType.EMPTY_ARRAY);
}
}
com/hypixel/hytale/component/ArchetypeChunk.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.function.consumer.IntObjectConsumer;
import java.util.Arrays;
import java.util.function.Consumer;
import java.util.function.IntPredicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ArchetypeChunk <ECS_TYPE> {
@Nonnull
private static final ArchetypeChunk[] EMPTY_ARRAY = new ArchetypeChunk [0 ];
@Nonnull
protected final Store<ECS_TYPE> store;
@Nonnull
protected final Archetype<ECS_TYPE> archetype;
protected int entitiesSize;
@Nonnull
protected Ref<ECS_TYPE>[] refs = new Ref [16 ];
protected Component<ECS_TYPE>[][] components;
public static <ECS_TYPE> ArchetypeChunk<ECS_TYPE>[] emptyArray() {
return EMPTY_ARRAY;
}
public ArchetypeChunk (@Nonnull Store<ECS_TYPE> store, @Nonnull Archetype<ECS_TYPE> archetype) {
this .store = store;
this .archetype = archetype;
.components = [archetype.length()][];
( archetype.getMinIndex(); i < archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = archetype.get(i);
(componentType != ) {
.components[componentType.getIndex()] = [ ];
}
}
}
Archetype<ECS_TYPE> {
.archetype;
}
{
.entitiesSize;
}
Ref<ECS_TYPE> {
(index >= && index < .entitiesSize) {
.refs[index];
} {
(index);
}
}
<T <ECS_TYPE>> {
componentType.validateRegistry( .store.getRegistry());
(index >= && index < .entitiesSize) {
(! .archetype.contains(componentType)) {
( + String.valueOf(componentType));
} {
.components[componentType.getIndex()][index] = component;
}
} {
(index);
}
}
<T <ECS_TYPE>> T {
componentType.validateRegistry( .store.getRegistry());
(index >= && index < .entitiesSize) {
(T)(! .archetype.contains(componentType) ? : .components[componentType.getIndex()][index]);
} {
(index);
}
}
{
(! .archetype.equals(holder.getArchetype())) {
( );
} {
.entitiesSize++;
.refs.length;
(oldLength <= entityIndex) {
ArrayUtil.grow(entityIndex);
.refs = (Ref[])Arrays.copyOf( .refs, newLength);
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
componentType.getIndex();
.components[componentTypeIndex] = (Component[])Arrays.copyOf( .components[componentTypeIndex], newLength);
}
}
}
.refs[entityIndex] = ref;
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
.components[componentType.getIndex()][entityIndex] = holder.getComponent(componentType);
}
}
entityIndex;
}
}
Holder<ECS_TYPE> {
(entityIndex >= .entitiesSize) {
(entityIndex);
} {
Component<ECS_TYPE>[] entityComponents = target.ensureComponentsSize( .archetype.length());
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
componentType.getIndex();
Component<ECS_TYPE> component = .components[componentTypeIndex][entityIndex];
entityComponents[componentTypeIndex] = component.clone();
}
}
target.init( .archetype, entityComponents);
target;
}
}
Holder<ECS_TYPE> {
(entityIndex >= .entitiesSize) {
(entityIndex);
} {
Archetype<ECS_TYPE> serializableArchetype = .archetype.getSerializableArchetype(data);
Component<ECS_TYPE>[] entityComponents = target.ensureComponentsSize(serializableArchetype.length());
( serializableArchetype.getMinIndex(); i < serializableArchetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = serializableArchetype.get(i);
(componentType != ) {
componentType.getIndex();
Component<ECS_TYPE> component = .components[componentTypeIndex][entityIndex];
entityComponents[componentTypeIndex] = component.cloneSerializable();
}
}
target.init(serializableArchetype, entityComponents);
target;
}
}
Holder<ECS_TYPE> {
(entityIndex >= .entitiesSize) {
(entityIndex);
} {
Component<ECS_TYPE>[] entityComponents = target.ensureComponentsSize( .archetype.length());
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
componentType.getIndex();
entityComponents[componentTypeIndex] = .components[componentTypeIndex][entityIndex];
}
}
.entitiesSize - ;
(entityIndex != lastIndex) {
.fillEmptyIndex(entityIndex, lastIndex);
}
.refs[lastIndex] = ;
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
.components[componentType.getIndex()][lastIndex] = ;
}
}
.entitiesSize = lastIndex;
target.init( .archetype, entityComponents);
target;
}
}
{
Component<ECS_TYPE>[] entityComponents = [ .archetype.length()];
( ; entityIndex < .entitiesSize; ++entityIndex) {
Ref<ECS_TYPE> ref = .refs[entityIndex];
.refs[entityIndex] = ;
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
componentType.getIndex();
entityComponents[componentTypeIndex] = .components[componentTypeIndex][entityIndex];
.components[componentTypeIndex][entityIndex] = ;
}
}
tempInternalEntityHolder._internal_init( .archetype, entityComponents, .store.getRegistry().getUnknownComponentType());
modification.accept(tempInternalEntityHolder);
chunk.addEntity(ref, tempInternalEntityHolder);
referenceConsumer.accept(newEntityIndex, ref);
}
.entitiesSize = ;
}
{
- ;
- ;
Component<ECS_TYPE>[] entityComponents = [ .archetype.length()];
( ; entityIndex < .entitiesSize; ++entityIndex) {
(shouldTransfer.test(entityIndex)) {
(firstTransfered == - ) {
firstTransfered = entityIndex;
}
lastTransfered = entityIndex;
Ref<ECS_TYPE> ref = .refs[entityIndex];
.refs[entityIndex] = ;
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
componentType.getIndex();
entityComponents[componentTypeIndex] = .components[componentTypeIndex][entityIndex];
.components[componentTypeIndex][entityIndex] = ;
}
}
tempInternalEntityHolder.init( .archetype, entityComponents);
modification.accept(tempInternalEntityHolder);
chunk.addEntity(ref, tempInternalEntityHolder);
referenceConsumer.accept(newEntityIndex, ref);
}
}
(firstTransfered != - ) {
(lastTransfered == .entitiesSize - ) {
.entitiesSize = firstTransfered;
;
}
.entitiesSize - (lastTransfered - firstTransfered + );
( firstTransfered; entityIndex <= lastTransfered; ++entityIndex) {
( .refs[entityIndex] == ) {
.entitiesSize - ;
(lastIndex == lastTransfered) {
;
}
(entityIndex != lastIndex) {
.fillEmptyIndex(entityIndex, lastIndex);
}
-- .entitiesSize;
}
}
.entitiesSize = newSize;
}
}
{
Ref<ECS_TYPE> ref = .refs[lastIndex];
.store.setEntityChunkIndex(ref, entityIndex);
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != ) {
Component<ECS_TYPE>[] componentArr = .components[componentType.getIndex()];
componentArr[entityIndex] = componentArr[lastIndex];
}
}
.refs[entityIndex] = ref;
}
{
sb.append(prefix).append( ).append( .archetype).append( );
sb.append(prefix).append( ).append( .entitiesSize).append( );
( ; i < .entitiesSize; ++i) {
sb.append(prefix).append( ).append( .refs[i]).append( );
sb.append(prefix).append( ).append( ).append( );
( .archetype.getMinIndex(); x < .archetype.length(); ++x) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(x);
(componentType != ) {
sb.append(prefix).append( ).append(componentType.getIndex()).append( ).append( .components[componentType.getIndex()][x]).append( );
}
}
}
}
String {
String.valueOf( .archetype);
+ var10000 + + .entitiesSize + + Arrays.toString( .refs) + + Arrays.toString( .components) + ;
}
}
com/hypixel/hytale/component/CommandBuffer.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.event.EntityEventType;
import com.hypixel.hytale.component.event.WorldEventType;
import com.hypixel.hytale.component.system.EcsEvent;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class CommandBuffer <ECS_TYPE> implements ComponentAccessor <ECS_TYPE> {
@Nonnull
private final Store<ECS_TYPE> store;
@Nonnull
private final Deque<Consumer<Store<ECS_TYPE>>> queue = new ArrayDeque ();
@Nullable
private Ref<ECS_TYPE> trackedRef;
private boolean trackedRefRemoved;
@Nullable
private CommandBuffer<ECS_TYPE> parentBuffer;
@Nullable
private Thread thread;
protected CommandBuffer (@Nonnull Store<ECS_TYPE> store) {
this .store = store;
assert this .setThread();
}
@Nonnull
public Store<ECS_TYPE> getStore () {
return .store;
}
{
Thread.currentThread() == .thread;
.queue.add(consumer);
}
<T <ECS_TYPE>> T {
Thread.currentThread() == .thread;
(T) .store.__internal_getComponent(ref, componentType);
}
Archetype<ECS_TYPE> {
Thread.currentThread() == .thread;
.store.__internal_getArchetype(ref);
}
<T <ECS_TYPE>> T {
Thread.currentThread() == .thread;
(T) .store.__internal_getResource(resourceType);
}
ECS_TYPE {
.store.getExternalData();
}
Ref<ECS_TYPE>[] addEntities( Holder<ECS_TYPE>[] holders, AddReason reason) {
Thread.currentThread() == .thread;
Ref<ECS_TYPE>[] refs = [holders.length];
( ; i < holders.length; ++i) {
refs[i] = ( .store);
}
.queue.add((Consumer)(chunk) -> chunk.addEntities(holders, refs, reason));
refs;
}
Ref<ECS_TYPE> {
Thread.currentThread() == .thread;
Ref<ECS_TYPE> ref = <ECS_TYPE>( .store);
.queue.add((Consumer)(chunk) -> chunk.addEntity(holder, ref, reason));
ref;
}
{
Thread.currentThread() == .thread;
( refStart; i < refStart + length; ++i) {
refs[i] = ( .store);
}
.queue.add((Consumer)(chunk) -> chunk.addEntities(holders, holderStart, refs, refStart, length, reason));
}
Ref<ECS_TYPE> {
(ref.isValid()) {
( );
} (ref.getStore() != .store) {
( );
} {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> chunk.addEntity(holder, ref, reason));
ref;
}
}
Holder<ECS_TYPE> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> chunk.copyEntity(ref, target));
target;
}
{
Thread.currentThread() == .thread;
();
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.removeEntity(ref, chunk.getRegistry().newHolder(), reason, source);
}
});
(ref.equals( .trackedRef)) {
.trackedRefRemoved = ;
}
( .parentBuffer != ) {
.parentBuffer.testRemovedTracked(ref);
}
}
{
Thread.currentThread() == .thread;
();
.queue.add((Consumer)(chunk) -> chunk.removeEntity(ref, chunk.getRegistry().newHolder(), reason, source));
(ref.equals( .trackedRef)) {
.trackedRefRemoved = ;
}
( .parentBuffer != ) {
.parentBuffer.testRemovedTracked(ref);
}
}
Holder<ECS_TYPE> {
Thread.currentThread() == .thread;
();
.queue.add((Consumer)(chunk) -> chunk.removeEntity(ref, target, reason, source));
(ref.equals( .trackedRef)) {
.trackedRefRemoved = ;
}
( .parentBuffer != ) {
.parentBuffer.testRemovedTracked(ref);
}
target;
}
<T <ECS_TYPE>> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.ensureComponent(ref, componentType);
}
});
}
<T <ECS_TYPE>> T {
Thread.currentThread() == .thread;
.store.__internal_getComponent(ref, componentType);
(component != ) {
component;
} {
.store.getRegistry()._internal_getData().createComponent(componentType);
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.addComponent(ref, componentType, newComponent);
}
});
newComponent;
}
}
<T <ECS_TYPE>> T {
Thread.currentThread() == .thread;
.store.getRegistry()._internal_getData().createComponent(componentType);
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.addComponent(ref, componentType, component);
}
});
component;
}
<T <ECS_TYPE>> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.addComponent(ref, componentType, component);
}
});
}
<T <ECS_TYPE>> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.replaceComponent(ref, componentType, component);
}
});
}
<T <ECS_TYPE>> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.removeComponent(ref, componentType);
}
});
}
<T <ECS_TYPE>> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.tryRemoveComponent(ref, componentType);
}
});
}
<T <ECS_TYPE>> {
Thread.currentThread() == .thread;
.queue.add((Consumer)(chunk) -> {
(ref.isValid()) {
chunk.putComponent(ref, componentType, component);
}
});
}
<Event > {
Thread.currentThread() == .thread;
.store.internal_invoke( , ref, param);
}
<Event > {
Thread.currentThread() == .thread;
.store.internal_invoke( , systemType, ref, param);
}
<Event > {
Thread.currentThread() == .thread;
.store.internal_invoke( , param);
}
<Event > {
Thread.currentThread() == .thread;
.store.internal_invoke( , systemType, param);
}
{
.trackedRef = ref;
}
{
(ref.equals( .trackedRef)) {
.trackedRefRemoved = ;
}
( .parentBuffer != ) {
.parentBuffer.testRemovedTracked(ref);
}
}
{
( .trackedRef == ) {
( );
} {
.trackedRefRemoved;
.trackedRefRemoved = ;
wasRemoved;
}
}
{
.trackedRef = ;
.trackedRefRemoved = ;
Thread.currentThread() == .thread;
(! .queue.isEmpty()) {
((Consumer) .queue.pop()).accept( .store);
}
.store.storeCommandBuffer( );
}
CommandBuffer<ECS_TYPE> {
CommandBuffer<ECS_TYPE> forkedBuffer = .store.takeCommandBuffer();
forkedBuffer.parentBuffer = ;
forkedBuffer;
}
{
.trackedRef = ;
.trackedRefRemoved = ;
.parentBuffer = ;
(! .queue.isEmpty()) {
commandBuffer.queue.add((Consumer) .queue.pop());
}
.store.storeCommandBuffer( );
}
{
;
(!$assertionsDisabled) {
areAssertionsEnabled = ;
( ) {
();
}
}
(!areAssertionsEnabled) {
( );
} {
.thread = Thread.currentThread();
;
}
}
{
(! .queue.isEmpty()) {
( );
}
}
}
com/hypixel/hytale/component/Component.java
package com.hypixel.hytale.component;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface Component <ECS_TYPE> extends Cloneable {
@Nonnull
Component[] EMPTY_ARRAY = new Component [0 ];
@Nullable
Component<ECS_TYPE> clone () ;
@Nullable
default Component<ECS_TYPE> cloneSerializable () {
return this .clone();
}
}
com/hypixel/hytale/component/ComponentAccessor.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.event.EntityEventType;
import com.hypixel.hytale.component.event.WorldEventType;
import com.hypixel.hytale.component.system.EcsEvent;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface ComponentAccessor <ECS_TYPE> {
@Nullable
<T extends Component <ECS_TYPE>> T getComponent (@Nonnull Ref<ECS_TYPE> var1, @Nonnull ComponentType<ECS_TYPE, T> var2) ;
@Nonnull
<T extends Component <ECS_TYPE>> T ensureAndGetComponent (@Nonnull Ref<ECS_TYPE> var1, @Nonnull ComponentType<ECS_TYPE, T> var2) ;
@Nonnull
Archetype<ECS_TYPE> getArchetype (@Nonnull Ref<ECS_TYPE> var1) ;
@Nonnull
<T extends Resource <ECS_TYPE>> T getResource (@Nonnull ResourceType<ECS_TYPE, T> var1) ;
@Nonnull
ECS_TYPE getExternalData () ;
<T extends Component <ECS_TYPE>> void putComponent (@Nonnull Ref<ECS_TYPE> var1, @Nonnull ComponentType<ECS_TYPE, T> var2, T var3) ;
<T <ECS_TYPE>> ;
<T <ECS_TYPE>> T ;
Ref<ECS_TYPE>[] addEntities( Holder<ECS_TYPE>[] var1, AddReason var2);
Ref<ECS_TYPE> ;
Holder<ECS_TYPE> ;
<T <ECS_TYPE>> ;
<T <ECS_TYPE>> ;
<Event > ;
<Event > ;
<Event > ;
<Event > ;
}
com/hypixel/hytale/component/ComponentRegistration.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public record ComponentRegistration <ECS_TYPE, T extends Component <ECS_TYPE>>(@Nonnull Class<? super T> typeClass, @Nullable String id, @Nullable BuilderCodec<T> codec, @Nonnull Supplier<T> supplier, @Nonnull ComponentType<ECS_TYPE, T> componentType) {
}
com/hypixel/hytale/component/ComponentRegistry.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.lookup.MapProvidedMapCodec;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.component.data.change.ChangeType;
import com.hypixel.hytale.component.data.change.ComponentChange;
import com.hypixel.hytale.component.data.change.DataChange;
import com.hypixel.hytale.component.data.change.ResourceChange;
import com.hypixel.hytale.component.data.change.SystemChange;
import com.hypixel.hytale.component.data.change.SystemGroupChange;
import com.hypixel.hytale.component.data.change.SystemTypeChange;
import com.hypixel.hytale.component.data.unknown.TempUnknownComponent;
import com.hypixel.hytale.component.data.unknown.UnknownComponents;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.event.EntityEventType;
import com.hypixel.hytale.component.event.WorldEventType;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.query.ReadWriteArchetypeQuery;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.component.spatial.SpatialStructure;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.EntityEventSystem;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.ISystem;
import com.hypixel.hytale.component.system.QuerySystem;
import com.hypixel.hytale.component.system.RefChangeSystem;
com.hypixel.hytale.component.system.RefSystem;
com.hypixel.hytale.component.system.System;
com.hypixel.hytale.component.system.WorldEventSystem;
com.hypixel.hytale.component.system.tick.ArchetypeTickingSystem;
com.hypixel.hytale.component.system.tick.RunWhenPausedSystem;
com.hypixel.hytale.component.system.tick.TickableSystem;
com.hypixel.hytale.component.system.tick.TickingSystem;
com.hypixel.hytale.logger.HytaleLogger;
it.unimi.dsi.fastutil.objects.Object2BooleanMap;
it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
it.unimi.dsi.fastutil.objects.Object2IntMap;
it.unimi.dsi.fastutil.objects.Object2IntMaps;
it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.lang.ref.Reference;
java.lang.ref.ReferenceQueue;
java.lang.ref.WeakReference;
java.util.Arrays;
java.util.BitSet;
java.util.Collections;
java.util.HashSet;
java.util.LinkedHashMap;
java.util.List;
java.util.Map;
java.util.Objects;
java.util.Optional;
java.util.Set;
java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.atomic.AtomicInteger;
java.util.concurrent.locks.ReadWriteLock;
java.util.concurrent.locks.ReentrantReadWriteLock;
java.util.concurrent.locks.StampedLock;
java.util.function.Consumer;
java.util.function.Function;
java.util.function.Supplier;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
org.bson.BsonDocument;
<ECS_TYPE> <ECS_TYPE> {
- ;
;
HytaleLogger.forEnclosingClass();
KeyedCodec<Integer> VERSION;
AtomicInteger REFERENCE_THREAD_COUNTER;
shutdown;
();
Object2IntMap<String> componentIdToIndex = <String>( );
();
componentSize;
String[] componentIds = [ ];
BuilderCodec<? <ECS_TYPE>>[] componentCodecs = [ ];
Supplier<? <ECS_TYPE>>[] componentSuppliers = [ ];
ComponentType<ECS_TYPE, ? <ECS_TYPE>>[] componentTypes = [ ];
Object2IntMap<String> resourceIdToIndex = <String>( );
();
resourceSize;
String[] resourceIds = [ ];
BuilderCodec<? <ECS_TYPE>>[] resourceCodecs = [ ];
Supplier<? <ECS_TYPE>>[] resourceSuppliers = [ ];
ResourceType<ECS_TYPE, ? <ECS_TYPE>>[] resourceTypes = [ ];
Object2IntMap<Class<? <ECS_TYPE>>> systemTypeClassToIndex = <Class<? <ECS_TYPE>>>( );
Object2IntMap<Class<? >> entityEventTypeClassToIndex = <Class<? >>( );
Object2IntMap<Class<? >> worldEventTypeClassToIndex = <Class<? >>( );
();
systemTypeSize;
SystemType<ECS_TYPE, ? <ECS_TYPE>>[] systemTypes = [ ];
BitSet[] systemTypeToSystemIndex = [ ];
();
systemGroupSize;
SystemGroup<ECS_TYPE>[] systemGroups = [ ];
systemSize;
ISystem<ECS_TYPE>[] systems = [ ];
ISystem<ECS_TYPE>[] sortedSystems = [ ];
Object2IntMap<Class<? <ECS_TYPE>>> systemClasses = <Class<? <ECS_TYPE>>>( );
Object2BooleanMap<Class<? <ECS_TYPE>>> systemBypassClassCheck = <Class<? <ECS_TYPE>>>( );
();
storeSize;
Store<ECS_TYPE>[] stores = [ ];
();
Data<ECS_TYPE> data;
Set<Reference<Holder<ECS_TYPE>>> holders = ConcurrentHashMap.newKeySet();
ReferenceQueue<Holder<ECS_TYPE>> holderReferenceQueue = ();
Thread holderReferenceThread;
ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> unknownComponentType;
ComponentType<ECS_TYPE, NonTicking<ECS_TYPE>> nonTickingComponentType;
ComponentType<ECS_TYPE, NonSerialized<ECS_TYPE>> nonSerializedComponentType;
SystemType<ECS_TYPE, HolderSystem<ECS_TYPE>> holderSystemType;
SystemType<ECS_TYPE, RefSystem<ECS_TYPE>> refSystemType;
SystemType<ECS_TYPE, RefChangeSystem<ECS_TYPE, ?>> refChangeSystemType;
SystemType<ECS_TYPE, QuerySystem<ECS_TYPE>> querySystemType;
SystemType<ECS_TYPE, TickingSystem<ECS_TYPE>> tickingSystemType;
SystemType<ECS_TYPE, TickableSystem<ECS_TYPE>> tickableSystemType;
SystemType<ECS_TYPE, RunWhenPausedSystem<ECS_TYPE>> runWhenPausedSystemType;
SystemType<ECS_TYPE, ArchetypeTickingSystem<ECS_TYPE>> archetypeTickingSystemType;
{
.componentIdToIndex.defaultReturnValue(- );
.resourceIdToIndex.defaultReturnValue(- );
.systemTypeClassToIndex.defaultReturnValue(- );
.entityEventTypeClassToIndex.defaultReturnValue(- );
.worldEventTypeClassToIndex.defaultReturnValue(- );
( ; i < ; ++i) {
.systemTypeToSystemIndex[i] = ();
}
.data = <ECS_TYPE>( );
.unknownComponentType = .registerComponent(UnknownComponents.class, , UnknownComponents.CODEC);
.nonTickingComponentType = .registerComponent(NonTicking.class, NonTicking::get);
.nonSerializedComponentType = .registerComponent(NonSerialized.class, NonSerialized::get);
.holderSystemType = .registerSystemType(HolderSystem.class);
.refSystemType = .registerSystemType(RefSystem.class);
.refChangeSystemType = .registerSystemType(RefChangeSystem.class);
.querySystemType = .registerSystemType(QuerySystem.class);
.tickingSystemType = .registerSystemType(TickingSystem.class);
.tickableSystemType = .registerSystemType(TickableSystem.class);
.runWhenPausedSystemType = .registerSystemType(RunWhenPausedSystem.class);
.archetypeTickingSystemType = .registerSystemType(ArchetypeTickingSystem.class);
.holderReferenceThread = (() -> {
{
(!Thread.interrupted()) {
.holders.remove( .holderReferenceQueue.remove());
}
} (InterruptedException var2) {
Thread.currentThread().interrupt();
}
}, + REFERENCE_THREAD_COUNTER.getAndIncrement());
.holderReferenceThread.setDaemon( );
.holderReferenceThread.start();
}
{
.shutdown;
}
{
.shutdown0();
}
{
.shutdown = ;
.holderReferenceThread.interrupt();
.storeLock.writeLock();
{
( .storeSize - ; storeIndex >= ; --storeIndex) {
Store<ECS_TYPE> store = .stores[storeIndex];
(store != ) {
store.shutdown0( .data);
}
}
.stores = Store.EMPTY_ARRAY;
} {
.storeLock.unlockWrite(lock);
}
}
ReadWriteLock {
.dataUpdateLock;
}
ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> {
.unknownComponentType;
}
ComponentType<ECS_TYPE, NonTicking<ECS_TYPE>> {
.nonTickingComponentType;
}
ComponentType<ECS_TYPE, NonSerialized<ECS_TYPE>> {
.nonSerializedComponentType;
}
SystemType<ECS_TYPE, HolderSystem<ECS_TYPE>> {
.holderSystemType;
}
SystemType<ECS_TYPE, RefSystem<ECS_TYPE>> {
.refSystemType;
}
SystemType<ECS_TYPE, RefChangeSystem<ECS_TYPE, ?>> getRefChangeSystemType() {
.refChangeSystemType;
}
SystemType<ECS_TYPE, QuerySystem<ECS_TYPE>> {
.querySystemType;
}
SystemType<ECS_TYPE, TickingSystem<ECS_TYPE>> {
.tickingSystemType;
}
SystemType<ECS_TYPE, TickableSystem<ECS_TYPE>> {
.tickableSystemType;
}
SystemType<ECS_TYPE, RunWhenPausedSystem<ECS_TYPE>> {
.runWhenPausedSystemType;
}
SystemType<ECS_TYPE, ArchetypeTickingSystem<ECS_TYPE>> {
.archetypeTickingSystemType;
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
.registerComponent(tClass, (String) , (BuilderCodec) , supplier, );
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
Objects.requireNonNull(codec);
.registerComponent(tClass, id, codec, codec::getDefaultValue, );
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
Objects.requireNonNull(codec);
.registerComponent(tClass, id, codec, codec::getDefaultValue, skipValidation);
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
( .shutdown) {
( );
} {
(codec != && !skipValidation) {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
codec.validateDefaults(extraInfo, ());
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER, );
}
.dataLock.writeLock();
ComponentType var9;
{
ComponentType<ECS_TYPE, T> componentType = .registerComponent0(tClass, id, codec, supplier, ());
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.REGISTERED, componentType));
var9 = componentType;
} {
.dataLock.unlock(lock);
}
var9;
}
}
<T <ECS_TYPE>> {
( .shutdown) {
( );
} {
componentType.validateRegistry( );
componentType.validate();
(componentType.equals( .unknownComponentType)) {
( );
} {
.dataLock.writeLock();
{
.unregisterComponent0(componentType);
List<DataChange> changes = <DataChange>();
changes.add( (ChangeType.UNREGISTERED, componentType));
( .systemSize - ; unsortedSystemIndex >= ; --unsortedSystemIndex) {
ISystem<ECS_TYPE> system = .systems[unsortedSystemIndex];
(system QuerySystem) {
QuerySystem<ECS_TYPE> archetypeSystem = (QuerySystem)system;
Query<ECS_TYPE> query = archetypeSystem.getQuery();
(query != && query.requiresComponentType(componentType)) {
.unregisterSystem0(unsortedSystemIndex, system);
changes.add( (ChangeType.UNREGISTERED, system));
}
}
}
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0((DataChange[])changes.toArray((x$ ) -> [x$ ]));
componentType.invalidate();
} {
.dataLock.unlock(lock);
}
}
}
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
.registerResource(tClass, (String) , (BuilderCodec) , supplier);
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
Objects.requireNonNull(codec);
.registerResource(tClass, id, codec, codec::getDefaultValue);
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
( .shutdown) {
( );
} {
(codec != ) {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
codec.validateDefaults(extraInfo, ());
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER, );
}
.dataLock.writeLock();
ResourceType var8;
{
ResourceType<ECS_TYPE, T> resourceType = .registerResource0(tClass, id, codec, supplier, ());
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.REGISTERED, resourceType));
var8 = resourceType;
} {
.dataLock.unlock(lock);
}
var8;
}
}
<T <ECS_TYPE>> {
( .shutdown) {
( );
} {
resourceType.validateRegistry( );
resourceType.validate();
.dataLock.writeLock();
{
.unregisterResource0(resourceType);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.UNREGISTERED, resourceType));
resourceType.invalidate();
} {
.dataLock.unlock(lock);
}
}
}
<T <ECS_TYPE>> SystemType<ECS_TYPE, T> {
( .shutdown) {
( );
} (!ISystem.class.isAssignableFrom(systemTypeClass)) {
( + String.valueOf(systemTypeClass));
} {
.dataLock.writeLock();
SystemType var5;
{
SystemType<ECS_TYPE, T> systemType = .registerSystemType0(systemTypeClass);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.REGISTERED, systemType));
var5 = systemType;
} {
.dataLock.unlock(lock);
}
var5;
}
}
<T <ECS_TYPE>> {
( .shutdown) {
( );
} {
systemType.validate();
.dataLock.writeLock();
{
.unregisterSystemType0(systemType);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.UNREGISTERED, systemType));
systemType.invalidate();
} {
.dataLock.unlock(lock);
}
}
}
<T > EntityEventType<ECS_TYPE, T> {
( .shutdown) {
( );
} (!EcsEvent.class.isAssignableFrom(eventTypeClass)) {
( + String.valueOf(eventTypeClass));
} {
.dataLock.writeLock();
EntityEventType var5;
{
EntityEventType<ECS_TYPE, T> systemType = .registerEntityEventType0(eventTypeClass);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.REGISTERED, systemType));
var5 = systemType;
} {
.dataLock.unlock(lock);
}
var5;
}
}
<T > WorldEventType<ECS_TYPE, T> {
( .shutdown) {
( );
} (!EcsEvent.class.isAssignableFrom(eventTypeClass)) {
( + String.valueOf(eventTypeClass));
} {
.dataLock.writeLock();
WorldEventType var5;
{
WorldEventType<ECS_TYPE, T> systemType = .registerWorldEventType0(eventTypeClass);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.REGISTERED, systemType));
var5 = systemType;
} {
.dataLock.unlock(lock);
}
var5;
}
}
<T > {
( .shutdown) {
( );
} {
eventType.validate();
.dataLock.writeLock();
{
.unregisterEntityEventType0(eventType);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.UNREGISTERED, eventType));
eventType.invalidate();
} {
.dataLock.unlock(lock);
}
}
}
<T > {
( .shutdown) {
( );
} {
eventType.validate();
.dataLock.writeLock();
{
.unregisterWorldEventType0(eventType);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.UNREGISTERED, eventType));
eventType.invalidate();
} {
.dataLock.unlock(lock);
}
}
}
SystemGroup<ECS_TYPE> {
.registerSystemGroup(Collections.emptySet());
}
SystemGroup<ECS_TYPE> {
( .shutdown) {
( );
} {
.dataLock.writeLock();
SystemGroup var5;
{
SystemGroup<ECS_TYPE> systemGroup = .registerSystemGroup0(dependencies);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.REGISTERED, systemGroup));
var5 = systemGroup;
} {
.dataLock.unlock(lock);
}
var5;
}
}
{
( .shutdown) {
( );
} {
systemGroup.validate();
.dataLock.writeLock();
{
.unregisterSystemGroup0(systemGroup);
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0( (ChangeType.UNREGISTERED, systemGroup));
systemGroup.invalidate();
} {
.dataLock.unlock(lock);
}
}
}
{
.registerSystem(system, );
}
{
( .shutdown) {
( );
} {
Class<? > systemClass = system.getClass();
(system QuerySystem) {
QuerySystem<ECS_TYPE> archetypeSystem = (QuerySystem)system;
Query<ECS_TYPE> query = archetypeSystem.getQuery();
query.validateRegistry( );
query.validate();
(query ReadWriteArchetypeQuery) {
ReadWriteArchetypeQuery<ECS_TYPE> readWriteQuery = (ReadWriteArchetypeQuery)query;
(readWriteQuery.getReadArchetype().equals(readWriteQuery.getWriteArchetype())) {
LOGGER.at(Level.WARNING).log( , systemClass.getName());
}
}
}
.dataLock.writeLock();
{
(!bypassClassCheck) {
( .systemClasses.containsKey(systemClass)) {
( + systemClass.getName() + );
}
} {
.systemBypassClassCheck.put(systemClass, );
}
(ArrayUtil.indexOf( .systems, system) != - ) {
( );
}
(Dependency<ECS_TYPE> dependency : system.getDependencies()) {
dependency.validate( );
}
.registerSystem0(system);
List<DataChange> changes = <DataChange>();
changes.add( (ChangeType.REGISTERED, system));
(system System) {
System<ECS_TYPE> theSystem = (System)system;
(ComponentRegistration<ECS_TYPE, ?> componentRegistration : theSystem.getComponentRegistrations()) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .registerComponent0(componentRegistration);
changes.add( (ChangeType.REGISTERED, componentType));
}
(ResourceRegistration<ECS_TYPE, ?> resourceRegistration : theSystem.getResourceRegistrations()) {
ResourceType<ECS_TYPE, ? <ECS_TYPE>> resourceType = .registerResource0(resourceRegistration);
changes.add( (ChangeType.REGISTERED, resourceType));
}
}
(system EntityEventSystem) {
EntityEventSystem<ECS_TYPE, ?> eventSystem = (EntityEventSystem)system;
(! .entityEventTypeClassToIndex.containsKey(eventSystem.getEventType())) {
EntityEventType<ECS_TYPE, ?> eventType = .registerEntityEventType0(eventSystem.getEventType());
changes.add( (ChangeType.REGISTERED, eventType));
}
}
(system WorldEventSystem) {
WorldEventSystem<ECS_TYPE, ?> eventSystem = (WorldEventSystem)system;
(! .worldEventTypeClassToIndex.containsKey(eventSystem.getEventType())) {
WorldEventType<ECS_TYPE, ?> eventType = .registerWorldEventType0(eventSystem.getEventType());
changes.add( (ChangeType.REGISTERED, eventType));
}
}
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0((DataChange[])changes.toArray((x$ ) -> [x$ ]));
} {
.dataLock.unlock(lock);
}
}
}
{
( .shutdown) {
( );
} {
.dataLock.writeLock();
{
.systemClasses.getInt(systemClass);
ISystem<ECS_TYPE> system = .systems[systemIndex];
(system != ) {
(system QuerySystem) {
QuerySystem<ECS_TYPE> archetypeSystem = (QuerySystem)system;
Query<ECS_TYPE> query = archetypeSystem.getQuery();
query.validateRegistry( );
query.validate();
}
ArrayUtil.indexOf( .systems, system);
(unsortedSystemIndex == - ) {
( );
}
.unregisterSystem0(unsortedSystemIndex, system);
List<DataChange> changes = <DataChange>();
changes.add( (ChangeType.UNREGISTERED, system));
(system System) {
System<ECS_TYPE> theSystem = (System)system;
(ComponentRegistration<ECS_TYPE, ?> systemComponent : theSystem.getComponentRegistrations()) {
.unregisterComponent0(systemComponent.componentType());
changes.add( (ChangeType.UNREGISTERED, systemComponent.componentType()));
}
(ResourceRegistration<ECS_TYPE, ?> systemResource : theSystem.getResourceRegistrations()) {
.unregisterResource0(systemResource.resourceType());
changes.add( (ChangeType.UNREGISTERED, systemResource.resourceType()));
}
}
lock = .dataLock.tryConvertToReadLock(lock);
.updateData0((DataChange[])changes.toArray((x$ ) -> [x$ ]));
;
}
} {
.dataLock.unlock(lock);
}
}
}
ResourceType<ECS_TYPE, SpatialResource<Ref<ECS_TYPE>, ECS_TYPE>> {
.registerResource(SpatialResource.class, () -> ((SpatialStructure)supplier.get()));
}
Store<ECS_TYPE> {
( .shutdown) {
( );
} {
.addStore0(externalData, resourceStorage, (_store) -> {
});
}
}
Store<ECS_TYPE> {
( .shutdown) {
( );
} {
.addStore0(externalData, resourceStorage, consumer);
}
}
{
( .shutdown) {
( );
} (store.isShutdown()) {
( );
} {
.removeStore0(store);
}
}
Holder<ECS_TYPE> {
Holder<ECS_TYPE> holder = <ECS_TYPE>( );
.holders.add( (holder, .holderReferenceQueue));
holder;
}
Holder<ECS_TYPE> {
Holder<ECS_TYPE> holder = <ECS_TYPE>( , archetype, components);
.holders.add( (holder, .holderReferenceQueue));
holder;
}
Holder<ECS_TYPE> {
<ECS_TYPE>();
}
Data<ECS_TYPE> {
.data;
}
Data<ECS_TYPE> {
.assertInStoreThread();
.data;
}
BuilderCodec<Holder<ECS_TYPE>> {
.data.getEntityCodec();
}
{
.storeLock.readLock();
{
( ; i < .storeSize; ++i) {
( .stores[i].isInThread()) {
;
}
}
( );
} {
.storeLock.unlockRead(lock);
}
}
Holder<ECS_TYPE> {
Optional<Integer> version = VERSION.get(entityDocument);
(version.isPresent()) {
.deserialize(entityDocument, (Integer)version.get());
} {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
Holder<ECS_TYPE> holder = .data.getEntityCodec().decode(entityDocument, extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
holder;
}
}
Holder<ECS_TYPE> {
(version);
Holder<ECS_TYPE> holder = .data.getEntityCodec().decode(entityDocument, extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
holder;
}
BsonDocument {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
.data.getEntityCodec().encode(holder, extraInfo).asDocument();
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
document;
}
{
ArrayUtil.indexOf( .systems, system, , .systemSize) != - ;
}
<T <ECS_TYPE>> {
.systemClasses.containsKey(systemClass);
}
<T <ECS_TYPE>> {
.systemTypeClassToIndex.containsKey(systemType.getTypeClass());
}
{
ArrayUtil.indexOf( .systemGroups, group) != - ;
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
.registerComponent0(registration.typeClass(), registration.id(), registration.codec(), registration.supplier(), registration.componentType());
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
(id != && .componentIdToIndex.containsKey(id)) {
( + id + );
} {
index;
( .componentIndexReuse.isEmpty()) {
index = .componentSize++;
} {
index = .componentIndexReuse.nextSetBit( );
.componentIndexReuse.clear(index);
}
( .componentIds.length <= index) {
ArrayUtil.grow(index);
.componentIds = (String[])Arrays.copyOf( .componentIds, newLength);
.componentCodecs = (BuilderCodec[])Arrays.copyOf( .componentCodecs, newLength);
.componentSuppliers = (Supplier[])Arrays.copyOf( .componentSuppliers, newLength);
.componentTypes = (ComponentType[])Arrays.copyOf( .componentTypes, newLength);
}
componentType.init( , tClass, index);
.componentIdToIndex.put(id, index);
.componentIds[index] = id;
.componentCodecs[index] = codec;
.componentSuppliers[index] = supplier;
.componentTypes[index] = componentType;
componentType;
}
}
<T <ECS_TYPE>> {
componentType.getIndex();
(componentIndex == .componentSize - ) {
.componentIndexReuse.previousClearBit(componentIndex - );
.componentSize = highestUsedIndex + ;
.componentIndexReuse.clear( .componentSize, componentIndex);
} {
.componentIndexReuse.set(componentIndex);
}
.componentIdToIndex.removeInt( .componentIds[componentIndex]);
.componentIds[componentIndex] = ;
.componentCodecs[componentIndex] = ;
.componentSuppliers[componentIndex] = ;
.componentTypes[componentIndex] = ;
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
.registerResource0(registration.typeClass(), registration.id(), registration.codec(), registration.supplier(), registration.resourceType());
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
(id != && .resourceIdToIndex.containsKey(id)) {
( + id + );
} {
index;
( .resourceIndexReuse.isEmpty()) {
index = .resourceSize++;
} {
index = .resourceIndexReuse.nextSetBit( );
.resourceIndexReuse.clear(index);
}
( .resourceIds.length <= index) {
ArrayUtil.grow(index);
.resourceIds = (String[])Arrays.copyOf( .resourceIds, newLength);
.resourceCodecs = (BuilderCodec[])Arrays.copyOf( .resourceCodecs, newLength);
.resourceSuppliers = (Supplier[])Arrays.copyOf( .resourceSuppliers, newLength);
.resourceTypes = (ResourceType[])Arrays.copyOf( .resourceTypes, newLength);
}
resourceType.init( , tClass, index);
.resourceIdToIndex.put(id, index);
.resourceIds[index] = id;
.resourceCodecs[index] = codec;
.resourceSuppliers[index] = supplier;
.resourceTypes[index] = resourceType;
resourceType;
}
}
<T <ECS_TYPE>> {
resourceType.getIndex();
(resourceIndex == .resourceSize - ) {
.resourceIndexReuse.previousClearBit(resourceIndex - );
.resourceSize = highestUsedIndex + ;
.resourceIndexReuse.clear( .resourceSize, resourceIndex);
} {
.resourceIndexReuse.set(resourceIndex);
}
.resourceIdToIndex.removeInt( .resourceIds[resourceIndex]);
.resourceIds[resourceIndex] = ;
.resourceCodecs[resourceIndex] = ;
.resourceSuppliers[resourceIndex] = ;
.resourceTypes[resourceIndex] = ;
}
<T <ECS_TYPE>> SystemType<ECS_TYPE, T> {
( .systemTypeClassToIndex.containsKey(systemTypeClass)) {
( + String.valueOf(systemTypeClass) + );
} {
systemTypeIndex;
( .systemTypeIndexReuse.isEmpty()) {
systemTypeIndex = .systemTypeSize++;
} {
systemTypeIndex = .systemTypeIndexReuse.nextSetBit( );
.systemTypeIndexReuse.clear(systemTypeIndex);
}
( .systemTypes.length <= systemTypeIndex) {
.systemTypes = (SystemType[])Arrays.copyOf( .systemTypes, ArrayUtil.grow(systemTypeIndex));
.systemTypeToSystemIndex = (BitSet[])Arrays.copyOf( .systemTypeToSystemIndex, ArrayUtil.grow(systemTypeIndex));
}
SystemType<ECS_TYPE, T> systemType = <ECS_TYPE, T>( , systemTypeClass, systemTypeIndex);
.systemTypeClassToIndex.put(systemTypeClass, systemTypeIndex);
.systemTypes[systemTypeIndex] = systemType;
systemType;
}
}
<T <ECS_TYPE>> {
systemType.getIndex();
(systemTypeIndex == .systemTypeSize - ) {
.systemTypeIndexReuse.previousClearBit(systemTypeIndex - );
.systemTypeSize = highestUsedIndex + ;
.systemTypeIndexReuse.clear( .systemTypeSize, systemTypeIndex);
} {
.systemTypeIndexReuse.set(systemTypeIndex);
}
.systemTypeClassToIndex.removeInt(systemType.getTypeClass());
.systemTypes[systemTypeIndex] = ;
.systemTypeToSystemIndex[systemTypeIndex].clear();
}
<T > EntityEventType<ECS_TYPE, T> {
( .entityEventTypeClassToIndex.containsKey(eventTypeClass)) {
( + String.valueOf(eventTypeClass) + );
} {
systemTypeIndex;
( .systemTypeIndexReuse.isEmpty()) {
systemTypeIndex = .systemTypeSize++;
} {
systemTypeIndex = .systemTypeIndexReuse.nextSetBit( );
.systemTypeIndexReuse.clear(systemTypeIndex);
}
( .systemTypes.length <= systemTypeIndex) {
.systemTypes = (SystemType[])Arrays.copyOf( .systemTypes, ArrayUtil.grow(systemTypeIndex));
.systemTypeToSystemIndex = (BitSet[])Arrays.copyOf( .systemTypeToSystemIndex, ArrayUtil.grow(systemTypeIndex));
}
EntityEventType<ECS_TYPE, T> systemType = <ECS_TYPE, T>( , EntityEventSystem.class, eventTypeClass, systemTypeIndex);
.entityEventTypeClassToIndex.put(eventTypeClass, systemTypeIndex);
.systemTypes[systemTypeIndex] = systemType;
systemType;
}
}
<T > {
eventType.getIndex();
(systemTypeIndex == .systemTypeSize - ) {
.systemTypeIndexReuse.previousClearBit(systemTypeIndex - );
.systemTypeSize = highestUsedIndex + ;
.systemTypeIndexReuse.clear( .systemTypeSize, systemTypeIndex);
} {
.systemTypeIndexReuse.set(systemTypeIndex);
}
.entityEventTypeClassToIndex.removeInt(eventType.getEventClass());
.systemTypes[systemTypeIndex] = ;
.systemTypeToSystemIndex[systemTypeIndex].clear();
}
<T > EntityEventType<ECS_TYPE, T> {
.entityEventTypeClassToIndex.getInt(eClass);
index == - ? : (EntityEventType) .systemTypes[index];
}
<T > WorldEventType<ECS_TYPE, T> {
( .worldEventTypeClassToIndex.containsKey(eventTypeClass)) {
( + String.valueOf(eventTypeClass) + );
} {
systemTypeIndex;
( .systemTypeIndexReuse.isEmpty()) {
systemTypeIndex = .systemTypeSize++;
} {
systemTypeIndex = .systemTypeIndexReuse.nextSetBit( );
.systemTypeIndexReuse.clear(systemTypeIndex);
}
( .systemTypes.length <= systemTypeIndex) {
.systemTypes = (SystemType[])Arrays.copyOf( .systemTypes, ArrayUtil.grow(systemTypeIndex));
.systemTypeToSystemIndex = (BitSet[])Arrays.copyOf( .systemTypeToSystemIndex, ArrayUtil.grow(systemTypeIndex));
}
WorldEventType<ECS_TYPE, T> systemType = <ECS_TYPE, T>( , WorldEventSystem.class, eventTypeClass, systemTypeIndex);
.worldEventTypeClassToIndex.put(eventTypeClass, systemTypeIndex);
.systemTypes[systemTypeIndex] = systemType;
systemType;
}
}
<T > {
eventType.getIndex();
(systemTypeIndex == .systemTypeSize - ) {
.systemTypeIndexReuse.previousClearBit(systemTypeIndex - );
.systemTypeSize = highestUsedIndex + ;
.systemTypeIndexReuse.clear( .systemTypeSize, systemTypeIndex);
} {
.systemTypeIndexReuse.set(systemTypeIndex);
}
.worldEventTypeClassToIndex.removeInt(eventType.getEventClass());
.systemTypes[systemTypeIndex] = ;
.systemTypeToSystemIndex[systemTypeIndex].clear();
}
<T > WorldEventType<ECS_TYPE, T> {
.worldEventTypeClassToIndex.getInt(eClass);
index == - ? : (WorldEventType) .systemTypes[index];
}
SystemGroup<ECS_TYPE> {
systemGroupIndex;
( .systemGroupIndexReuse.isEmpty()) {
systemGroupIndex = .systemGroupSize++;
} {
systemGroupIndex = .systemGroupIndexReuse.nextSetBit( );
.systemGroupIndexReuse.clear(systemGroupIndex);
}
( .systemGroups.length <= systemGroupIndex) {
.systemGroups = (SystemGroup[])Arrays.copyOf( .systemGroups, ArrayUtil.grow(systemGroupIndex));
}
SystemGroup<ECS_TYPE> systemGroup = <ECS_TYPE>( , systemGroupIndex, dependencies);
.systemGroups[systemGroupIndex] = systemGroup;
systemGroup;
}
{
systemType.getIndex();
(systemGroupIndex == .systemGroupSize - ) {
.systemGroupIndexReuse.previousClearBit(systemGroupIndex - );
.systemGroupSize = highestUsedIndex + ;
.systemGroupIndexReuse.clear( .systemGroupSize, systemGroupIndex);
} {
.systemGroupIndexReuse.set(systemGroupIndex);
}
.systemGroups[systemGroupIndex] = ;
}
{
.systemSize++;
( .systems.length <= systemIndex) {
.systems = (ISystem[])Arrays.copyOf( .systems, ArrayUtil.grow(systemIndex));
}
.systems[systemIndex] = system;
.systemClasses.put(system.getClass(), systemIndex);
system.onSystemRegistered();
}
{
.systemSize - ;
(systemIndex != lastIndex) {
ISystem<ECS_TYPE> lastSystem = .systems[lastIndex];
.systems[systemIndex] = lastSystem;
.systemClasses.put(lastSystem.getClass(), systemIndex);
}
.systems[lastIndex] = ;
.systemSize = lastIndex;
Class<? > systemClass = system.getClass();
.systemBypassClassCheck.getBoolean(systemClass);
(!bypassClassCheck && ! .systemClasses.remove(systemClass, systemIndex)) {
systemClass.getName();
( + var10002 + + systemIndex);
} {
system.onSystemUnregistered();
}
}
Store<ECS_TYPE> {
.storeLock.writeLock();
Store var8;
{
.storeSize++;
( .stores.length <= storeIndex) {
.stores = (Store[])Arrays.copyOf( .stores, ArrayUtil.grow(storeIndex));
}
Store<ECS_TYPE> store = <ECS_TYPE>( , storeIndex, externalData, resourceStorage);
.stores[storeIndex] = store;
consumer.accept(store);
store.onAdd( .data);
var8 = store;
} {
.storeLock.unlockWrite(lock);
}
var8;
}
{
store.shutdown0( .data);
lock;
{
Thread.onSpinWait();
.doDataUpdate();
lock = .storeLock.tryWriteLock();
} (! .storeLock.validate(lock));
{
store.storeIndex;
.storeSize - ;
(storeIndex != lastIndex) {
Store<ECS_TYPE> lastStore = .stores[lastIndex];
lastStore.storeIndex = storeIndex;
.stores[storeIndex] = lastStore;
}
.stores[lastIndex] = ;
.storeSize = lastIndex;
} {
.storeLock.unlockWrite(lock);
}
}
Data<ECS_TYPE> {
.data;
}
{
;
;
(DataChange dataChange : dataChanges) {
(dataChange SystemChange) {
systemChanged = ;
}
(dataChange SystemTypeChange) {
systemTypeChanged = ;
}
}
(systemChanged) {
( .sortedSystems.length < .systems.length) {
.sortedSystems = (ISystem[])Arrays.copyOf( .systems, .systems.length);
} {
java.lang.System.arraycopy( .systems, , .sortedSystems, , .systems.length);
}
ISystem.calculateOrder( , .sortedSystems, .systemSize);
}
(systemChanged || systemTypeChanged) {
( ; systemTypeIndex < .systemTypeSize; ++systemTypeIndex) {
SystemType<ECS_TYPE, ? <ECS_TYPE>> systemType = .systemTypes[systemTypeIndex];
(systemType != ) {
.systemTypeToSystemIndex[systemTypeIndex] = ();
( ; systemIndex < .systemSize; ++systemIndex) {
(systemType.isType( .sortedSystems[systemIndex])) {
bitSet.set(systemIndex);
}
}
}
}
}
.storeLock.readLock();
.dataUpdateLock.writeLock().lock();
{
Data<ECS_TYPE> oldData = .data;
.data = <ECS_TYPE>(oldData.getVersion() + , , dataChanges);
( ; i < .storeSize; ++i) {
.stores[i].updateData(oldData, .data);
}
(Reference<Holder<ECS_TYPE>> holderReference : .holders) {
Holder<ECS_TYPE> holder = (Holder)holderReference.get();
(holder != ) {
holder.updateData(oldData, .data);
}
}
} {
.dataUpdateLock.writeLock().unlock();
.storeLock.unlockRead(lock);
}
}
String {
String.valueOf( .getClass());
+ var10000 + + .hashCode() + + .shutdown + + String.valueOf( .dataLock) + + String.valueOf( .componentIdToIndex) + + String.valueOf( .componentIndexReuse) + + .componentSize + + Arrays.toString( .componentIds) + + Arrays.toString( .componentCodecs) + + Arrays.toString( .componentSuppliers) + + Arrays.toString( .componentTypes) + + String.valueOf( .resourceIndexReuse) + + .resourceSize + + Arrays.toString( .resourceIds) + + Arrays.toString( .resourceCodecs) + + Arrays.toString( .resourceSuppliers) + + Arrays.toString( .resourceTypes) + + .systemSize + + Arrays.toString( .systems) + + Arrays.toString( .sortedSystems) + + String.valueOf( .storeLock) + + .storeSize + + Arrays.toString( .stores) + + String.valueOf( .data) + ;
}
<T <ECS_TYPE>> T {
.dataLock.readLock();
Component var4;
{
var4 = .data.createComponent(componentType);
} {
.dataLock.unlockRead(lock);
}
(T)var4;
}
{
VERSION = <Integer>( , Codec.INTEGER);
REFERENCE_THREAD_COUNTER = ();
}
<ECS_TYPE> {
version;
ComponentRegistry<ECS_TYPE> registry;
Object2IntMap<String> componentIdToIndex;
componentSize;
String[] componentIds;
BuilderCodec<? <ECS_TYPE>>[] componentCodecs;
Supplier<? <ECS_TYPE>>[] componentSuppliers;
ComponentType<ECS_TYPE, ? <ECS_TYPE>>[] componentTypes;
Object2IntMap<String> resourceIdToIndex;
resourceSize;
String[] resourceIds;
BuilderCodec<? <ECS_TYPE>>[] resourceCodecs;
Supplier<? <ECS_TYPE>>[] resourceSuppliers;
ResourceType<ECS_TYPE, ? <ECS_TYPE>>[] resourceTypes;
Object2IntMap<Class<? <ECS_TYPE>>> systemTypeClassToIndex;
systemTypeSize;
SystemType<ECS_TYPE, ? <ECS_TYPE>>[] systemTypes;
BitSet[] systemTypeToSystemIndex;
systemSize;
ISystem<ECS_TYPE>[] sortedSystems;
Map<String, Codec<Component<ECS_TYPE>>> codecMap;
BuilderCodec<Holder<ECS_TYPE>> entityCodec;
DataChange[] dataChanges;
{
.version = ;
.registry = registry;
.componentIdToIndex = Object2IntMaps.<String>emptyMap();
.componentSize = ;
.componentIds = ArrayUtil.EMPTY_STRING_ARRAY;
.componentCodecs = BuilderCodec.EMPTY_ARRAY;
.componentSuppliers = ArrayUtil.<Component<ECS_TYPE>>emptySupplierArray();
.componentTypes = ComponentType.EMPTY_ARRAY;
.resourceIdToIndex = Object2IntMaps.<String>emptyMap();
.resourceSize = ;
.resourceIds = ArrayUtil.EMPTY_STRING_ARRAY;
.resourceCodecs = BuilderCodec.EMPTY_ARRAY;
.resourceSuppliers = ArrayUtil.<Resource<ECS_TYPE>>emptySupplierArray();
.resourceTypes = ResourceType.EMPTY_ARRAY;
.systemTypeClassToIndex = Object2IntMaps.<Class<? <ECS_TYPE>>>emptyMap();
.systemTypeSize = ;
.systemTypes = SystemType.EMPTY_ARRAY;
.systemTypeToSystemIndex = ArrayUtil.EMPTY_BITSET_ARRAY;
.systemSize = ;
.sortedSystems = ISystem.EMPTY_ARRAY;
.codecMap = Collections.emptyMap();
.entityCodec = .createCodec();
.dataChanges = ;
}
{
.version = version;
.registry = registry;
.componentIdToIndex = <String>(registry.componentIdToIndex);
.componentIdToIndex.defaultReturnValue(- );
.componentSize = registry.componentSize;
.componentIds = (String[])Arrays.copyOf(registry.componentIds, .componentSize);
.componentCodecs = (BuilderCodec[])Arrays.copyOf(registry.componentCodecs, .componentSize);
.componentSuppliers = (Supplier[])Arrays.copyOf(registry.componentSuppliers, .componentSize);
.componentTypes = (ComponentType[])Arrays.copyOf(registry.componentTypes, .componentSize);
.resourceIdToIndex = <String>(registry.resourceIdToIndex);
.resourceIdToIndex.defaultReturnValue(- );
.resourceSize = registry.resourceSize;
.resourceIds = (String[])Arrays.copyOf(registry.resourceIds, .resourceSize);
.resourceCodecs = (BuilderCodec[])Arrays.copyOf(registry.resourceCodecs, .resourceSize);
.resourceSuppliers = (Supplier[])Arrays.copyOf(registry.resourceSuppliers, .resourceSize);
.resourceTypes = (ResourceType[])Arrays.copyOf(registry.resourceTypes, .resourceSize);
.systemTypeClassToIndex = <Class<? <ECS_TYPE>>>(registry.systemTypeClassToIndex);
.systemTypeClassToIndex.defaultReturnValue(- );
.systemTypeSize = registry.systemTypeSize;
.systemTypes = (SystemType[])Arrays.copyOf(registry.systemTypes, .systemTypeSize);
.systemTypeToSystemIndex = (BitSet[])Arrays.copyOf(registry.systemTypeToSystemIndex, .systemTypeSize);
.systemSize = registry.systemSize;
.sortedSystems = (ISystem[])Arrays.copyOf(registry.sortedSystems, .systemSize);
Object2ObjectOpenHashMap<String, Codec<Component<ECS_TYPE>>> codecMap = <String, Codec<Component<ECS_TYPE>>>( .componentSize);
( ; i < .componentSize; ++i) {
( .componentCodecs[i] != ) {
codecMap.put( .componentIds[i], .componentCodecs[i]);
}
}
.codecMap = codecMap;
.entityCodec = .createCodec();
.dataChanges = dataChanges;
}
BuilderCodec<Holder<ECS_TYPE>> {
Function<Codec<Component<ECS_TYPE>>, Codec<Component<ECS_TYPE>>> function = (componentCodec) -> componentCodec != ? componentCodec : TempUnknownComponent.COMPONENT_CODEC;
.registry;
Objects.requireNonNull(var10001);
BuilderCodec.builder(Holder.class, var10001::newHolder).append( ( , ( .codecMap, function, LinkedHashMap:: , )), (holder, map) -> holder.loadComponentsMap( , map), (holder) -> holder.createComponentsMap( )).add().build();
}
{
.version;
}
ComponentRegistry<ECS_TYPE> {
.registry;
}
ComponentType<ECS_TYPE, ?> getComponentType(String id) {
.componentIdToIndex.getInt(id);
index == - ? : .componentTypes[index];
}
{
.componentSize;
}
String {
.componentIds[componentType.getIndex()];
}
<T <ECS_TYPE>> Codec<T> {
.componentCodecs[componentType.getIndex()];
}
<T <ECS_TYPE>> T {
componentType.validateRegistry( .registry);
componentType.validate();
(T)( .componentSuppliers[componentType.getIndex()].get());
}
ResourceType<ECS_TYPE, ?> getResourceType( index) {
.resourceTypes[index];
}
ResourceType<ECS_TYPE, ?> getResourceType(String id) {
.resourceIdToIndex.getInt(id);
index == - ? : .resourceTypes[index];
}
{
.resourceSize;
}
String {
.resourceIds[resourceType.getIndex()];
}
<T <ECS_TYPE>> BuilderCodec<T> {
.resourceCodecs[resourceType.getIndex()];
}
<T <ECS_TYPE>> T {
resourceType.validateRegistry( .registry);
resourceType.validate();
(T)( .resourceSuppliers[resourceType.getIndex()].get());
}
{
.systemTypeSize;
}
<T <ECS_TYPE>> SystemType<ECS_TYPE, T> {
.systemTypeClassToIndex.getInt(systemTypeClass);
systemTypeClassToIndexInt == - ? : .systemTypes[systemTypeClassToIndexInt];
}
SystemType<ECS_TYPE, ? <ECS_TYPE>> getSystemType( systemTypeIndex) {
.systemTypes[systemTypeIndex];
}
<T <ECS_TYPE>> BitSet {
.systemTypeToSystemIndex[systemType.getIndex()];
}
{
.systemSize;
}
ISystem<ECS_TYPE> {
.sortedSystems[systemIndex];
}
<T <ECS_TYPE>> T {
(T) .sortedSystems[systemIndex];
}
{
- ;
( ; i < .sortedSystems.length; ++i) {
( .sortedSystems[i] == system) {
systemIndex = i;
;
}
}
systemIndex;
}
BuilderCodec<Holder<ECS_TYPE>> {
.entityCodec;
}
{
.dataChanges.length;
}
DataChange {
.dataChanges[index];
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
Data<?> data = (Data)o;
.version == data.version;
} {
;
}
}
{
.version;
}
String {
.version;
+ var10000 + + .componentSize + + Arrays.toString( .componentSuppliers) + + .resourceSize + + Arrays.toString( .resourceSuppliers) + + .systemSize + + Arrays.toString( .sortedSystems) + + Arrays.toString( .dataChanges) + ;
}
{
sb.append(prefix).append( ).append( .version).append( );
sb.append(prefix).append( ).append( .componentSize).append( );
sb.append(prefix).append( ).append( );
( ; i < .componentSize; ++i) {
sb.append(prefix).append( ).append(i).append( ).append( .componentSuppliers[i]).append( );
}
sb.append(prefix).append( ).append( );
( ; i < .resourceSize; ++i) {
sb.append(prefix).append( ).append(i).append( ).append( .resourceSuppliers[i]).append( );
}
sb.append(prefix).append( ).append( .systemSize).append( );
sb.append(prefix).append( ).append( );
( ; i < .systemSize; ++i) {
sb.append(prefix).append( ).append(i).append( ).append( .sortedSystems[i]).append( );
}
sb.append(prefix).append( ).append( );
( ; i < .dataChanges.length; ++i) {
sb.append(prefix).append( ).append(i).append( ).append( .dataChanges[i]).append( );
}
}
}
}
com/hypixel/hytale/component/ComponentRegistryProxy.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.event.EntityEventType;
import com.hypixel.hytale.component.event.WorldEventType;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.component.spatial.SpatialStructure;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.ISystem;
import com.hypixel.hytale.function.consumer.BooleanConsumer;
import java.util.List;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public class ComponentRegistryProxy <ECS_TYPE> implements IComponentRegistry <ECS_TYPE> {
private final ComponentRegistry<ECS_TYPE> registry;
private final List<BooleanConsumer> unregister;
public ComponentRegistryProxy (List<BooleanConsumer> registrations, ComponentRegistry<ECS_TYPE> registry) {
this .unregister = registrations;
this .registry = registry;
}
public void shutdown () {
}
@Nonnull
public <T extends Component <ECS_TYPE>> ComponentType<ECS_TYPE, T> registerComponent (@Nonnull Class<? super T> tClass, Supplier<T> supplier) {
.registerComponentType( .registry.registerComponent(tClass, supplier));
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
.registerComponentType( .registry.registerComponent(tClass, id, codec));
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
.registerComponentType( .registry.registerComponent(tClass, id, codec, skipValidation));
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
.registerResourceType( .registry.registerResource(tClass, supplier));
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
.registerResourceType( .registry.registerResource(tClass, id, codec));
}
ResourceType<ECS_TYPE, SpatialResource<Ref<ECS_TYPE>, ECS_TYPE>> {
.registerResourceType( .registry.registerSpatialResource(supplier));
}
<T <ECS_TYPE>> SystemType<ECS_TYPE, T> {
.registerSystemType( .registry.registerSystemType(systemTypeClass));
}
<T > EntityEventType<ECS_TYPE, T> {
.registerEntityEventType( .registry.registerEntityEventType(eventTypeClass));
}
<T > WorldEventType<ECS_TYPE, T> {
.registerWorldEventType( .registry.registerWorldEventType(eventTypeClass));
}
SystemGroup<ECS_TYPE> {
.registerSystemGroup( .registry.registerSystemGroup());
}
{
Class<? <ECS_TYPE>> systemClass = system.getClass();
.registry.registerSystem(system);
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
( .registry.hasSystemClass(systemClass)) {
.registry.unregisterSystem(systemClass);
}
}
});
}
{
Class<? <ECS_TYPE>> systemClass = system.getClass();
.registry.registerSystem(system, bypassClassCheck);
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
( .registry.hasSystemClass(systemClass)) {
.registry.unregisterSystem(systemClass);
}
}
});
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
(componentType.isValid()) {
.registry.unregisterComponent(componentType);
}
}
});
componentType;
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
(componentType.isValid()) {
.registry.unregisterResource(componentType);
}
}
});
componentType;
}
<T <ECS_TYPE>> SystemType<ECS_TYPE, T> {
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
(systemType.isValid()) {
.registry.unregisterSystemType(systemType);
}
}
});
systemType;
}
<T > EntityEventType<ECS_TYPE, T> {
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
(eventType.isValid()) {
.registry.unregisterEntityEventType(eventType);
}
}
});
eventType;
}
<T > WorldEventType<ECS_TYPE, T> {
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
(eventType.isValid()) {
.registry.unregisterWorldEventType(eventType);
}
}
});
eventType;
}
SystemGroup<ECS_TYPE> {
.unregister.add((BooleanConsumer)(shutdown) -> {
(!shutdown) {
(systemGroup.isValid()) {
.registry.unregisterSystemGroup(systemGroup);
}
}
});
systemGroup;
}
}
com/hypixel/hytale/component/ComponentType.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.query.Query;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ComponentType <ECS_TYPE, T extends Component <ECS_TYPE>> implements Comparable <ComponentType<ECS_TYPE, ?>>, Query<ECS_TYPE> {
@Nonnull
public static final ComponentType[] EMPTY_ARRAY = new ComponentType [0 ];
private ComponentRegistry<ECS_TYPE> registry;
private Class<? super T> tClass;
private int index;
private boolean invalid = true ;
public ComponentType () {
}
void init (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super T> tClass, int index) {
this .registry = registry;
this .tClass = tClass;
this .index = index;
this .invalid = false ;
}
@Nonnull
public ComponentRegistry<ECS_TYPE> {
.registry;
}
Class<? T> getTypeClass() {
.tClass;
}
{
.index;
}
{
.invalid = ;
}
{
! .invalid;
}
{
archetype.contains( );
}
{
.equals(componentType);
}
{
(! .registry.equals(registry)) {
( + String.valueOf( ));
}
}
{
( .invalid) {
( );
}
}
{
Integer.compare( .index, o.index);
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
ComponentType<?, ?> that = (ComponentType)o;
.index != that.index ? : .registry.equals(that.registry);
} {
;
}
}
{
.registry.hashCode();
result = * result + .index;
result;
}
String {
String.valueOf( .registry.getClass());
+ var10000 + + .registry.hashCode() + + String.valueOf( .tClass) + + .index + ;
}
}
com/hypixel/hytale/component/DisableProcessingAssert.java
package com.hypixel.hytale.component;
@Deprecated(
forRemoval = true
)
public interface DisableProcessingAssert {
}
com/hypixel/hytale/component/EmptyResourceStorage.java
package com.hypixel.hytale.component;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class EmptyResourceStorage implements IResourceStorage {
private static final EmptyResourceStorage INSTANCE = new EmptyResourceStorage ();
public EmptyResourceStorage () {
}
public static EmptyResourceStorage get () {
return INSTANCE;
}
@Nonnull
public <T extends Resource <ECS_TYPE>, ECS_TYPE> CompletableFuture<T> load (@Nonnull Store<ECS_TYPE> store, @Nonnull ComponentRegistry.Data<ECS_TYPE> data, @Nonnull ResourceType<ECS_TYPE, T> resourceType) {
return CompletableFuture.completedFuture(data.createResource(resourceType));
}
@Nonnull
public <T extends Resource <ECS_TYPE>, ECS_TYPE> CompletableFuture<Void> save (@Nonnull Store<ECS_TYPE> store, @Nonnull ComponentRegistry.Data<ECS_TYPE> data, @Nonnull ResourceType<ECS_TYPE, T> resourceType, T resource) {
CompletableFuture.completedFuture((Object) );
}
<T <ECS_TYPE>, ECS_TYPE> CompletableFuture<Void> {
CompletableFuture.completedFuture((Object) );
}
}
com/hypixel/hytale/component/Holder.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.component.data.change.ComponentChange;
import com.hypixel.hytale.component.data.change.DataChange;
import com.hypixel.hytale.component.data.unknown.TempUnknownComponent;
import com.hypixel.hytale.component.data.unknown.UnknownComponents;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.locks.StampedLock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public class Holder <ECS_TYPE> {
private static final Holder<?>[] EMPTY_ARRAY = new Holder [0 ];
@Nullable
private final ComponentRegistry<ECS_TYPE> registry;
private final StampedLock lock = new StampedLock ();
@Nullable
private Archetype<ECS_TYPE> archetype;
@Nullable
private Component<ECS_TYPE>[] components;
;
<T> Holder<T>[] emptyArray() {
EMPTY_ARRAY;
}
Holder() {
.registry = ;
}
Holder( ComponentRegistry<ECS_TYPE> registry) {
.registry = registry;
.archetype = Archetype.<ECS_TYPE>empty();
.components = Component.EMPTY_ARRAY;
}
Holder( ComponentRegistry<ECS_TYPE> registry, Archetype<ECS_TYPE> archetype, Component<ECS_TYPE>[] components) {
.registry = registry;
.init(archetype, components);
}
Component<ECS_TYPE>[] ensureComponentsSize( size) {
.lock.writeLock();
Component[] var4;
{
( .components != ) {
( .components.length < size) {
.components = (Component[])Arrays.copyOf( .components, size);
}
var4 = .components;
var4;
}
.components = [size];
var4 = .components;
} {
.lock.unlockWrite(stamp);
}
var4;
}
{
archetype.validate();
archetype.validateComponents(components, (ComponentType) );
.lock.writeLock();
{
.archetype = archetype;
.components = components;
.ensureValidComponents = ;
} {
.lock.unlockWrite(stamp);
}
}
{
archetype.validateComponents(components, unknownComponentType);
.lock.writeLock();
{
.archetype = archetype;
.components = components;
.ensureValidComponents = ;
} {
.lock.unlockWrite(stamp);
}
}
Archetype<ECS_TYPE> {
.archetype;
}
<T <ECS_TYPE>> {
.archetype != ;
.registry != ;
( .ensureValidComponents) {
componentType.validate();
}
.lock.writeLock();
{
(! .archetype.contains(componentType)) {
.registry.createComponent(componentType);
.addComponent0(componentType, component);
;
}
} {
.lock.unlockWrite(stamp);
}
}
<T <ECS_TYPE>> T {
.ensureComponent(componentType);
(T) .getComponent(componentType);
}
<T <ECS_TYPE>> {
.archetype != ;
.lock.writeLock();
{
( .ensureValidComponents) {
componentType.validate();
}
( .archetype.contains(componentType)) {
( + String.valueOf(componentType));
}
.addComponent0(componentType, component);
} {
.lock.unlockWrite(stamp);
}
}
<T <ECS_TYPE>> {
.archetype != ;
.components != ;
.archetype = Archetype.add( .archetype, componentType);
.archetype.length();
( .components.length < newLength) {
.components = (Component[])Arrays.copyOf( .components, newLength);
}
.components[componentType.getIndex()] = component;
}
<T <ECS_TYPE>> {
.archetype != ;
.components != ;
.lock.writeLock();
{
( .ensureValidComponents) {
componentType.validate();
}
.archetype.validateComponentType(componentType);
.components[componentType.getIndex()] = component;
} {
.lock.unlockWrite(stamp);
}
}
<T <ECS_TYPE>> {
( .getComponent(componentType) != ) {
.replaceComponent(componentType, component);
} {
.addComponent(componentType, component);
}
}
<T <ECS_TYPE>> T {
.archetype != ;
.components != ;
.lock.readLock();
Component var4;
{
( .ensureValidComponents) {
componentType.validate();
}
( .archetype.contains(componentType)) {
var4 = .components[componentType.getIndex()];
(T)var4;
}
var4 = ;
} {
.lock.unlockRead(stamp);
}
(T)var4;
}
<T <ECS_TYPE>> {
.archetype != ;
.components != ;
.lock.writeLock();
{
( .ensureValidComponents) {
componentType.validate();
}
.archetype.validateComponentType(componentType);
.archetype = Archetype.remove( .archetype, componentType);
.components[componentType.getIndex()] = ;
} {
.lock.unlockWrite(stamp);
}
}
<T <ECS_TYPE>> {
( .getComponent(componentType) == ) {
;
} {
.removeComponent(componentType);
;
}
}
{
.archetype != ;
.archetype.hasSerializableComponents(data);
}
{
.archetype != ;
.components != ;
.registry != ;
.lock.writeLock();
{
(! .archetype.isEmpty()) {
ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> unknownComponentType = .registry.getUnknownComponentType();
( ; i < newData.getDataChangeCount(); ++i) {
newData.getDataChange(i);
(dataChange ComponentChange) {
ComponentChange<ECS_TYPE, ? <ECS_TYPE>> componentChange = (ComponentChange)dataChange;
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = componentChange.getComponentType();
(componentChange.getType()) {
REGISTERED:
.archetype != ;
(! .archetype.contains(componentType) && .archetype.contains(unknownComponentType)) {
newData.getComponentId(componentType);
Codec<Component<ECS_TYPE>> componentCodec = newData.<Component<ECS_TYPE>>getComponentCodec(componentType);
(componentCodec != ) {
UnknownComponents<ECS_TYPE> unknownComponents = (UnknownComponents) .components[unknownComponentType.getIndex()];
unknownComponents != ;
Component<ECS_TYPE> component = unknownComponents.removeComponent(componentId, componentCodec);
(component != ) {
.addComponent0(componentType, component);
}
}
}
;
UNREGISTERED:
.archetype != ;
( .archetype.contains(componentType)) {
oldData.getComponentId(componentType);
Codec<Component<ECS_TYPE>> componentCodec = oldData.<Component<ECS_TYPE>>getComponentCodec(componentType);
(componentCodec != ) {
UnknownComponents<ECS_TYPE> unknownComponents;
( .archetype.contains(unknownComponentType)) {
unknownComponents = (UnknownComponents) .components[unknownComponentType.getIndex()];
unknownComponents != ;
} {
unknownComponents = <ECS_TYPE>();
.addComponent0(unknownComponentType, unknownComponents);
}
Component<ECS_TYPE> component = .components[componentType.getIndex()];
unknownComponents.addComponent(componentId, component, componentCodec);
}
.archetype = Archetype.remove( .archetype, componentType);
.components[componentType.getIndex()] = ;
}
}
}
}
;
}
} {
.lock.unlockWrite(stamp);
}
}
Holder<ECS_TYPE> {
.archetype != ;
.components != ;
.registry != ;
.lock.readLock();
Holder var9;
{
Component<ECS_TYPE>[] componentsClone = [ .components.length];
( ; i < .components.length; ++i) {
Component<ECS_TYPE> component = .components[i];
(component != ) {
componentsClone[i] = component.clone();
}
}
var9 = .registry.newHolder( .archetype, componentsClone);
} {
.lock.unlockRead(stamp);
}
var9;
}
Holder<ECS_TYPE> {
.archetype != ;
.components != ;
.registry != ;
.lock.readLock();
Holder var11;
{
Archetype<ECS_TYPE> serializableArchetype = .archetype.getSerializableArchetype(data);
Component<ECS_TYPE>[] componentsClone = [serializableArchetype.length()];
( serializableArchetype.getMinIndex(); i < serializableArchetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = serializableArchetype.get(i);
(componentType != ) {
componentsClone[i] = .components[i].cloneSerializable();
}
}
var11 = .registry.newHolder(serializableArchetype, componentsClone);
} {
.lock.unlockRead(stamp);
}
var11;
}
{
.components != ;
.lock.writeLock();
{
ComponentType<ECS_TYPE, ?>[] componentTypes = [map.size()];
;
ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> unknownComponentType = data.getRegistry().getUnknownComponentType();
UnknownComponents<ECS_TYPE> unknownComponents = (UnknownComponents)map.remove( );
(unknownComponents != ) {
(Map.Entry<String, BsonDocument> e : unknownComponents.getUnknownComponents().entrySet()) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> type = data.getComponentType((String)e.getKey());
(type != && !map.containsKey(e.getKey())) {
Codec<Component<ECS_TYPE>> codec = data.<Component<ECS_TYPE>>getComponentCodec(type);
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
Component<ECS_TYPE> decodedComponent = codec.decode((BsonValue)e.getValue(), extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions(UnknownComponents.LOGGER);
(componentTypes.length <= i) {
componentTypes = (ComponentType[])Arrays.copyOf(componentTypes, i + );
}
componentTypes[i++] = type;
type.getIndex();
( .components.length <= index) {
.components = (Component[])Arrays.copyOf( .components, index + );
}
.components[index] = decodedComponent;
}
}
(componentTypes.length <= i) {
componentTypes = (ComponentType[])Arrays.copyOf(componentTypes, i + );
}
componentTypes[i++] = unknownComponentType;
unknownComponentType.getIndex();
( .components.length <= index) {
.components = (Component[])Arrays.copyOf( .components, index + );
}
.components[index] = unknownComponents;
}
(Map.Entry<String, Component<ECS_TYPE>> entry : map.entrySet()) {
Component<ECS_TYPE> component = (Component)entry.getValue();
(component TempUnknownComponent) {
(TempUnknownComponent)component;
(unknownComponents == ) {
unknownComponents = <ECS_TYPE>();
(componentTypes.length <= i) {
componentTypes = (ComponentType[])Arrays.copyOf(componentTypes, i + );
}
componentTypes[i++] = unknownComponentType;
unknownComponentType.getIndex();
( .components.length <= index) {
.components = (Component[])Arrays.copyOf( .components, index + );
}
.components[index] = unknownComponents;
}
unknownComponents.addComponent((String)entry.getKey(), tempUnknownComponent);
} {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = data.getComponentType((String)entry.getKey());
(componentTypes.length <= i) {
componentTypes = (ComponentType[])Arrays.copyOf(componentTypes, i + );
}
componentTypes[i++] = componentType;
componentType.getIndex();
( .components.length <= index) {
.components = (Component[])Arrays.copyOf( .components, index + );
}
.components[index] = component;
}
}
.archetype = Archetype.of(componentTypes.length == i ? componentTypes : (ComponentType[])Arrays.copyOf(componentTypes, i));
} {
.lock.unlockWrite(stamp);
}
}
Map<String, Component<ECS_TYPE>> {
.archetype != ;
.components != ;
.lock.readLock();
Map var4;
{
(! .archetype.isEmpty()) {
ComponentRegistry<ECS_TYPE> registry = data.getRegistry();
ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> unknownComponentType = registry.getUnknownComponentType();
Map<String, Component<ECS_TYPE>> map = <String, Component<ECS_TYPE>>( .archetype.length());
( .archetype.getMinIndex(); i < .archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = .archetype.get(i);
(componentType != && data.getComponentCodec(componentType) != ) {
(componentType == unknownComponentType) {
UnknownComponents<ECS_TYPE> unknownComponents = (UnknownComponents) .components[componentType.getIndex()];
(Map.Entry<String, BsonDocument> entry : unknownComponents.getUnknownComponents().entrySet()) {
map.putIfAbsent((String)entry.getKey(), ((BsonDocument)entry.getValue()));
}
} {
map.put(data.getComponentId(componentType), .components[componentType.getIndex()]);
}
}
}
map;
(Map<String, Component<ECS_TYPE>>)var16;
}
var4 = Collections.emptyMap();
} {
.lock.unlockRead(stamp);
}
var4;
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
Holder<?> that = (Holder)o;
.lock.readLock();
that.lock.readLock();
var7;
{
(Objects.equals( .archetype, that.archetype)) {
var7 = Arrays.equals( .components, that.components);
var7;
}
var7 = ;
} {
that.lock.unlockRead(thatStamp);
.lock.unlockRead(stamp);
}
var7;
} {
;
}
}
{
.lock.readLock();
var4;
{
.archetype != ? .archetype.hashCode() : ;
result = * result + Arrays.hashCode( .components);
var4 = result;
} {
.lock.unlockRead(stamp);
}
var4;
}
String {
.lock.readLock();
String var3;
{
String.valueOf( .archetype);
var3 = + var10000 + + Arrays.toString( .components) + ;
} {
.lock.unlockRead(stamp);
}
var3;
}
}
com/hypixel/hytale/component/IComponentRegistry.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.event.EntityEventType;
import com.hypixel.hytale.component.event.WorldEventType;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.component.spatial.SpatialStructure;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.ISystem;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public interface IComponentRegistry <ECS_TYPE> {
@Nonnull
<T extends Component <ECS_TYPE>> ComponentType<ECS_TYPE, T> registerComponent (@Nonnull Class<? super T> var1, @Nonnull Supplier<T> var2) ;
@Nonnull
<T extends Component <ECS_TYPE>> ComponentType<ECS_TYPE, T> registerComponent (@Nonnull Class<? super T> var1, @Nonnull String var2, @Nonnull BuilderCodec<T> var3) ;
@Nonnull
<T extends Resource <ECS_TYPE>> ResourceType<ECS_TYPE, T> registerResource (@Nonnull Class<? super T> var1, @Nonnull Supplier<T> var2) ;
@Nonnull
<T extends Resource <ECS_TYPE>> ResourceType<ECS_TYPE, T> ;
<T <ECS_TYPE>> SystemType<ECS_TYPE, T> ;
<T > EntityEventType<ECS_TYPE, T> ;
<T > WorldEventType<ECS_TYPE, T> ;
SystemGroup<ECS_TYPE> ;
;
ResourceType<ECS_TYPE, SpatialResource<Ref<ECS_TYPE>, ECS_TYPE>> ;
}
com/hypixel/hytale/component/IResourceStorage.java
package com.hypixel.hytale.component;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public interface IResourceStorage {
@Nonnull
<T extends Resource <ECS_TYPE>, ECS_TYPE> CompletableFuture<T> load (@Nonnull Store<ECS_TYPE> var1, @Nonnull ComponentRegistry.Data<ECS_TYPE> var2, @Nonnull ResourceType<ECS_TYPE, T> var3) ;
@Nonnull
<T extends Resource <ECS_TYPE>, ECS_TYPE> CompletableFuture<Void> save (@Nonnull Store<ECS_TYPE> var1, @Nonnull ComponentRegistry.Data<ECS_TYPE> var2, @Nonnull ResourceType<ECS_TYPE, T> var3, T var4) ;
@Nonnull
<T extends Resource <ECS_TYPE>, ECS_TYPE> CompletableFuture<Void> remove (@Nonnull Store<ECS_TYPE> var1, @Nonnull ComponentRegistry.Data<ECS_TYPE> var2, @Nonnull ResourceType<ECS_TYPE, T> var3) ;
}
com/hypixel/hytale/component/NonSerialized.java
package com.hypixel.hytale.component;
public class NonSerialized <ECS_TYPE> implements Component <ECS_TYPE> {
private static final NonSerialized<?> INSTANCE = new NonSerialized ();
public NonSerialized () {
}
public static <ECS_TYPE> NonSerialized<ECS_TYPE> get () {
return INSTANCE;
}
public Component<ECS_TYPE> clone () {
return get();
}
}
com/hypixel/hytale/component/NonTicking.java
package com.hypixel.hytale.component;
public class NonTicking <ECS_TYPE> implements Component <ECS_TYPE> {
private static final NonTicking<?> INSTANCE = new NonTicking ();
public NonTicking () {
}
public static <ECS_TYPE> NonTicking<ECS_TYPE> get () {
return INSTANCE;
}
public Component<ECS_TYPE> clone () {
return get();
}
}
com/hypixel/hytale/component/ReadWriteQuery.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.query.ReadWriteArchetypeQuery;
public class ReadWriteQuery <ECS_TYPE> implements ReadWriteArchetypeQuery <ECS_TYPE> {
private final Archetype<ECS_TYPE> read;
private final Archetype<ECS_TYPE> write;
public ReadWriteQuery (Archetype<ECS_TYPE> read, Archetype<ECS_TYPE> write) {
this .read = read;
this .write = write;
}
public Archetype<ECS_TYPE> getReadArchetype () {
return this .read;
}
public Archetype<ECS_TYPE> getWriteArchetype () {
return this .write;
}
}
com/hypixel/hytale/component/Ref.java
package com.hypixel.hytale.component;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class Ref <ECS_TYPE> {
public static final Ref<?>[] EMPTY_ARRAY = new Ref [0 ];
@Nonnull
private final Store<ECS_TYPE> store;
private volatile int index;
private transient volatile int hashCode;
private volatile Throwable invalidatedBy;
public Ref (@Nonnull Store<ECS_TYPE> store) {
this (store, -2147483648 );
}
public Ref (@Nonnull Store<ECS_TYPE> store, int index) {
this .store = store;
this .index = index;
this .hashCode = this .hashCode0();
}
@Nonnull
public Store<ECS_TYPE> getStore () {
return this .store;
}
public int getIndex {
.index;
}
{
.index = index;
}
{
.index = - ;
.hashCode = .hashCode0();
.invalidatedBy = ();
}
{
.index = - ;
.hashCode = .hashCode0();
.invalidatedBy = invalidatedBy != ? invalidatedBy : ();
}
{
( .index == - ) {
( , .invalidatedBy);
}
}
{
.index != - ;
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
Ref<?> ref = (Ref)o;
.index != ref.index ? : .store.equals(ref.store);
} {
;
}
}
{
== o || o != && .index == o.index && .store.equals(o.store);
}
{
.hashCode;
}
{
.store.hashCode();
result = * result + .index;
result;
}
String {
String.valueOf( .store.getClass());
+ var10000 + + .store.hashCode() + + .index + ;
}
}
com/hypixel/hytale/component/RemoveReason.java
package com.hypixel.hytale.component;
public enum RemoveReason {
REMOVE,
UNLOAD;
private RemoveReason () {
}
}
com/hypixel/hytale/component/Resource.java
package com.hypixel.hytale.component;
import javax.annotation.Nullable;
public interface Resource <ECS_TYPE> extends Cloneable {
Resource[] EMPTY_ARRAY = new Resource [0 ];
@Nullable
Resource<ECS_TYPE> clone () ;
}
com/hypixel/hytale/component/ResourceRegistration.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public record ResourceRegistration <ECS_TYPE, T extends Resource <ECS_TYPE>>(@Nonnull Class<? super T> typeClass, @Nullable String id, @Nullable BuilderCodec<T> codec, @Nonnull Supplier<T> supplier, @Nonnull ResourceType<ECS_TYPE, T> resourceType) {
}
com/hypixel/hytale/component/ResourceType.java
package com.hypixel.hytale.component;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ResourceType <ECS_TYPE, T extends Resource <ECS_TYPE>> implements Comparable <ResourceType<ECS_TYPE, ?>> {
@Nonnull
public static final ResourceType[] EMPTY_ARRAY = new ResourceType [0 ];
private ComponentRegistry<ECS_TYPE> registry;
private Class<? super T> tClass;
private int index;
private boolean invalid = true ;
public ResourceType () {
}
void init (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super T> tClass, int index) {
this .registry = registry;
this .tClass = tClass;
this .index = index;
this .invalid = false ;
}
@Nonnull
public ComponentRegistry<ECS_TYPE> getRegistry () {
.registry;
}
Class<? T> getTypeClass() {
.tClass;
}
{
.index;
}
{
(! .registry.equals(registry)) {
( + String.valueOf( ));
}
}
{
( .invalid) {
( );
}
}
{
.invalid = ;
}
{
! .invalid;
}
{
Integer.compare( .index, o.getIndex());
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
ResourceType<?, ?> that = (ResourceType)o;
.index != that.index ? : .registry.equals(that.registry);
} {
;
}
}
{
.registry.hashCode();
result = * result + .index;
result;
}
String {
String.valueOf( .registry.getClass());
+ var10000 + + .registry.hashCode() + + String.valueOf( .tClass) + + .index + ;
}
}
com/hypixel/hytale/component/Store.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.component.data.ForEachTaskData;
import com.hypixel.hytale.component.data.change.ChangeType;
import com.hypixel.hytale.component.data.change.ComponentChange;
import com.hypixel.hytale.component.data.change.DataChange;
import com.hypixel.hytale.component.data.change.SystemChange;
import com.hypixel.hytale.component.data.unknown.UnknownComponents;
import com.hypixel.hytale.component.event.EntityEventType;
import com.hypixel.hytale.component.event.WorldEventType;
import com.hypixel.hytale.component.metric.ArchetypeChunkData;
import com.hypixel.hytale.component.metric.SystemMetricData;
import com.hypixel.hytale.component.query.ExactArchetypeQuery;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.ArchetypeChunkSystem;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.EntityEventSystem;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.ISystem;
import com.hypixel.hytale.component.system.MetricSystem;
import com.hypixel.hytale.component.system.QuerySystem;
import com.hypixel.hytale.component.system.RefChangeSystem;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.component.system.StoreSystem;
import com.hypixel.hytale.component.system.WorldEventSystem;
import com.hypixel.hytale.component.system.data.ArchetypeDataSystem;
import com.hypixel.hytale.component.system.data.EntityDataSystem;
com.hypixel.hytale.component.system.tick.ArchetypeTickingSystem;
com.hypixel.hytale.component.system.tick.EntityTickingSystem;
com.hypixel.hytale.component.system.tick.TickableSystem;
com.hypixel.hytale.component.system.tick.TickingSystem;
com.hypixel.hytale.component.task.ParallelRangeTask;
com.hypixel.hytale.component.task.ParallelTask;
com.hypixel.hytale.function.consumer.IntBiObjectConsumer;
com.hypixel.hytale.metrics.MetricResults;
com.hypixel.hytale.metrics.MetricsRegistry;
com.hypixel.hytale.metrics.metric.HistoricMetric;
it.unimi.dsi.fastutil.objects.Object2IntMap;
it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.util.ArrayDeque;
java.util.Arrays;
java.util.BitSet;
java.util.Collection;
java.util.Deque;
java.util.List;
java.util.Objects;
java.util.concurrent.CompletableFuture;
java.util.concurrent.TimeUnit;
java.util.concurrent.locks.Condition;
java.util.concurrent.locks.Lock;
java.util.function.BiConsumer;
java.util.function.BiPredicate;
javax.annotation.Nonnull;
javax.annotation.Nullable;
<ECS_TYPE> <ECS_TYPE> {
Store[] EMPTY_ARRAY = [ ];
MetricsRegistry<Store<?>> METRICS_REGISTRY;
ComponentRegistry<ECS_TYPE> registry;
ECS_TYPE externalData;
IResourceStorage resourceStorage;
Deque<CommandBuffer<ECS_TYPE>> commandBuffers = ();
Thread.currentThread();
ParallelTask<EntityTickingSystem.SystemTaskData<ECS_TYPE>> parallelTask = <EntityTickingSystem.SystemTaskData<ECS_TYPE>>(EntityTickingSystem.SystemTaskData:: );
ParallelTask<ForEachTaskData<ECS_TYPE>> forEachTask = <ForEachTaskData<ECS_TYPE>>(ForEachTaskData:: );
ParallelTask<EntityDataSystem.SystemTaskData<ECS_TYPE, ?, ?>> fetchTask = <EntityDataSystem.SystemTaskData<ECS_TYPE, ?, ?>>(EntityDataSystem.SystemTaskData:: );
();
shutdown;
storeIndex;
entitiesSize;
Ref<ECS_TYPE>[] refs = [ ];
[] entityToArchetypeChunk = [ ];
[] entityChunkIndex = [ ];
BitSet[] systemIndexToArchetypeChunkIndexes;
BitSet[] archetypeChunkIndexesToSystemIndex;
Object2IntMap<Archetype<ECS_TYPE>> archetypeToIndexMap;
archetypeSize;
BitSet archetypeChunkReuse;
ArchetypeChunk<ECS_TYPE>[] archetypeChunks;
Resource<ECS_TYPE>[] resources;
HistoricMetric[] systemMetrics;
disableProcessingAssert;
Store( ComponentRegistry<ECS_TYPE> registry, storeIndex, ECS_TYPE externalData, IResourceStorage resourceStorage) {
.systemIndexToArchetypeChunkIndexes = ArrayUtil.EMPTY_BITSET_ARRAY;
.archetypeChunkIndexesToSystemIndex = ArrayUtil.EMPTY_BITSET_ARRAY;
.archetypeToIndexMap = <Archetype<ECS_TYPE>>();
.archetypeChunkReuse = ();
.archetypeChunks = ArchetypeChunk.<ECS_TYPE>emptyArray();
.resources = Resource.EMPTY_ARRAY;
.systemMetrics = HistoricMetric.EMPTY_ARRAY;
.disableProcessingAssert = ;
.registry = registry;
.storeIndex = storeIndex;
.externalData = externalData;
.resourceStorage = resourceStorage;
.archetypeToIndexMap.defaultReturnValue(- );
Arrays.fill( .entityToArchetypeChunk, - );
Arrays.fill( .entityChunkIndex, - );
}
CommandBuffer<ECS_TYPE> {
.assertThread();
( .commandBuffers.isEmpty()) {
<ECS_TYPE>( );
} {
CommandBuffer<ECS_TYPE> buffer = (CommandBuffer) .commandBuffers.pop();
buffer.setThread();
buffer;
}
}
{
.assertThread();
commandBuffer.validateEmpty();
.commandBuffers.add(commandBuffer);
}
{
.storeIndex;
}
ComponentRegistry<ECS_TYPE> {
.registry;
}
ECS_TYPE {
.externalData;
}
IResourceStorage {
.resourceStorage;
}
ParallelTask<EntityTickingSystem.SystemTaskData<ECS_TYPE>> getParallelTask() {
.parallelTask;
}
ParallelTask<EntityDataSystem.SystemTaskData<ECS_TYPE, ?, ?>> getFetchTask() {
.fetchTask;
}
HistoricMetric[] getSystemMetrics() {
.assertThread();
.systemMetrics;
}
{
.shutdown;
}
{
.updateArchetypeIndexes(data);
data.getResourceSize();
.resources = (Resource[])Arrays.copyOf( .resources, resourceSize);
( ; index < resourceSize; ++index) {
ResourceType<ECS_TYPE, ? <ECS_TYPE>> resourceType = data.getResourceType(index);
(resourceType != ) {
.resources[index] = (Resource) .resourceStorage.load( , data, resourceType).join();
}
}
( ; systemIndex < data.getSystemSize(); ++systemIndex) {
.updateData(data, data, (ChangeType.REGISTERED, data.getSystem(systemIndex)));
}
.systemMetrics = (HistoricMetric[])Arrays.copyOf( .systemMetrics, data.getSystemSize());
SystemType<ECS_TYPE, TickableSystem<ECS_TYPE>> tickingSystemType = .registry.getTickableSystemType();
data.getSystemIndexesForType(tickingSystemType);
( - ; (systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ; .systemMetrics[systemIndex] = HistoricMetric.builder( , TimeUnit.NANOSECONDS).addPeriod( , TimeUnit.SECONDS).addPeriod( , TimeUnit.MINUTES).addPeriod( , TimeUnit.MINUTES).build()) {
}
}
{
( .shutdown) {
( );
} {
.registry.removeStore( );
}
}
{
( .thread.isAlive() && ! .thread.equals(Thread.currentThread())) {
( );
} {
( data.getSystemSize() - ; systemIndex >= ; --systemIndex) {
.updateData(data, data, (ChangeType.UNREGISTERED, data.getSystem(systemIndex)));
}
.saveAllResources0(data).join();
.processing.lock();
{
( ; i < .entitiesSize; ++i) {
.refs[i].invalidate();
.refs[i] = ;
}
} {
.processing.unlock();
}
.shutdown = ;
}
}
CompletableFuture<Void> {
.saveAllResources0( .registry.getData());
}
CompletableFuture<Void> {
data.getResourceSize();
CompletableFuture<Void>[] futures = [resourceSize];
;
( ; index < resourceSize; ++index) {
ResourceType<ECS_TYPE, ? <ECS_TYPE>> resourceType = data.getResourceType(index);
(resourceType != ) {
futures[idx++] = .resourceStorage.save( , data, resourceType, .resources[index]);
}
}
CompletableFuture.allOf((CompletableFuture[])Arrays.copyOf(futures, idx));
}
{
.entitiesSize;
}
{
.assertThread();
(query ExactArchetypeQuery<ECS_TYPE> exactQuery) {
.archetypeToIndexMap.getInt(exactQuery.getArchetype());
archetypeIndex != - ? .archetypeChunks[archetypeIndex].size() : ;
} {
;
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && query.test(archetypeChunk.getArchetype())) {
count += archetypeChunk.size();
}
}
count;
}
}
{
.assertThread();
;
.systemIndexToArchetypeChunkIndexes[systemIndex];
( - ; (index = indexes.nextSetBit(index + )) >= ; count += .archetypeChunks[index].size()) {
}
count;
}
{
.assertThread();
.archetypeSize;
}
ArchetypeChunkData[] collectArchetypeChunkData() {
.assertThread();
ObjectArrayList<ArchetypeChunkData> result = <ArchetypeChunkData>( .archetypeSize);
( ; i < .archetypeSize; ++i) {
ArchetypeChunk<ECS_TYPE> chunk = .archetypeChunks[i];
(chunk != ) {
Archetype<ECS_TYPE> archetype = chunk.getArchetype();
String[] componentTypeNames = [archetype.count()];
;
( archetype.getMinIndex(); j < archetype.length(); ++j) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = archetype.get(j);
(componentType != ) {
componentTypeNames[nameIndex++] = componentType.getTypeClass().getName();
}
}
result.add( (componentTypeNames, chunk.size()));
}
}
(ArchetypeChunkData[])result.toArray((x$ ) -> [x$ ]);
}
{
.assertThread();
.systemIndexToArchetypeChunkIndexes[systemIndex].cardinality();
}
{
(ref.isValid()) {
.entityChunkIndex[ref.getIndex()] = newEntityChunkIndex;
}
}
Ref<ECS_TYPE> {
.assertThread();
.assertWriteProcessing();
Component<ECS_TYPE>[] entityComponents;
(archetype.isEmpty()) {
entityComponents = Component.EMPTY_ARRAY;
} {
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
entityComponents = [archetype.length()];
( archetype.getMinIndex(); i < archetype.length(); ++i) {
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = archetype.get(i);
(componentType != ) {
entityComponents[componentType.getIndex()] = data.createComponent(componentType);
}
}
}
.addEntity( .registry.newHolder(archetype, entityComponents), ( ), reason);
}
Ref<ECS_TYPE> {
.addEntity(holder, ( ), reason);
}
Ref<ECS_TYPE> {
(ref.isValid()) {
( );
} (ref.getStore() != ) {
( );
} {
.assertThread();
.assertWriteProcessing();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
.processing.lock();
{
SystemType<ECS_TYPE, HolderSystem<ECS_TYPE>> systemType = .registry.getHolderSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
HolderSystem<ECS_TYPE> system = (HolderSystem)data.getSystem(systemIndex, systemType);
(system.test( .registry, holder.getArchetype())) {
system.onEntityAdd(holder, reason, );
}
}
.entitiesSize++;
.refs.length;
(oldLength <= entityIndex) {
systemIndex = ArrayUtil.grow(entityIndex);
.refs = (Ref[])Arrays.copyOf( .refs, systemIndex);
.entityToArchetypeChunk = Arrays.copyOf( .entityToArchetypeChunk, systemIndex);
.entityChunkIndex = Arrays.copyOf( .entityChunkIndex, systemIndex);
Arrays.fill( .entityToArchetypeChunk, oldLength, systemIndex, - );
Arrays.fill( .entityChunkIndex, oldLength, systemIndex, - );
}
.refs[entityIndex] = ref;
ref.setIndex(entityIndex);
systemIndex = .findOrCreateArchetypeChunk(holder.getArchetype());
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[systemIndex];
archetypeChunk.addEntity(ref, holder);
.entityToArchetypeChunk[entityIndex] = systemIndex;
.entityChunkIndex[entityIndex] = chunkEntityRef;
SystemType<ECS_TYPE, RefSystem<ECS_TYPE>> systemType = .registry.getRefSystemType();
data.getSystemIndexesForType(systemType);
.archetypeChunkIndexesToSystemIndex[systemIndex];
commandBuffer.track(ref);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefSystem<ECS_TYPE> system = (RefSystem)data.getSystem(systemIndex, systemType);
.disableProcessingAssert;
.disableProcessingAssert = system DisableProcessingAssert;
system.onEntityAdded(ref, reason, , commandBuffer);
.disableProcessingAssert = oldDisableProcessingAssert;
(commandBuffer.consumeWasTrackedRefRemoved()) {
;
}
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
ref.isValid() ? ref : ;
}
}
Ref<ECS_TYPE>[] addEntities( Holder<ECS_TYPE>[] holders, AddReason reason) {
.addEntities(holders, , holders.length, reason);
}
Ref<ECS_TYPE>[] addEntities( Holder<ECS_TYPE>[] holders, start, length, AddReason reason) {
Ref<ECS_TYPE>[] refs = [length];
( ; i < length; ++i) {
refs[i] = ( );
}
.addEntities(holders, start, refs, , length, reason);
refs;
}
{
(holders.length != refs.length) {
( );
} {
.addEntities(holders, , refs, , holders.length, reason);
}
}
{
holderStart + length;
refStart + length;
(holders.length < holderEnd) {
( );
} (refs.length < refEnd) {
( );
} {
( refStart; i < refEnd; ++i) {
Ref<ECS_TYPE> ref = refs[i];
(ref.isValid()) {
( );
}
(ref.getStore() != ) {
( );
}
}
.assertThread();
.assertWriteProcessing();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
.processing.lock();
{
SystemType<ECS_TYPE, HolderSystem<ECS_TYPE>> systemType = .registry.getHolderSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
HolderSystem<ECS_TYPE> system = (HolderSystem)data.getSystem(systemIndex, systemType);
( holderStart; i < holderEnd; ++i) {
(system.test( .registry, holders[i].getArchetype())) {
system.onEntityAdd(holders[i], reason, );
}
}
}
.entitiesSize;
.entitiesSize += length;
.refs.length;
(oldLength <= .entitiesSize) {
systemIndex = ArrayUtil.grow( .entitiesSize);
.refs = (Ref[])Arrays.copyOf( .refs, systemIndex);
.entityToArchetypeChunk = Arrays.copyOf( .entityToArchetypeChunk, systemIndex);
.entityChunkIndex = Arrays.copyOf( .entityChunkIndex, systemIndex);
Arrays.fill( .entityToArchetypeChunk, oldLength, systemIndex, - );
Arrays.fill( .entityChunkIndex, oldLength, systemIndex, - );
}
System.arraycopy(refs, refStart, .refs, firstIndex, length);
systemIndex = refStart;
( firstIndex; systemIndex < refEnd; ++entityIndex) {
refs[systemIndex].setIndex(entityIndex);
++systemIndex;
}
systemIndex = ;
( firstIndex; systemIndex < length; ++entityIndex) {
Ref<ECS_TYPE> ref = refs[refStart + systemIndex];
Holder<ECS_TYPE> holder = holders[holderStart + systemIndex];
.findOrCreateArchetypeChunk(holder.getArchetype());
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
archetypeChunk.addEntity(ref, holder);
.entityToArchetypeChunk[entityIndex] = archetypeIndex;
.entityChunkIndex[entityIndex] = chunkEntityRef;
++systemIndex;
}
SystemType<ECS_TYPE, RefSystem<ECS_TYPE>> systemType = .registry.getRefSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
( refStart; i < refEnd; ++i) {
Ref<ECS_TYPE> ref = refs[i];
.entityToArchetypeChunk[ref.getIndex()];
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefSystem<ECS_TYPE> system = (RefSystem)data.getSystem(systemIndex, systemType);
.disableProcessingAssert;
.disableProcessingAssert = system DisableProcessingAssert;
commandBuffer.track(ref);
system.onEntityAdded(ref, reason, , commandBuffer);
(commandBuffer.consumeWasTrackedRefRemoved()) {
refEnd - i;
(remaining > ) {
System.arraycopy(refs, i + , refs, i, remaining - );
refs[refEnd - ] = ref;
--i;
}
--refEnd;
--length;
}
.disableProcessingAssert = oldDisableProcessingAssert;
}
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
Holder<ECS_TYPE> {
.copyEntity(ref, .registry.newHolder());
}
Holder<ECS_TYPE> {
.assertThread();
ref.validate();
ref.getIndex();
.entityToArchetypeChunk[refIndex];
.archetypeChunks[archetypeIndex].copyEntity( .entityChunkIndex[refIndex], holder);
}
Holder<ECS_TYPE> {
.copySerializableEntity(ref, .registry.newHolder());
}
Holder<ECS_TYPE> {
.assertThread();
ref.validate();
ref.getIndex();
.entityToArchetypeChunk[refIndex];
.archetypeChunks[archetypeIndex].copySerializableEntity( .registry.getData(), .entityChunkIndex[refIndex], holder);
}
Archetype<ECS_TYPE> {
.assertThread();
ref.validate();
.entityToArchetypeChunk[ref.getIndex()];
.archetypeChunks[archetypeIndex].getArchetype();
}
Archetype<ECS_TYPE> {
ref.validate();
.entityToArchetypeChunk[ref.getIndex()];
.archetypeChunks[archetypeIndex].getArchetype();
}
Holder<ECS_TYPE> {
.removeEntity(ref, .registry.newHolder(), reason);
}
Holder<ECS_TYPE> {
.removeEntity(ref, holder, reason, (Throwable) );
}
Holder<ECS_TYPE> {
.assertThread();
.assertWriteProcessing();
ref.validate();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
ref.getIndex();
.entityToArchetypeChunk[entityIndex];
.entityChunkIndex[entityIndex];
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
.processing.lock();
{
SystemType<ECS_TYPE, RefSystem<ECS_TYPE>> systemType = .registry.getRefSystemType();
data.getSystemIndexesForType(systemType);
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
((RefSystem)data.getSystem(systemIndex, systemType)).onEntityRemove(ref, reason, , commandBuffer);
}
}
.entitiesSize - ;
(entityIndex != lastIndex) {
Ref<ECS_TYPE> lastEntityRef = .refs[lastIndex];
.entityToArchetypeChunk[lastIndex];
systemIndex = .entityChunkIndex[lastIndex];
lastEntityRef.setIndex(entityIndex);
.refs[entityIndex] = lastEntityRef;
.entityToArchetypeChunk[entityIndex] = lastSelfEntityRef;
.entityChunkIndex[entityIndex] = systemIndex;
}
.refs[lastIndex] = ;
.entityToArchetypeChunk[lastIndex] = - ;
.entityChunkIndex[lastIndex] = - ;
.entitiesSize = lastIndex;
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
archetypeChunk.removeEntity(chunkEntityRef, holder);
(archetypeChunk.size() == ) {
.removeArchetypeChunk(archetypeIndex);
}
ref.invalidate(proxyReason);
} {
.processing.unlock();
}
commandBuffer.consume();
.processing.lock();
{
SystemType<ECS_TYPE, HolderSystem<ECS_TYPE>> systemType = .registry.getHolderSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
HolderSystem<ECS_TYPE> system = (HolderSystem)data.getSystem(systemIndex, systemType);
(system.test( .registry, holder.getArchetype())) {
system.onEntityRemoved(holder, reason, );
}
}
} {
.processing.unlock();
}
holder;
}
Holder<ECS_TYPE>[] removeEntities( Ref<ECS_TYPE>[] refs, RemoveReason reason) {
.removeEntities(refs, , refs.length, reason);
}
Holder<ECS_TYPE>[] removeEntities( Ref<ECS_TYPE>[] refs, start, length, RemoveReason reason) {
Holder<ECS_TYPE>[] holders = [length];
( ; i < length; ++i) {
holders[i] = .registry.newHolder();
}
.removeEntities(refs, start, holders, , length, reason);
}
Holder<ECS_TYPE>[] removeEntities( Ref<ECS_TYPE>[] refs, Holder<ECS_TYPE>[] holders, RemoveReason reason) {
(refs.length != holders.length) {
( );
} {
.removeEntities(refs, , holders, , refs.length, reason);
}
}
Holder<ECS_TYPE>[] removeEntities( Ref<ECS_TYPE>[] refArr, refStart, Holder<ECS_TYPE>[] holders, holderStart, length, RemoveReason reason) {
refStart + length;
holderStart + length;
(refArr.length < refEnd) {
( );
} (holders.length < holderEnd) {
( );
} {
( refStart; i < refEnd; ++i) {
refArr[i].validate();
}
.assertThread();
.assertWriteProcessing();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
.processing.lock();
{
SystemType<ECS_TYPE, RefSystem<ECS_TYPE>> systemType = .registry.getRefSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
( refStart; i < refEnd; ++i) {
Ref<ECS_TYPE> ref = refArr[i];
.entityToArchetypeChunk[ref.getIndex()];
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
(entityProcessedBySystemIndexes.get(systemIndex)) {
((RefSystem)data.getSystem(systemIndex, systemType)).onEntityRemove(refArr[i], reason, , commandBuffer);
}
}
}
( ; i < length; ++i) {
refArr[refStart + i].getIndex();
systemIndex = .entityToArchetypeChunk[entityIndex];
.entityChunkIndex[entityIndex];
.entitiesSize - ;
(entityIndex != lastIndex) {
Ref<ECS_TYPE> lastEntityRef = .refs[lastIndex];
.entityToArchetypeChunk[lastIndex];
.entityChunkIndex[lastIndex];
lastEntityRef.setIndex(entityIndex);
.refs[entityIndex] = lastEntityRef;
.entityToArchetypeChunk[entityIndex] = lastSelfEntityRef;
.entityChunkIndex[entityIndex] = lastEntityChunkIndex;
}
.refs[lastIndex] = ;
.entityToArchetypeChunk[lastIndex] = - ;
.entityChunkIndex[lastIndex] = - ;
.entitiesSize = lastIndex;
Holder<ECS_TYPE> holder = holders[holderStart + i];
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[systemIndex];
archetypeChunk.removeEntity(chunkEntityRef, holder);
(archetypeChunk.size() == ) {
.removeArchetypeChunk(systemIndex);
}
}
( refStart; i < refEnd; ++i) {
refArr[i].invalidate();
}
} {
.processing.unlock();
}
commandBuffer.consume();
.processing.lock();
{
SystemType<ECS_TYPE, HolderSystem<ECS_TYPE>> systemType = .registry.getHolderSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
HolderSystem<ECS_TYPE> system = (HolderSystem)data.getSystem(systemIndex, systemType);
( holderStart; i < holderEnd; ++i) {
(system.test( .registry, holders[i].getArchetype())) {
system.onEntityRemoved(holders[i], reason, );
}
}
}
} {
.processing.unlock();
}
holders;
}
}
<T <ECS_TYPE>> {
.assertThread();
.assertWriteProcessing();
componentType.validateRegistry( .registry);
componentType.validate();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.entityToArchetypeChunk[ref.getIndex()];
.processing.lock();
{
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(!archetypeChunk.getArchetype().contains(componentType)) {
.registry._internal_getData().createComponent(componentType);
.datachunk_addComponent(ref, archetypeIndex, componentType, component, commandBuffer);
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
<T <ECS_TYPE>> T {
.assertThread();
.assertWriteProcessing();
ref.getIndex();
componentType.validateRegistry( .registry);
componentType.validate();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.entityToArchetypeChunk[refIndex];
.processing.lock();
T component;
{
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
component = archetypeChunk.getComponent( .entityChunkIndex[refIndex], componentType);
(component == ) {
component = .registry._internal_getData().createComponent(componentType);
.datachunk_addComponent(ref, archetypeIndex, componentType, component, commandBuffer);
}
} {
.processing.unlock();
}
commandBuffer.consume();
component;
}
<T <ECS_TYPE>> T {
.assertThread();
.assertWriteProcessing();
.registry._internal_getData().createComponent(componentType);
.addComponent(ref, componentType, component);
component;
}
<T <ECS_TYPE>> {
.assertThread();
.assertWriteProcessing();
ref.validate();
componentType.validateRegistry( .registry);
componentType.validate();
Objects.requireNonNull(component);
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.entityToArchetypeChunk[ref.getIndex()];
.processing.lock();
{
.datachunk_addComponent(ref, archetypeIndex, componentType, component, commandBuffer);
} {
.processing.unlock();
}
commandBuffer.consume();
}
<T <ECS_TYPE>> {
.assertThread();
.assertWriteProcessing();
ref.validate();
componentType.validateRegistry( .registry);
componentType.validate();
Objects.requireNonNull(component);
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.entityToArchetypeChunk[ref.getIndex()];
.processing.lock();
{
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
.entityChunkIndex[ref.getIndex()];
archetypeChunk.getComponent(chunkEntityRef, componentType);
archetypeChunk.setComponent(chunkEntityRef, componentType, component);
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType( .registry.getRefChangeSystemType());
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefChangeSystem<ECS_TYPE, T> system = (RefChangeSystem)data.getSystem(systemIndex);
(system.componentType().getIndex() == componentType.getIndex()) {
system.onComponentSet(ref, oldComponent, component, , commandBuffer);
}
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
<T <ECS_TYPE>> {
.assertThread();
.assertWriteProcessing();
ref.validate();
componentType.validateRegistry( .registry);
componentType.validate();
Objects.requireNonNull(component);
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.entityToArchetypeChunk[ref.getIndex()];
.processing.lock();
{
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk.getArchetype().contains(componentType)) {
.entityChunkIndex[ref.getIndex()];
archetypeChunk.getComponent(chunkEntityRef, componentType);
archetypeChunk.setComponent(chunkEntityRef, componentType, component);
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType( .registry.getRefChangeSystemType());
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefChangeSystem<ECS_TYPE, T> system = (RefChangeSystem)data.getSystem(systemIndex);
(system.componentType().getIndex() == componentType.getIndex()) {
system.onComponentSet(ref, oldComponent, component, , commandBuffer);
}
}
}
} {
.datachunk_addComponent(ref, archetypeIndex, componentType, component, commandBuffer);
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
<T <ECS_TYPE>> T {
.assertThread();
(T) .__internal_getComponent(ref, componentType);
}
<T <ECS_TYPE>> T {
ref.validate();
componentType.validateRegistry( .registry);
componentType.validate();
.entityToArchetypeChunk[ref.getIndex()];
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(T)archetypeChunk.getComponent( .entityChunkIndex[ref.getIndex()], componentType);
}
<T <ECS_TYPE>> {
.assertThread();
.assertWriteProcessing();
ref.validate();
componentType.validateRegistry( .registry);
componentType.validate();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
ref.getIndex();
.entityToArchetypeChunk[entityIndex];
.processing.lock();
{
ArchetypeChunk<ECS_TYPE> fromArchetypeChunk = .archetypeChunks[fromArchetypeIndex];
Holder<ECS_TYPE> holder = .registry._internal_newEntityHolder();
fromArchetypeChunk.removeEntity( .entityChunkIndex[entityIndex], holder);
holder.getComponent(componentType);
component != ;
holder.removeComponent(componentType);
.findOrCreateArchetypeChunk(holder.getArchetype());
ArchetypeChunk<ECS_TYPE> toArchetypeChunk = .archetypeChunks[toArchetypeIndex];
toArchetypeChunk.addEntity(ref, holder);
.entityToArchetypeChunk[entityIndex] = toArchetypeIndex;
.entityChunkIndex[entityIndex] = chunkEntityRef;
.archetypeChunkIndexesToSystemIndex[fromArchetypeIndex];
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType( .registry.getRefChangeSystemType());
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefChangeSystem<ECS_TYPE, T> system = (RefChangeSystem)data.getSystem(systemIndex);
(system.componentType().getIndex() == componentType.getIndex()) {
system.onComponentRemoved(ref, component, , commandBuffer);
}
}
}
(fromArchetypeChunk.size() == ) {
.removeArchetypeChunk(fromArchetypeIndex);
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
<T <ECS_TYPE>> {
.removeComponentIfExists(ref, componentType);
}
<T <ECS_TYPE>> {
.assertThread();
.assertWriteProcessing();
ref.validate();
componentType.validateRegistry( .registry);
componentType.validate();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
ref.getIndex();
.entityToArchetypeChunk[entityIndex];
.processing.lock();
result;
{
ArchetypeChunk<ECS_TYPE> fromArchetypeChunk = .archetypeChunks[fromArchetypeIndex];
(!fromArchetypeChunk.getArchetype().contains(componentType)) {
result = ;
} {
Holder<ECS_TYPE> holder = .registry._internal_newEntityHolder();
fromArchetypeChunk.removeEntity( .entityChunkIndex[entityIndex], holder);
holder.getComponent(componentType);
component != ;
holder.removeComponent(componentType);
.findOrCreateArchetypeChunk(holder.getArchetype());
ArchetypeChunk<ECS_TYPE> toArchetypeChunk = .archetypeChunks[toArchetypeIndex];
toArchetypeChunk.addEntity(ref, holder);
.entityToArchetypeChunk[entityIndex] = toArchetypeIndex;
.entityChunkIndex[entityIndex] = chunkEntityRef;
.archetypeChunkIndexesToSystemIndex[fromArchetypeIndex];
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType( .registry.getRefChangeSystemType());
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefChangeSystem<ECS_TYPE, T> system = (RefChangeSystem)data.getSystem(systemIndex);
(system.componentType().getIndex() == componentType.getIndex()) {
system.onComponentRemoved(ref, component, , commandBuffer);
}
}
}
(fromArchetypeChunk.size() == ) {
.removeArchetypeChunk(fromArchetypeIndex);
}
result = ;
}
} {
.processing.unlock();
}
commandBuffer.consume();
result;
}
<T <ECS_TYPE>> {
.assertThread();
resourceType.validateRegistry( .registry);
Objects.requireNonNull(resource);
.resources[resourceType.getIndex()] = resource;
}
<T <ECS_TYPE>> T {
resourceType.validateRegistry( .registry);
(T) .resources[resourceType.getIndex()];
}
<T <ECS_TYPE>> T {
resourceType.validateRegistry( .registry);
(T) .resources[resourceType.getIndex()];
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.processing.lock();
{
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != ) {
consumer.accept(archetypeChunk, commandBuffer);
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
;
.processing.lock();
{
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && predicate.test(archetypeChunk, commandBuffer)) {
result = ;
;
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
result;
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.processing.lock();
{
(query ExactArchetypeQuery) {
ExactArchetypeQuery<ECS_TYPE> exactQuery = (ExactArchetypeQuery)query;
.archetypeToIndexMap.getInt(exactQuery.getArchetype());
(archetypeIndex != - ) {
consumer.accept( .archetypeChunks[archetypeIndex], commandBuffer);
}
} {
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && query.test(archetypeChunk.getArchetype())) {
consumer.accept( .archetypeChunks[archetypeIndex], commandBuffer);
}
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
;
.processing.lock();
{
(query ExactArchetypeQuery) {
ExactArchetypeQuery<ECS_TYPE> exactQuery = (ExactArchetypeQuery)query;
.archetypeToIndexMap.getInt(exactQuery.getArchetype());
(archetypeIndex != - ) {
result = predicate.test( .archetypeChunks[archetypeIndex], commandBuffer);
}
} {
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && query.test(archetypeChunk.getArchetype()) && predicate.test( .archetypeChunks[archetypeIndex], commandBuffer)) {
result = ;
;
}
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
result;
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.processing.lock();
{
.systemIndexToArchetypeChunkIndexes[systemIndex];
- ;
((index = indexes.nextSetBit(index + )) >= ) {
consumer.accept( .archetypeChunks[index], commandBuffer);
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
;
.processing.lock();
{
.systemIndexToArchetypeChunkIndexes[systemIndex];
- ;
((index = indexes.nextSetBit(index + )) >= ) {
(predicate.test( .archetypeChunks[index], commandBuffer)) {
result = ;
;
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
result;
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.forEachTask.init();
.processing.lock();
{
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != ) {
archetypeChunk.size();
(size != ) {
ParallelRangeTask<ForEachTaskData<ECS_TYPE>> systemTask = .forEachTask.appendTask();
systemTask.init( , size);
;
( systemTask.size(); i < systemTaskSize; ++i) {
(systemTask.get(i)).init(consumer, archetypeChunk, commandBuffer.fork());
}
}
}
}
ForEachTaskData.invokeParallelTask( .forEachTask, commandBuffer);
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.forEachTask.init();
.processing.lock();
{
(query ExactArchetypeQuery) {
ExactArchetypeQuery<ECS_TYPE> exactQuery = (ExactArchetypeQuery)query;
.archetypeToIndexMap.getInt(exactQuery.getArchetype());
(archetypeIndex != - ) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
archetypeChunk.size();
(archetypeChunkSize != ) {
ParallelRangeTask<ForEachTaskData<ECS_TYPE>> systemTask = .forEachTask.appendTask();
systemTask.init( , archetypeChunkSize);
;
( systemTask.size(); i < systemSize; ++i) {
(systemTask.get(i)).init(consumer, archetypeChunk, commandBuffer.fork());
}
}
}
} {
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && query.test(archetypeChunk.getArchetype())) {
archetypeChunk.size();
(archetypeChunkSize != ) {
ParallelRangeTask<ForEachTaskData<ECS_TYPE>> systemTask = .forEachTask.appendTask();
systemTask.init( , archetypeChunkSize);
;
( systemTask.size(); i < systemTaskSize; ++i) {
(systemTask.get(i)).init(consumer, archetypeChunk, commandBuffer.fork());
}
}
}
}
}
ForEachTaskData.invokeParallelTask( .forEachTask, commandBuffer);
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
<T <ECS_TYPE, Q, R>, Q, R> {
( .shutdown) {
( );
} {
.assertThread();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.fetchTask.init();
data.getSystemIndexesForType(systemType);
.processing.lock();
{
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(T)(data.getSystem(systemIndex, systemType));
.systemIndexToArchetypeChunkIndexes[systemIndex];
- ;
((index = indexes.nextSetBit(index + )) >= ) {
((ArchetypeDataSystem)system).fetch( .archetypeChunks[index], , commandBuffer, query, results);
}
}
EntityDataSystem.SystemTaskData.invokeParallelTask( .fetchTask, commandBuffer, results);
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
<T <ECS_TYPE, Q, R>, Q, R> {
( .shutdown) {
( );
} {
.assertThread();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.fetchTask.init();
data.getSystemIndexesForType(systemType);
.processing.lock();
{
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(T)(data.getSystem(systemIndex, systemType));
(Ref<ECS_TYPE> ref : refs) {
ref.getIndex();
.entityToArchetypeChunk[entityIndex];
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
(entityProcessedBySystemIndexes.get(systemIndex)) {
.entityChunkIndex[entityIndex];
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
((EntityDataSystem)system).fetch(index, archetypeChunk, , commandBuffer, query, results);
}
}
}
EntityDataSystem.SystemTaskData.invokeParallelTask( .fetchTask, commandBuffer, results);
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
<Event > {
EntityEventType<ECS_TYPE, ?> eventType = .registry.getEntityEventTypeForClass(param.getClass());
(eventType != ) {
.invoke(eventType, ref, param);
}
}
<Event > {
( .shutdown) {
( );
} {
.assertThread();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
commandBuffer.track(ref);
data.getSystemIndexesForType(systemType);
.processing.lock();
{
ref.getIndex();
.entityToArchetypeChunk[entityIndex];
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
.entityChunkIndex[entityIndex];
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
systemIndex = entityProcessedBySystemIndexes.nextSetBit(systemIndex);
(systemIndex < ) {
;
}
(systemIndexes.get(systemIndex)) {
EntityEventSystem<ECS_TYPE, Event> system = (EntityEventSystem)data.getSystem(systemIndex, systemType);
system.handleInternal(index, archetypeChunk, , commandBuffer, param);
(commandBuffer.consumeWasTrackedRefRemoved()) {
;
}
}
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
<Event > {
WorldEventType<ECS_TYPE, ?> eventType = .registry.getWorldEventTypeForClass(param.getClass());
(eventType != ) {
.invoke(eventType, param);
}
}
<Event > {
( .shutdown) {
( );
} {
.assertThread();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
data.getSystemIndexesForType(systemType);
.processing.lock();
{
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
WorldEventSystem<ECS_TYPE, Event> system = (WorldEventSystem)data.getSystem(systemIndex, systemType);
system.handleInternal( , commandBuffer, param);
}
} {
.processing.unlock();
}
commandBuffer.consume();
}
}
<Event > {
EntityEventType<ECS_TYPE, ?> eventType = .registry.getEntityEventTypeForClass(param.getClass());
(eventType != ) {
.internal_invoke(sourceCommandBuffer, eventType, ref, param);
}
}
<Event > {
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
CommandBuffer<ECS_TYPE> commandBuffer = sourceCommandBuffer.fork();
commandBuffer.track(ref);
data.getSystemIndexesForType(systemType);
ref.getIndex();
.entityToArchetypeChunk[entityIndex];
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
.entityChunkIndex[entityIndex];
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
systemIndex = entityProcessedBySystemIndexes.nextSetBit(systemIndex);
(systemIndex < ) {
;
}
(systemIndexes.get(systemIndex)) {
EntityEventSystem<ECS_TYPE, Event> system = (EntityEventSystem)data.getSystem(systemIndex, systemType);
system.handleInternal(index, archetypeChunk, , commandBuffer, param);
(commandBuffer.consumeWasTrackedRefRemoved()) {
;
}
}
}
commandBuffer.mergeParallel(sourceCommandBuffer);
}
<Event > {
WorldEventType<ECS_TYPE, ?> eventType = .registry.getWorldEventTypeForClass(param.getClass());
(eventType != ) {
.internal_invoke(sourceCommandBuffer, eventType, param);
}
}
<Event > {
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
WorldEventSystem<ECS_TYPE, Event> system = (WorldEventSystem)data.getSystem(systemIndex, systemType);
system.handleInternal( , sourceCommandBuffer, param);
}
}
{
.tickInternal(dt, .registry.getTickingSystemType());
}
{
( .shutdown) {
( );
} {
.assertThread();
.tickInternal(dt, .registry.getRunWhenPausedSystemType());
}
}
<Tickable <ECS_TYPE>> {
( .shutdown) {
( );
} {
.assertThread();
.registry.getDataUpdateLock().readLock().lock();
{
ComponentRegistry.Data<ECS_TYPE> data = .registry.doDataUpdate();
data.getSystemIndexesForType(tickingSystemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(Tickable)(data.getSystem(systemIndex, tickingSystemType));
System.nanoTime();
tickingSystem.tick(dt, systemIndex, );
System.nanoTime();
.systemMetrics[systemIndex].add(end, end - start);
}
} {
.registry.getDataUpdateLock().readLock().unlock();
}
}
}
{
( .shutdown) {
( );
} {
.assertThread();
CommandBuffer<ECS_TYPE> commandBuffer = .takeCommandBuffer();
.parallelTask.init();
.disableProcessingAssert;
.disableProcessingAssert = system DisableProcessingAssert;
.processing.lock();
{
.systemIndexToArchetypeChunkIndexes[systemIndex];
- ;
((index = indexes.nextSetBit(index + )) >= ) {
system.tick(dt, .archetypeChunks[index], , commandBuffer);
}
EntityTickingSystem.SystemTaskData.invokeParallelTask( .parallelTask, commandBuffer);
} {
.processing.unlock();
.disableProcessingAssert = oldDisableProcessingAssert;
}
commandBuffer.consume();
}
}
{
( .shutdown) {
( );
} {
data.getResourceSize();
.resources = (Resource[])Arrays.copyOf( .resources, resourceSize);
( ; index < .resources.length; ++index) {
ResourceType<ECS_TYPE, ? <ECS_TYPE>> resourceType = data.getResourceType(index);
( .resources[index] == && resourceType != ) {
.resources[index] = (Resource) .resourceStorage.load( , data, resourceType).join();
} ( .resources[index] != && resourceType == ) {
.resources[index] = ;
}
}
;
( ; i < data.getDataChangeCount(); ++i) {
data.getDataChange(i);
systemChanged |= dataChange SystemChange;
.updateData(oldData, data, dataChange);
}
HistoricMetric[] oldSystemMetrics = .systemMetrics;
.systemMetrics = [data.getSystemSize()];
SystemType<ECS_TYPE, TickableSystem<ECS_TYPE>> tickingSystemType = .registry.getTickableSystemType();
data.getSystemIndexesForType(tickingSystemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
ISystem<ECS_TYPE> system = data.getSystem(systemIndex);
oldData.indexOf(system);
(oldSystemIndex >= ) {
.systemMetrics[systemIndex] = oldSystemMetrics[oldSystemIndex];
} {
.systemMetrics[systemIndex] = HistoricMetric.builder( , TimeUnit.NANOSECONDS).addPeriod( , TimeUnit.SECONDS).addPeriod( , TimeUnit.MINUTES).addPeriod( , TimeUnit.MINUTES).build();
}
}
(systemChanged) {
.updateArchetypeIndexes(data);
}
}
}
{
.processing.lock();
{
.updateData0(oldData, newData, dataChange);
} {
.processing.unlock();
}
(dataChange SystemChange) {
SystemChange<ECS_TYPE> systemChange = (SystemChange)dataChange;
ISystem<ECS_TYPE> system = systemChange.getSystem();
(systemChange.getType()) {
REGISTERED:
(system StoreSystem) {
((StoreSystem)system).onSystemAddedToStore( );
}
;
UNREGISTERED:
(system StoreSystem) {
((StoreSystem)system).onSystemRemovedFromStore( );
}
}
}
}
{
(dataChange ComponentChange) {
ComponentChange<ECS_TYPE, ? <ECS_TYPE>> componentChange = (ComponentChange)dataChange;
ComponentType<ECS_TYPE, ? <ECS_TYPE>> componentType = componentChange.getComponentType();
ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> unknownComponentType = .registry.getUnknownComponentType();
(componentChange.getType()) {
REGISTERED:
newData.getComponentId(componentType);
Codec<Component<ECS_TYPE>> componentCodec = newData.<Component<ECS_TYPE>>getComponentCodec(componentType);
(componentCodec != ) {
Holder<ECS_TYPE> tempInternalEntityHolder = .registry._internal_newEntityHolder();
.archetypeSize;
( ; archetypeIndex < oldArchetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != ) {
Archetype<ECS_TYPE> archetype = archetypeChunk.getArchetype();
(!archetype.contains(componentType) && archetype.contains(unknownComponentType)) {
Archetype<ECS_TYPE> newArchetype = Archetype.add(archetype, componentType);
.findOrCreateArchetypeChunk(newArchetype);
ArchetypeChunk<ECS_TYPE> toArchetypeChunk = .archetypeChunks[toArchetypeIndex];
archetypeChunk.transferSomeTo(tempInternalEntityHolder, toArchetypeChunk, (index) -> {
UnknownComponents<ECS_TYPE> unknownComponents = (UnknownComponents)archetypeChunk.getComponent(index, unknownComponentType);
unknownComponents != ;
unknownComponents.contains(componentId);
}, (entity) -> {
UnknownComponents<ECS_TYPE> unknownComponents = (UnknownComponents)entity.getComponent(unknownComponentType);
unknownComponents != ;
Component<ECS_TYPE> component = unknownComponents.removeComponent(componentId, componentCodec);
entity.addComponent(componentType, component);
}, (newChunkEntityRef, ref) -> {
.entityToArchetypeChunk[ref.getIndex()] = toArchetypeIndex;
.entityChunkIndex[ref.getIndex()] = newChunkEntityRef;
});
(archetypeChunk.size() == ) {
.archetypeToIndexMap.removeInt( .archetypeChunks[archetypeIndex].getArchetype());
.archetypeChunks[archetypeIndex] = ;
( ; systemIndex < oldData.getSystemSize(); ++systemIndex) {
.systemIndexToArchetypeChunkIndexes[systemIndex].clear(archetypeIndex);
}
.archetypeChunkIndexesToSystemIndex[archetypeIndex].clear();
.archetypeChunkReuse.set(archetypeIndex);
}
(toArchetypeChunk.size() == ) {
.archetypeToIndexMap.removeInt( .archetypeChunks[toArchetypeIndex].getArchetype());
.archetypeChunks[toArchetypeIndex] = ;
( ; systemIndex < oldData.getSystemSize(); ++systemIndex) {
.systemIndexToArchetypeChunkIndexes[systemIndex].clear(toArchetypeIndex);
}
.archetypeChunkIndexesToSystemIndex[toArchetypeIndex].clear();
.archetypeChunkReuse.set(toArchetypeIndex);
}
}
}
}
}
;
UNREGISTERED:
Holder<ECS_TYPE> tempInternalEntityHolder = .registry._internal_newEntityHolder();
oldData.getComponentId(componentType);
Codec<Component<ECS_TYPE>> componentCodec = oldData.<Component<ECS_TYPE>>getComponentCodec(componentType);
.archetypeSize;
( ; archetypeIndex < oldArchetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != ) {
Archetype<ECS_TYPE> archetype = archetypeChunk.getArchetype();
(archetype.contains(componentType)) {
.archetypeToIndexMap.removeInt( .archetypeChunks[archetypeIndex].getArchetype());
.archetypeChunks[archetypeIndex] = ;
( ; systemIndex < oldData.getSystemSize(); ++systemIndex) {
.systemIndexToArchetypeChunkIndexes[systemIndex].clear(archetypeIndex);
}
.archetypeChunkIndexesToSystemIndex[archetypeIndex].clear();
.archetypeChunkReuse.set(archetypeIndex);
Archetype<ECS_TYPE> newArchetype = Archetype.remove(archetype, componentType);
(componentCodec != && !newArchetype.contains(unknownComponentType)) {
newArchetype = Archetype.add(newArchetype, unknownComponentType);
}
.findOrCreateArchetypeChunk(newArchetype);
ArchetypeChunk<ECS_TYPE> toArchetypeChunk = .archetypeChunks[toArchetypeIndex];
archetypeChunk.transferTo(tempInternalEntityHolder, toArchetypeChunk, (entity) -> {
(componentCodec != ) {
UnknownComponents<ECS_TYPE> unknownComponents;
(entity.getArchetype().contains(unknownComponentType)) {
unknownComponents = (UnknownComponents)entity.getComponent(unknownComponentType);
unknownComponents != ;
} {
unknownComponents = <ECS_TYPE>();
entity.addComponent(unknownComponentType, unknownComponents);
}
Component<ECS_TYPE> component = entity.getComponent(componentType);
unknownComponents.addComponent(componentId, component, componentCodec);
}
entity.removeComponent(componentType);
}, (newChunkEntityRef, ref) -> {
.entityToArchetypeChunk[ref.getIndex()] = toArchetypeIndex;
.entityChunkIndex[ref.getIndex()] = newChunkEntityRef;
});
}
}
}
.archetypeChunkReuse.previousClearBit(oldArchetypeSize - );
.archetypeSize = highestUsedIndex + ;
.archetypeChunkReuse.clear( .archetypeSize, oldArchetypeSize);
}
} (dataChange SystemChange) {
SystemChange<ECS_TYPE> systemChange = (SystemChange)dataChange;
ISystem<ECS_TYPE> system = systemChange.getSystem();
(systemChange.getType()) {
REGISTERED:
(system ArchetypeChunkSystem) {
ArchetypeChunkSystem<ECS_TYPE> archetypeChunkSystem = (ArchetypeChunkSystem)system;
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && archetypeChunkSystem.test( .registry, archetypeChunk.getArchetype())) {
archetypeChunkSystem.onSystemAddedToArchetypeChunk(archetypeChunk);
}
}
}
;
UNREGISTERED:
(system ArchetypeChunkSystem) {
ArchetypeChunkSystem<ECS_TYPE> archetypeChunkSystem = (ArchetypeChunkSystem)system;
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && archetypeChunkSystem.test( .registry, archetypeChunk.getArchetype())) {
archetypeChunkSystem.onSystemRemovedFromArchetypeChunk(archetypeChunk);
}
}
}
}
}
}
{
data.getSystemSize();
.systemIndexToArchetypeChunkIndexes.length;
(oldLength < systemSize) {
.systemIndexToArchetypeChunkIndexes = (BitSet[])Arrays.copyOf( .systemIndexToArchetypeChunkIndexes, systemSize);
( oldLength; i < systemSize; ++i) {
.systemIndexToArchetypeChunkIndexes[i] = ( .archetypeSize);
}
}
( ; systemIndex < oldLength; ++systemIndex) {
.systemIndexToArchetypeChunkIndexes[systemIndex].clear();
}
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
.archetypeChunkIndexesToSystemIndex[archetypeIndex].clear();
}
SystemType<ECS_TYPE, QuerySystem<ECS_TYPE>> entityQuerySystemType = .registry.getQuerySystemType();
data.getSystemIndexesForType(entityQuerySystemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
QuerySystem<ECS_TYPE> system = (QuerySystem)data.getSystem(systemIndex, entityQuerySystemType);
.systemIndexToArchetypeChunkIndexes[systemIndex];
( ; archetypeIndex < .archetypeSize; ++archetypeIndex) {
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
(archetypeChunk != && system.test( .registry, archetypeChunk.getArchetype())) {
archetypeChunkIndexes.set(archetypeIndex);
.archetypeChunkIndexesToSystemIndex[archetypeIndex].set(systemIndex);
}
}
}
}
{
( .processing.isHeld() && ! .disableProcessingAssert) {
( );
}
}
{
.processing.isHeld();
}
{
Thread.currentThread();
(!currentThread.equals( .thread) && .thread.isAlive()) {
String.valueOf( .thread);
( + var10002 + + String.valueOf(currentThread));
}
}
{
Thread.currentThread().equals( .thread);
}
{
.thread.isAlive() && !Thread.currentThread().equals( .thread);
}
String {
String.valueOf( .getClass());
+ var10000 + + .hashCode() + + String.valueOf( .registry.getClass()) + + .registry.hashCode() + + .shutdown + + .storeIndex + + Arrays.toString( .systemIndexToArchetypeChunkIndexes) + + .archetypeSize + + Arrays.toString( .archetypeChunks) + ;
}
<T <ECS_TYPE>> {
ref.getIndex();
ArchetypeChunk<ECS_TYPE> fromArchetypeChunk = .archetypeChunks[fromArchetypeIndex];
.entityChunkIndex[entityIndex];
Holder<ECS_TYPE> holder = .registry._internal_newEntityHolder();
fromArchetypeChunk.removeEntity(oldChunkEntityRef, holder);
holder.addComponent(componentType, component);
.findOrCreateArchetypeChunk(holder.getArchetype());
ArchetypeChunk<ECS_TYPE> toArchetypeChunk = .archetypeChunks[toArchetypeIndex];
toArchetypeChunk.addEntity(ref, holder);
.entityToArchetypeChunk[entityIndex] = toArchetypeIndex;
.entityChunkIndex[entityIndex] = chunkEntityRef;
.archetypeChunkIndexesToSystemIndex[toArchetypeIndex];
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType( .registry.getRefChangeSystemType());
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
(entityProcessedBySystemIndexes.get(systemIndex)) {
RefChangeSystem<ECS_TYPE, T> system = (RefChangeSystem)data.getSystem(systemIndex);
(system.componentType().getIndex() == componentType.getIndex()) {
system.onComponentAdded(ref, component, , commandBuffer);
}
}
}
(fromArchetypeChunk.size() == ) {
.removeArchetypeChunk(fromArchetypeIndex);
}
}
{
.archetypeToIndexMap.getInt(archetype);
(archetypeIndex != - ) {
archetypeIndex;
} {
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
( .archetypeChunkReuse.isEmpty()) {
archetypeIndex = .archetypeSize++;
} {
archetypeIndex = .archetypeChunkReuse.nextSetBit( );
.archetypeChunkReuse.clear(archetypeIndex);
}
.archetypeChunks.length;
(oldLength <= archetypeIndex) {
ArrayUtil.grow(archetypeIndex);
.archetypeChunks = (ArchetypeChunk[])Arrays.copyOf( .archetypeChunks, newLength);
.archetypeChunkIndexesToSystemIndex = (BitSet[])Arrays.copyOf( .archetypeChunkIndexesToSystemIndex, newLength);
data.getSystemSize();
( oldLength; i < newLength; ++i) {
.archetypeChunkIndexesToSystemIndex[i] = (systemSize);
}
}
ArchetypeChunk<ECS_TYPE> archetypeChunk = <ECS_TYPE>( , archetype);
.archetypeChunks[archetypeIndex] = archetypeChunk;
.archetypeToIndexMap.put(archetype, archetypeIndex);
.archetypeChunkIndexesToSystemIndex[archetypeIndex];
SystemType<ECS_TYPE, QuerySystem<ECS_TYPE>> entityQuerySystemType = .registry.getQuerySystemType();
data.getSystemIndexesForType(entityQuerySystemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
QuerySystem<ECS_TYPE> system = (QuerySystem)data.getSystem(systemIndex, entityQuerySystemType);
(system.test( .registry, archetype)) {
.systemIndexToArchetypeChunkIndexes[systemIndex].set(archetypeIndex);
archetypeChunkToSystemIndex.set(systemIndex);
(system ArchetypeChunkSystem) {
((ArchetypeChunkSystem)system).onSystemAddedToArchetypeChunk(archetypeChunk);
}
}
}
archetypeIndex;
}
}
{
ArchetypeChunk<ECS_TYPE> archetypeChunk = .archetypeChunks[archetypeIndex];
Archetype<ECS_TYPE> archetype = archetypeChunk.getArchetype();
.archetypeToIndexMap.removeInt(archetype);
.archetypeChunks[archetypeIndex] = ;
.archetypeChunkIndexesToSystemIndex[archetypeIndex].clear();
ComponentRegistry.Data<ECS_TYPE> data = .registry._internal_getData();
data.getSystemIndexesForType( .registry.getQuerySystemType());
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
.systemIndexToArchetypeChunkIndexes[systemIndex].clear(archetypeIndex);
ISystem<ECS_TYPE> system = data.getSystem(systemIndex);
(system ArchetypeChunkSystem<ECS_TYPE> archetypeChunkSystem) {
(archetypeChunkSystem.test( .registry, archetype)) {
archetypeChunkSystem.onSystemRemovedFromArchetypeChunk(archetypeChunk);
}
}
}
(archetypeIndex == .archetypeSize - ) {
.archetypeChunkReuse.previousClearBit(archetypeIndex - );
.archetypeSize = highestUsedIndex + ;
.archetypeChunkReuse.clear( .archetypeSize, archetypeIndex);
} {
.archetypeChunkReuse.set(archetypeIndex);
}
}
{
METRICS_REGISTRY = ( ()).register( , Store::getArchetypeChunkCount, Codec.INTEGER).register( , Store::getEntityCount, Codec.INTEGER).register( , (componentStore) -> {
ComponentRegistry.Data<?> data = componentStore.getRegistry().getData();
HistoricMetric[] systemMetrics = componentStore.getSystemMetrics();
SystemMetricData[] systemMetricData = [data.getSystemSize()];
( ; systemIndex < data.getSystemSize(); ++systemIndex) {
ISystem<?> system = data.getSystem(systemIndex);
;
(system MetricSystem metricSystem) {
metrics = metricSystem.toMetricResults(componentStore);
}
systemMetricData[systemIndex] = (system.getClass().getName(), componentStore.getArchetypeChunkCountFor(systemIndex), componentStore.getEntityCountFor(systemIndex), system TickingSystem ? systemMetrics[systemIndex] : , metrics);
}
systemMetricData;
}, (SystemMetricData.CODEC, (x$ ) -> [x$ ])).register( , Store::collectArchetypeChunkData, (ArchetypeChunkData.CODEC, (x$ ) -> [x$ ]));
}
{
;
{
}
{
.count > ;
}
{
++ .count;
}
{
( );
}
{
( );
}
{
( );
}
{
-- .count;
}
Condition {
( );
}
}
}
com/hypixel/hytale/component/SystemGroup.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.dependency.Dependency;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class SystemGroup <ECS_TYPE> implements Comparable <SystemGroup<ECS_TYPE>> {
@Nonnull
private final ComponentRegistry<ECS_TYPE> registry;
private final int index;
@Nonnull
private final Set<Dependency<ECS_TYPE>> dependencies;
private boolean invalidated;
SystemGroup(@Nonnull ComponentRegistry<ECS_TYPE> registry, int index, @Nonnull Set<Dependency<ECS_TYPE>> dependencies) {
this .registry = registry;
this .index = index;
this .dependencies = dependencies;
}
@Nonnull
public ComponentRegistry<ECS_TYPE> getRegistry () {
return this .registry;
}
@Nonnull
public Set<Dependency<ECS_TYPE>> getDependencies () {
return this .dependencies;
}
public int getIndex () {
.index;
}
{
(! .registry.equals(registry)) {
( + String.valueOf( ));
}
}
{
( .invalidated) {
( );
}
}
{
.invalidated = ;
}
{
! .invalidated;
}
{
Integer.compare( .index, o.getIndex());
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
SystemGroup<?> that = (SystemGroup)o;
.index != that.index ? : .registry.equals(that.registry);
} {
;
}
}
{
.registry.hashCode();
result = * result + .index;
result;
}
String {
String.valueOf( .registry.getClass());
+ var10000 + + .registry.hashCode() + + .index + ;
}
}
com/hypixel/hytale/component/SystemType.java
package com.hypixel.hytale.component;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class SystemType <ECS_TYPE, T extends ISystem <ECS_TYPE>> implements Comparable <SystemType<ECS_TYPE, ?>> {
@Nonnull
public static final SystemType[] EMPTY_ARRAY = new SystemType [0 ];
@Nonnull
private final ComponentRegistry<ECS_TYPE> registry;
@Nonnull
private final Class<? super T> tClass;
private final int index;
private boolean invalidated;
protected SystemType (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super T> tClass, int index) {
this .registry = registry;
this .tClass = tClass;
this .index = index;
}
@Nonnull
public ComponentRegistry<ECS_TYPE> getRegistry () {
return this .registry;
}
Class<? T> getTypeClass() {
.tClass;
}
{
.tClass.isAssignableFrom(system.getClass());
}
{
.index;
}
{
(! .registry.equals(registry)) {
( + String.valueOf( ));
}
}
{
( .invalidated) {
( );
}
}
{
.invalidated = ;
}
{
! .invalidated;
}
{
Integer.compare( .index, o.getIndex());
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
SystemType<?, ?> that = (SystemType)o;
.index != that.index ? : .registry.equals(that.registry);
} {
;
}
}
{
.registry.hashCode();
result = * result + .index;
result;
}
String {
String.valueOf( .registry.getClass());
+ var10000 + + .registry.hashCode() + + String.valueOf( .tClass) + + .index + ;
}
}
com/hypixel/hytale/component/WeakComponentReference.java
package com.hypixel.hytale.component;
import java.lang.ref.WeakReference;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class WeakComponentReference <ECS_TYPE, T extends Component <ECS_TYPE>> {
@Nonnull
private final Store<ECS_TYPE> store;
@Nonnull
private final ComponentType<ECS_TYPE, T> type;
@Nullable
private Ref<ECS_TYPE> ref;
private WeakReference<T> reference;
WeakComponentReference(@Nonnull Store<ECS_TYPE> store, @Nonnull ComponentType<ECS_TYPE, T> type, @Nonnull Ref<ECS_TYPE> ref, @Nonnull T data) {
this .store = store;
this .type = type;
this .ref = ref;
this .reference = new WeakReference (data);
}
@Nullable
public T get () {
T data = (T)(this .reference.get());
if (data != null ) {
return data;
} else if (this .ref == null ) {
;
} {
data = .store.getComponent( .ref, .type);
(data != ) {
.reference = (data);
}
data;
}
}
Store<ECS_TYPE> {
.store;
}
ComponentType<ECS_TYPE, T> {
.type;
}
Ref<ECS_TYPE> {
.ref;
}
{
.ref = ;
.reference.clear();
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
WeakComponentReference<?, ?> that = (WeakComponentReference)o;
(! .store.equals(that.store)) {
;
} {
! .type.equals(that.type) ? : Objects.equals( .ref, that.ref);
}
} {
;
}
}
{
.store.hashCode();
result = * result + .type.hashCode();
result = * result + ( .ref != ? .ref.hashCode() : );
result;
}
String {
String.valueOf( .store);
+ var10000 + + String.valueOf( .type) + + String.valueOf( .ref) + + String.valueOf( .reference) + ;
}
}
com/hypixel/hytale/component/package-info.java
package com.hypixel.hytale.component;
com/hypixel/hytale/component/data/ForEachTaskData.java
package com.hypixel.hytale.component.data;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.task.ParallelRangeTask;
import com.hypixel.hytale.component.task.ParallelTask;
import com.hypixel.hytale.function.consumer.IntBiObjectConsumer;
import java.util.function.IntConsumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ForEachTaskData <ECS_TYPE> implements IntConsumer {
@Nullable
private IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer;
@Nullable
private ArchetypeChunk<ECS_TYPE> archetypeChunk;
@Nullable
private CommandBuffer<ECS_TYPE> commandBuffer;
public ForEachTaskData () {
}
public void init (IntBiObjectConsumer<ArchetypeChunk<ECS_TYPE>, CommandBuffer<ECS_TYPE>> consumer, ArchetypeChunk<ECS_TYPE> archetypeChunk, CommandBuffer<ECS_TYPE> commandBuffer) {
this .consumer = consumer;
this .archetypeChunk = archetypeChunk;
this .commandBuffer = commandBuffer;
}
public void accept (int index) {
assert this .commandBuffer.setThread();
this .consumer.accept(index, .archetypeChunk, .commandBuffer);
}
{
.consumer = ;
.archetypeChunk = ;
.commandBuffer = ;
}
<ECS_TYPE> {
parallelTask.size();
(parallelTaskSize > ) {
parallelTask.doInvoke();
( ; x < parallelTaskSize; ++x) {
ParallelRangeTask<ForEachTaskData<ECS_TYPE>> systemTask = parallelTask.get(x);
;
( systemTask.size(); i < systemTaskSize; ++i) {
ForEachTaskData<ECS_TYPE> data = systemTask.get(i);
data.commandBuffer.mergeParallel(commandBuffer);
data.clear();
}
}
}
}
}
com/hypixel/hytale/component/data/change/ChangeType.java
package com.hypixel.hytale.component.data.change;
public enum ChangeType {
REGISTERED,
UNREGISTERED;
private ChangeType () {
}
}
com/hypixel/hytale/component/data/change/ComponentChange.java
package com.hypixel.hytale.component.data.change;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import javax.annotation.Nonnull;
public class ComponentChange <ECS_TYPE, T extends Component <ECS_TYPE>> implements DataChange {
private final ChangeType type;
private final ComponentType<ECS_TYPE, T> componentType;
public ComponentChange (ChangeType type, ComponentType<ECS_TYPE, T> componentType) {
this .type = type;
this .componentType = componentType;
}
public ChangeType getType () {
return this .type;
}
public ComponentType<ECS_TYPE, T> getComponentType () {
return this .componentType;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .type);
return "ComponentChange{type=" + var10000 + ", componentType=" + String.valueOf(this .componentType) + "}" ;
}
}
com/hypixel/hytale/component/data/change/DataChange.java
package com.hypixel.hytale.component.data.change;
public interface DataChange {
}
com/hypixel/hytale/component/data/change/ResourceChange.java
package com.hypixel.hytale.component.data.change;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceType;
import javax.annotation.Nonnull;
public class ResourceChange <ECS_TYPE, T extends Resource <ECS_TYPE>> implements DataChange {
private final ChangeType type;
private final ResourceType<ECS_TYPE, T> resourceType;
public ResourceChange (ChangeType type, ResourceType<ECS_TYPE, T> resourceType) {
this .type = type;
this .resourceType = resourceType;
}
public ChangeType getType () {
return this .type;
}
public ResourceType<ECS_TYPE, T> getResourceType () {
return this .resourceType;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .type);
return "ResourceChange{type=" + var10000 + ", resourceChange=" + String.valueOf(this .resourceType) + "}" ;
}
}
com/hypixel/hytale/component/data/change/SystemChange.java
package com.hypixel.hytale.component.data.change;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public class SystemChange <ECS_TYPE> implements DataChange {
private final ChangeType type;
private final ISystem<ECS_TYPE> system;
public SystemChange (ChangeType type, ISystem<ECS_TYPE> system) {
this .type = type;
this .system = system;
}
public ChangeType getType () {
return this .type;
}
public ISystem<ECS_TYPE> getSystem () {
return this .system;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .type);
return "SystemChange{type=" + var10000 + ", system=" + String.valueOf(this .system) + "}" ;
}
}
com/hypixel/hytale/component/data/change/SystemGroupChange.java
package com.hypixel.hytale.component.data.change;
import com.hypixel.hytale.component.SystemGroup;
import javax.annotation.Nonnull;
public class SystemGroupChange <ECS_TYPE> implements DataChange {
private final ChangeType type;
private final SystemGroup<ECS_TYPE> systemGroup;
public SystemGroupChange (ChangeType type, SystemGroup<ECS_TYPE> systemGroup) {
this .type = type;
this .systemGroup = systemGroup;
}
public ChangeType getType () {
return this .type;
}
public SystemGroup<ECS_TYPE> getSystemGroup () {
return this .systemGroup;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .type);
return "SystemGroupChange{type=" + var10000 + ", systemGroup=" + String.valueOf(this .systemGroup) + "}" ;
}
}
com/hypixel/hytale/component/data/change/SystemTypeChange.java
package com.hypixel.hytale.component.data.change;
import com.hypixel.hytale.component.SystemType;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public class SystemTypeChange <ECS_TYPE, T extends ISystem <ECS_TYPE>> implements DataChange {
private final ChangeType type;
private final SystemType<ECS_TYPE, T> systemType;
public SystemTypeChange (ChangeType type, SystemType<ECS_TYPE, T> systemType) {
this .type = type;
this .systemType = systemType;
}
public ChangeType getType () {
return this .type;
}
public SystemType<ECS_TYPE, T> getSystemType () {
return this .systemType;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .type);
return "SystemTypeChange{type=" + var10000 + ", systemType=" + String.valueOf(this .systemType) + "}" ;
}
}
com/hypixel/hytale/component/data/unknown/TempUnknownComponent.java
package com.hypixel.hytale.component.data.unknown;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.function.FunctionCodec;
import com.hypixel.hytale.component.Component;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public class TempUnknownComponent <ECS_TYPE> implements Component <ECS_TYPE> {
public static final Codec<Component> COMPONENT_CODEC;
private BsonDocument document;
public TempUnknownComponent (BsonDocument document) {
this .document = document;
}
public BsonDocument getDocument () {
return this .document;
}
@Nonnull
public Component<ECS_TYPE> clone () {
return new TempUnknownComponent <ECS_TYPE>(this .document.clone());
}
static {
COMPONENT_CODEC = new FunctionCodec (Codec.BSON_DOCUMENT, TempUnknownComponent::new , (component) -> ((TempUnknownComponent)component).document);
}
}
com/hypixel/hytale/component/data/unknown/UnknownComponents.java
package com.hypixel.hytale.component.data.unknown;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.logger.HytaleLogger;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
import org.bson.BsonValue;
public class UnknownComponents <ECS_TYPE> implements Component <ECS_TYPE> {
public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
public static final String ID = "Unknown" ;
public static final BuilderCodec<UnknownComponents> CODEC;
private Map<String, BsonDocument> unknownComponents;
public UnknownComponents () {
this .unknownComponents = new Object2ObjectOpenHashMap <String, BsonDocument>();
}
{
.unknownComponents = unknownComponents;
}
{
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
codec.encode(component, extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
.unknownComponents.put(componentId, bsonValue.asDocument());
}
{
.unknownComponents.put(componentId, component.getDocument());
}
{
.unknownComponents.containsKey(componentId);
}
<T <ECS_TYPE>> T {
(BsonDocument) .unknownComponents.remove(componentId);
(bsonDocument == ) {
;
} {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
codec.decode(bsonDocument, extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
component;
}
}
Map<String, BsonDocument> {
.unknownComponents;
}
Component<ECS_TYPE> {
<ECS_TYPE>( ( .unknownComponents));
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(UnknownComponents.class, UnknownComponents:: ).addField( ( , (Codec.BSON_DOCUMENT, Object2ObjectOpenHashMap:: , )), (o, map) -> o.unknownComponents = map, (o) -> o.unknownComponents)).build();
}
}
com/hypixel/hytale/component/dependency/Dependency.java
package com.hypixel.hytale.component.dependency;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public abstract class Dependency <ECS_TYPE> {
@Nonnull
protected final Order order;
protected final int priority;
public Dependency (@Nonnull Order order, int priority) {
this .order = order;
this .priority = priority;
}
public Dependency (@Nonnull Order order, @Nonnull OrderPriority priority) {
this .order = order;
this .priority = priority.getValue();
}
@Nonnull
public Order getOrder () {
return this .order;
}
public int getPriority () {
return this .priority;
}
public abstract void validate (@Nonnull ComponentRegistry<ECS_TYPE> var1) ;
;
String {
+ String.valueOf( .order) + ;
}
}
com/hypixel/hytale/component/dependency/DependencyGraph.java
package com.hypixel.hytale.component.dependency;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.system.ISystem;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class DependencyGraph <ECS_TYPE> {
@Nonnull
private final ISystem<ECS_TYPE>[] systems;
private final Map<ISystem<ECS_TYPE>, List<Edge<ECS_TYPE>>> beforeSystemEdges = new Object2ObjectOpenHashMap <ISystem<ECS_TYPE>, List<Edge<ECS_TYPE>>>();
private final Map<ISystem<ECS_TYPE>, List<Edge<ECS_TYPE>>> afterSystemEdges = new Object2ObjectOpenHashMap <ISystem<ECS_TYPE>, List<Edge<ECS_TYPE>>>();
private final Map<ISystem<ECS_TYPE>, Set<Edge<ECS_TYPE>>> afterSystemUnfulfilledEdges = new Object2ObjectOpenHashMap <ISystem<ECS_TYPE>, Set<Edge<ECS_TYPE>>>();
private Edge<ECS_TYPE>[] edges = DependencyGraph.Edge.<ECS_TYPE>emptyArray();
public DependencyGraph (@Nonnull ISystem<ECS_TYPE>[] systems) {
this .systems = systems;
for ( ; i < systems.length; ++i) {
ISystem<ECS_TYPE> system = systems[i];
.beforeSystemEdges.put(system, ());
.afterSystemEdges.put(system, ());
.afterSystemUnfulfilledEdges.put(system, ());
}
}
ISystem<ECS_TYPE>[] getSystems() {
.systems;
}
{
(ISystem<ECS_TYPE> system : .systems) {
(Dependency<ECS_TYPE> dependency : system.getDependencies()) {
dependency.resolveGraphEdge(registry, system, );
}
(system.getGroup() != ) {
(Dependency<ECS_TYPE> dependency : system.getGroup().getDependencies()) {
dependency.resolveGraphEdge(registry, system, );
}
}
}
(ISystem<ECS_TYPE> system : .systems) {
(((List) .afterSystemEdges.get(system)).isEmpty()) {
;
List<Edge<ECS_TYPE>> edges = (List) .beforeSystemEdges.get(system);
(Edge<ECS_TYPE> edge : edges) {
priority += edge.priority / edges.size();
}
.addEdgeFromRoot(system, priority);
}
}
}
{
.addEdge( ((ISystem) , afterSystem, priority));
}
{
.addEdge( (beforeSystem, afterSystem, priority));
}
{
Arrays.binarySearch( .edges, edge);
insertionPoint;
(index >= ) {
(insertionPoint = index; insertionPoint < .edges.length && .edges[insertionPoint].priority == edge.priority; ++insertionPoint) {
}
} {
insertionPoint = -(index + );
}
.edges.length;
oldLength + ;
(oldLength < newLength) {
.edges = (Edge[])Arrays.copyOf( .edges, newLength);
}
System.arraycopy( .edges, insertionPoint, .edges, insertionPoint + , oldLength - insertionPoint);
.edges[insertionPoint] = edge;
(edge.beforeSystem != ) {
((List) .beforeSystemEdges.get(edge.beforeSystem)).add(edge);
}
((List) .afterSystemEdges.get(edge.afterSystem)).add(edge);
(!edge.fulfilled) {
((Set) .afterSystemUnfulfilledEdges.get(edge.afterSystem)).add(edge);
}
}
{
;
label52:
(index < .systems.length) {
(Edge<ECS_TYPE> edge : .edges) {
(!edge.resolved && edge.fulfilled) {
ISystem<ECS_TYPE> system = edge.afterSystem;
(((Set) .afterSystemUnfulfilledEdges.get(system)).isEmpty() && ! .hasEdgeOfLaterPriority(system, edge.priority)) {
sortedSystems[index++] = system;
.resolveEdgesFor(system);
.fulfillEdgesFor(system);
label52;
}
}
}
(Edge<ECS_TYPE> edge : .edges) {
(!edge.resolved && edge.fulfilled) {
ISystem<ECS_TYPE> system = edge.afterSystem;
(((Set) .afterSystemUnfulfilledEdges.get(system)).isEmpty()) {
sortedSystems[index++] = system;
.resolveEdgesFor(system);
.fulfillEdgesFor(system);
label52;
}
}
}
( + String.valueOf( ));
}
}
{
(Edge<ECS_TYPE> edge : (List) .afterSystemEdges.get(system)) {
(!edge.resolved && edge.priority > priority) {
;
}
}
;
}
{
(Edge<ECS_TYPE> edge : (List) .afterSystemEdges.get(system)) {
edge.resolved = ;
}
}
{
(Edge<ECS_TYPE> edge : (List) .beforeSystemEdges.get(system)) {
edge.fulfilled = ;
((Set) .afterSystemUnfulfilledEdges.get(edge.afterSystem)).remove(edge);
}
}
String {
Arrays.toString( .systems);
+ var10000 + + Arrays.toString( .edges) + ;
}
<ECS_TYPE> <Edge<ECS_TYPE>> {
Edge<?>[] EMPTY_ARRAY = [ ];
ISystem<ECS_TYPE> beforeSystem;
ISystem<ECS_TYPE> afterSystem;
priority;
fulfilled;
resolved;
<ECS_TYPE> Edge<ECS_TYPE>[] emptyArray() {
EMPTY_ARRAY;
}
{
.beforeSystem = beforeSystem;
.afterSystem = afterSystem;
.priority = priority;
.fulfilled = beforeSystem == ;
}
{
Integer.compare( .priority, o.priority);
}
String {
String.valueOf( .beforeSystem);
+ var10000 + + String.valueOf( .afterSystem) + + .priority + + .fulfilled + + .resolved + ;
}
}
}
com/hypixel/hytale/component/dependency/Order.java
package com.hypixel.hytale.component.dependency;
public enum Order {
BEFORE,
AFTER;
private Order () {
}
}
com/hypixel/hytale/component/dependency/OrderPriority.java
package com.hypixel.hytale.component.dependency;
public enum OrderPriority {
CLOSEST(-1431655764 ),
CLOSE(-715827882 ),
NORMAL(0 ),
FURTHER(715827882 ),
FURTHEST(1431655764 );
private final int value;
private OrderPriority (int value) {
this .value = value;
}
public int getValue () {
return this .value;
}
}
com/hypixel/hytale/component/dependency/RootDependency.java
package com.hypixel.hytale.component.dependency;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.system.ISystem;
import java.util.Set;
import javax.annotation.Nonnull;
public class RootDependency <ECS_TYPE> extends Dependency <ECS_TYPE> {
private static final RootDependency<?> FIRST;
private static final RootDependency<?> LAST;
private static final Set<Dependency<?>> FIRST_SET;
private static final Set<Dependency<?>> LAST_SET;
public static <ECS_TYPE> RootDependency<ECS_TYPE> first () {
return FIRST;
}
public static <ECS_TYPE> RootDependency<ECS_TYPE> last () {
return LAST;
}
public static <ECS_TYPE> Set<Dependency<ECS_TYPE>> firstSet () {
return FIRST_SET;
}
public static <ECS_TYPE> Set<Dependency<ECS_TYPE>> lastSet () {
return LAST_SET;
}
public RootDependency {
(Order.AFTER, priority);
}
{
(Order.AFTER, priority);
}
{
}
{
( .order == Order.BEFORE) {
( );
} {
graph.addEdgeFromRoot(thisSystem, .priority);
}
}
String {
+ .toString();
}
{
FIRST = (OrderPriority.CLOSEST);
LAST = (OrderPriority.FURTHEST);
FIRST_SET = Set.of(FIRST);
LAST_SET = Set.of(LAST);
}
}
com/hypixel/hytale/component/dependency/SystemDependency.java
package com.hypixel.hytale.component.dependency;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public class SystemDependency <ECS_TYPE, T extends ISystem <ECS_TYPE>> extends Dependency <ECS_TYPE> {
@Nonnull
private final Class<T> systemClass;
public SystemDependency (@Nonnull Order order, @Nonnull Class<T> systemClass) {
this (order, systemClass, OrderPriority.NORMAL);
}
public SystemDependency (@Nonnull Order order, @Nonnull Class<T> systemClass, int priority) {
super (order, priority);
this .systemClass = systemClass;
}
public SystemDependency (@Nonnull Order order, @Nonnull Class<T> systemClass, @Nonnull OrderPriority priority) {
super (order, priority);
this .systemClass = systemClass;
}
@Nonnull
public Class<T> getSystemClass () {
return this .systemClass;
}
public {
(!registry.hasSystemClass( .systemClass)) {
( + String.valueOf( .systemClass));
}
}
{
( .order) {
BEFORE:
(ISystem<ECS_TYPE> system : graph.getSystems()) {
( .systemClass.equals(system.getClass())) {
graph.addEdge(thisSystem, system, - .priority);
}
}
;
AFTER:
(ISystem<ECS_TYPE> system : graph.getSystems()) {
( .systemClass.equals(system.getClass())) {
graph.addEdge(system, thisSystem, .priority);
}
}
}
}
String {
String.valueOf( .systemClass);
+ var10000 + + .toString();
}
}
com/hypixel/hytale/component/dependency/SystemGroupDependency.java
package com.hypixel.hytale.component.dependency;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public class SystemGroupDependency <ECS_TYPE> extends Dependency <ECS_TYPE> {
@Nonnull
private final SystemGroup<ECS_TYPE> group;
public SystemGroupDependency (@Nonnull Order order, @Nonnull SystemGroup<ECS_TYPE> group) {
this (order, group, OrderPriority.NORMAL);
}
public SystemGroupDependency (@Nonnull Order order, @Nonnull SystemGroup<ECS_TYPE> group, int priority) {
super (order, priority);
this .group = group;
}
public SystemGroupDependency (@Nonnull Order order, @Nonnull SystemGroup<ECS_TYPE> group, @Nonnull OrderPriority priority) {
super (order, priority);
this .group = group;
}
@Nonnull
public SystemGroup<ECS_TYPE> getGroup () {
return this .group;
}
public {
(!registry.hasSystemGroup( .group)) {
( + String.valueOf( .group));
}
}
{
( .order) {
BEFORE:
(ISystem<ECS_TYPE> system : graph.getSystems()) {
( .group.equals(system.getGroup())) {
graph.addEdge(thisSystem, system, - .priority);
}
}
;
AFTER:
(ISystem<ECS_TYPE> system : graph.getSystems()) {
( .group.equals(system.getGroup())) {
graph.addEdge(system, thisSystem, .priority);
}
}
}
}
String {
String.valueOf( .group);
+ var10000 + + .toString();
}
}
com/hypixel/hytale/component/dependency/SystemTypeDependency.java
package com.hypixel.hytale.component.dependency;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.SystemType;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public class SystemTypeDependency <ECS_TYPE, T extends ISystem <ECS_TYPE>> extends Dependency <ECS_TYPE> {
@Nonnull
private final SystemType<ECS_TYPE, T> systemType;
public SystemTypeDependency (@Nonnull Order order, @Nonnull SystemType<ECS_TYPE, T> systemType) {
this (order, systemType, OrderPriority.NORMAL);
}
public SystemTypeDependency (@Nonnull Order order, @Nonnull SystemType<ECS_TYPE, T> systemType, int priority) {
super (order, priority);
this .systemType = systemType;
}
public SystemTypeDependency (@Nonnull Order order, @Nonnull SystemType<ECS_TYPE, T> systemType, @Nonnull OrderPriority priority) {
super (order, priority);
this .systemType = systemType;
}
@Nonnull
public SystemType<ECS_TYPE, T> getSystemType () {
.systemType;
}
{
(!registry.hasSystemType( .systemType)) {
( + String.valueOf( .systemType));
}
}
{
( .order) {
BEFORE:
(ISystem<ECS_TYPE> system : graph.getSystems()) {
( .systemType.isType(system)) {
graph.addEdge(thisSystem, system, - .priority);
}
}
;
AFTER:
(ISystem<ECS_TYPE> system : graph.getSystems()) {
( .systemType.isType(system)) {
graph.addEdge(system, thisSystem, .priority);
}
}
}
}
String {
String.valueOf( .systemType);
+ var10000 + + .toString();
}
}
com/hypixel/hytale/component/event/EntityEventType.java
package com.hypixel.hytale.component.event;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.EntityEventSystem;
import javax.annotation.Nonnull;
public class EntityEventType <ECS_TYPE, Event extends EcsEvent > extends EventSystemType <ECS_TYPE, Event, EntityEventSystem<ECS_TYPE, Event>> {
public EntityEventType (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super EntityEventSystem<ECS_TYPE, Event>> tClass, @Nonnull Class<Event> eClass, int index) {
super (registry, tClass, eClass, index);
}
}
com/hypixel/hytale/component/event/EventSystemType.java
package com.hypixel.hytale.component.event;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.SystemType;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.EventSystem;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public abstract class EventSystemType <ECS_TYPE, Event extends EcsEvent , SYSTEM_TYPE extends EventSystem <Event> & ISystem<ECS_TYPE>> extends SystemType <ECS_TYPE, SYSTEM_TYPE> {
@Nonnull
private final Class<Event> eClass;
protected EventSystemType (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super SYSTEM_TYPE> tClass, @Nonnull Class<Event> eClass, int index) {
super (registry, tClass, index);
this .eClass = eClass;
}
@Nonnull
public Class<Event> getEventClass () {
return this .eClass;
}
public boolean isType (@Nonnull ISystem<ECS_TYPE> system) {
if (!super .isType(system)) {
;
} (system EventSystem) {
EventSystem<?> eventSystem = (EventSystem)system;
.eClass.equals(eventSystem.getEventType());
} {
;
}
}
}
com/hypixel/hytale/component/event/WorldEventType.java
package com.hypixel.hytale.component.event;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.component.system.WorldEventSystem;
import javax.annotation.Nonnull;
public class WorldEventType <ECS_TYPE, Event extends EcsEvent > extends EventSystemType <ECS_TYPE, Event, WorldEventSystem<ECS_TYPE, Event>> {
public WorldEventType (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super WorldEventSystem<ECS_TYPE, Event>> tClass, @Nonnull Class<Event> eClass, int index) {
super (registry, tClass, eClass, index);
}
}
com/hypixel/hytale/component/metric/ArchetypeChunkData.java
package com.hypixel.hytale.component.metric;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
public class ArchetypeChunkData {
@Nonnull
public static final Codec<ArchetypeChunkData> CODEC;
@Nonnull
private String[] componentTypes = new String [0 ];
private int entityCount;
public ArchetypeChunkData () {
}
public ArchetypeChunkData (@Nonnull String[] componentTypes, int entityCount) {
this .componentTypes = componentTypes;
this .entityCount = entityCount;
}
@Nonnull
public String[] getComponentTypes() {
return this .componentTypes;
}
public int getEntityCount () {
return this .entityCount;
}
static {
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ArchetypeChunkData.class, ArchetypeChunkData::new ).append(new KeyedCodec ( , Codec.STRING_ARRAY), (data, o) -> data.componentTypes = o, (data) -> data.componentTypes).add()).append( ( , Codec.INTEGER), (data, o) -> data.entityCount = o, (data) -> data.entityCount).add()).build();
}
}
com/hypixel/hytale/component/metric/SystemMetricData.java
package com.hypixel.hytale.component.metric;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.metrics.metric.HistoricMetric;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class SystemMetricData {
@Nonnull
public static final Codec<SystemMetricData> CODEC;
private String name;
private int archetypeChunkCount;
private int entityCount;
@Nullable
private HistoricMetric historicMetric;
private MetricResults metrics;
public SystemMetricData () {
}
public SystemMetricData (@Nonnull String name, int archetypeChunkCount, int entityCount, @Nullable HistoricMetric historicMetric, @Nonnull MetricResults metrics) {
this .name = name;
this .archetypeChunkCount = archetypeChunkCount;
this .entityCount = entityCount;
this .historicMetric = historicMetric;
this .metrics = metrics;
}
static {
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(SystemMetricData.class, SystemMetricData:: ).append( ( , Codec.STRING), (systemMetricData, o) -> systemMetricData.name = o, (systemMetricData) -> systemMetricData.name).add()).append( ( , Codec.INTEGER), (systemMetricData, o) -> systemMetricData.archetypeChunkCount = o, (systemMetricData) -> systemMetricData.archetypeChunkCount).add()).append( ( , Codec.INTEGER), (systemMetricData, o) -> systemMetricData.entityCount = o, (systemMetricData) -> systemMetricData.entityCount).add()).append( ( , HistoricMetric.METRICS_CODEC), (systemMetricData, o) -> systemMetricData.historicMetric = o, (systemMetricData) -> systemMetricData.historicMetric).add()).append( ( , MetricResults.CODEC), (systemMetricData, o) -> systemMetricData.metrics = o, (systemMetricData) -> systemMetricData.metrics).add()).build();
}
}
com/hypixel/hytale/component/query/AndQuery.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
public class AndQuery <ECS_TYPE> implements Query <ECS_TYPE> {
private final Query<ECS_TYPE>[] queries;
@SafeVarargs
public AndQuery (Query<ECS_TYPE>... queries) {
this .queries = queries;
}
public boolean test (Archetype<ECS_TYPE> archetype) {
for (Query<ECS_TYPE> query : this .queries) {
if (!query.test(archetype)) {
return false ;
}
}
return true ;
}
public boolean requiresComponentType (ComponentType<ECS_TYPE, ?> componentType) {
for (Query<ECS_TYPE> query : this .queries) {
if (query.requiresComponentType(componentType)) {
return true ;
}
}
return false ;
}
public void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
(Query<ECS_TYPE> query : .queries) {
query.validateRegistry(registry);
}
}
{
(Query<ECS_TYPE> query : .queries) {
query.validate();
}
}
}
com/hypixel/hytale/component/query/AnyQuery.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
class AnyQuery <ECS_TYPE> implements Query <ECS_TYPE> {
static final AnyQuery<?> INSTANCE = new AnyQuery ();
AnyQuery() {
}
public boolean test (Archetype<ECS_TYPE> archetype) {
return true ;
}
public boolean requiresComponentType (ComponentType<ECS_TYPE, ?> componentType) {
return false ;
}
public void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
}
public void validate () {
}
}
com/hypixel/hytale/component/query/ExactArchetypeQuery.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
import javax.annotation.Nonnull;
public class ExactArchetypeQuery <ECS_TYPE> implements Query <ECS_TYPE> {
private final Archetype<ECS_TYPE> archetype;
public ExactArchetypeQuery (Archetype<ECS_TYPE> archetype) {
this .archetype = archetype;
}
public Archetype<ECS_TYPE> getArchetype () {
return this .archetype;
}
public boolean test (@Nonnull Archetype<ECS_TYPE> archetype) {
return archetype.equals(this .archetype);
}
public boolean requiresComponentType (@Nonnull ComponentType<ECS_TYPE, ?> componentType) {
return this .archetype.requiresComponentType(componentType);
}
public void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
this .archetype.validateRegistry(registry);
}
public void {
.archetype.validate();
}
}
com/hypixel/hytale/component/query/NotQuery.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
public class NotQuery <ECS_TYPE> implements Query <ECS_TYPE> {
private final Query<ECS_TYPE> query;
public NotQuery (Query<ECS_TYPE> query) {
this .query = query;
}
public boolean test (Archetype<ECS_TYPE> archetype) {
return !this .query.test(archetype);
}
public boolean requiresComponentType (ComponentType<ECS_TYPE, ?> componentType) {
return this .query.requiresComponentType(componentType);
}
public void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
this .query.validateRegistry(registry);
}
public void validate () {
this .query.validate();
}
}
com/hypixel/hytale/component/query/OrQuery.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
public class OrQuery <ECS_TYPE> implements Query <ECS_TYPE> {
private final Query<ECS_TYPE>[] queries;
public OrQuery (Query<ECS_TYPE>... queries) {
this .queries = queries;
}
public boolean test (Archetype<ECS_TYPE> archetype) {
for (Query<ECS_TYPE> query : this .queries) {
if (query.test(archetype)) {
return true ;
}
}
return false ;
}
public boolean requiresComponentType (ComponentType<ECS_TYPE, ?> componentType) {
for (Query<ECS_TYPE> query : this .queries) {
if (query.requiresComponentType(componentType)) {
return true ;
}
}
return false ;
}
public void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
for (Query<ECS_TYPE> query : .queries) {
query.validateRegistry(registry);
}
}
{
(Query<ECS_TYPE> query : .queries) {
query.validate();
}
}
}
com/hypixel/hytale/component/query/Query.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
import javax.annotation.Nonnull;
public interface Query <ECS_TYPE> {
@Nonnull
static <ECS_TYPE> AnyQuery<ECS_TYPE> any () {
return AnyQuery.INSTANCE;
}
@Nonnull
static <ECS_TYPE> NotQuery<ECS_TYPE> not (Query<ECS_TYPE> query) {
return new NotQuery <ECS_TYPE>(query);
}
@Nonnull
@SafeVarargs
static <ECS_TYPE> AndQuery<ECS_TYPE> and (Query<ECS_TYPE>... queries) {
return new AndQuery <ECS_TYPE>(queries);
}
@Nonnull
@SafeVarargs
static <ECS_TYPE> OrQuery<ECS_TYPE> or (Query<ECS_TYPE>... queries) {
return new OrQuery <ECS_TYPE>(queries);
}
boolean test (Archetype<ECS_TYPE> var1) ;
boolean requiresComponentType (ComponentType<ECS_TYPE, ?> var1) ;
void ;
;
}
com/hypixel/hytale/component/query/ReadWriteArchetypeQuery.java
package com.hypixel.hytale.component.query;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
import javax.annotation.Nonnull;
public interface ReadWriteArchetypeQuery <ECS_TYPE> extends Query <ECS_TYPE> {
Archetype<ECS_TYPE> getReadArchetype () ;
Archetype<ECS_TYPE> getWriteArchetype () ;
default boolean test (@Nonnull Archetype<ECS_TYPE> archetype) {
return archetype.contains(this .getReadArchetype()) && archetype.contains(this .getWriteArchetype());
}
default boolean requiresComponentType (@Nonnull ComponentType<ECS_TYPE, ?> componentType) {
return this .getReadArchetype().contains(componentType) || this .getWriteArchetype().contains(componentType);
}
default void validateRegistry (ComponentRegistry<ECS_TYPE> registry) {
this .getReadArchetype().validateRegistry(registry);
this .getWriteArchetype().validateRegistry(registry);
}
default void validate () {
this .getReadArchetype().validate();
.getWriteArchetype().validate();
}
}
com/hypixel/hytale/component/spatial/KDTree.java
package com.hypixel.hytale.component.spatial;
import com.hypixel.hytale.math.vector.Vector3d;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class KDTree <T> implements SpatialStructure <T> {
@Nonnull
private final List<Node<T>> nodePool = new ObjectArrayList <Node<T>>();
private int nodePoolIndex = 0 ;
@Nonnull
private final List<List<T>> dataListPool = new ObjectArrayList <List<T>>();
private int dataListPoolIndex = 0 ;
private int size;
@Nonnull
private final Predicate<T> collectionFilter;
@Nullable
private Node<T> root;
public KDTree (@Nonnull Predicate<T> collectionFilter) {
this .collectionFilter = collectionFilter;
}
{
.size;
}
{
.root = ;
.size = ;
spatialData.size();
(spatialDataSize != ) {
( ; i < .dataListPoolIndex; ++i) {
((List) .dataListPool.get(i)).clear();
}
.nodePoolIndex = ;
.dataListPoolIndex = ;
spatialData.sortMorton();
spatialDataSize / ;
spatialData.getSortedIndex(mid);
spatialData.getVector(sortedIndex);
spatialData.getData(sortedIndex);
List<T> list = .getPooledDataList();
list.add(data);
left;
(left = mid - ; left >= ; --left) {
spatialData.getSortedIndex(left);
spatialData.getVector(leftSortedIndex);
(!leftVector.equals(vector)) {
;
}
spatialData.getData(leftSortedIndex);
list.add(leftData);
}
right;
(right = mid + ; right < spatialDataSize; ++right) {
spatialData.getSortedIndex(right);
spatialData.getVector(rightSortedIndex);
(!rightVector.equals(vector)) {
;
}
spatialData.getData(rightSortedIndex);
list.add(rightData);
}
.root = .getPooledNode(vector, list);
( < left + ) {
.build0(spatialData, , left + );
}
(right < spatialDataSize) {
.build0(spatialData, right, spatialDataSize);
}
.size = spatialDataSize;
}
}
T {
ClosestState<T> closestState = <T>((Node) , );
.closest0(closestState, .root, point, );
(T)(closestState.node == ? : closestState.node.data.getFirst());
}
{
radius * radius;
.collect0(results, .root, center, distanceSq, );
}
{
radius * radius;
height / ;
.collectCylinder0(results, .root, center, radiusSq, halfHeight, radius, );
}
{
.collectBox0(results, .root, min, max, );
}
{
radius * radius;
ObjectArrayList<OrderedEntry<T>> entryResults = <OrderedEntry<T>>();
.ordered0(entryResults, .root, center, distanceSq, );
entryResults.sort(Comparator.comparingDouble((o) -> o.distanceSq));
(OrderedEntry<T> entry : entryResults) {
;
( entry.values.size(); i < bound; ++i) {
(T)entry.values.get(i);
( .collectionFilter.test(data)) {
results.add(data);
}
}
}
}
{
ObjectArrayList<OrderedEntry<T>> entryResults = <OrderedEntry<T>>();
._internal_ordered3DAxis(entryResults, .root, center, xSearchRadius, YSearchRadius, zSearchRadius, );
entryResults.sort(Comparator.comparingDouble((o) -> o.distanceSq));
(OrderedEntry<T> entry : entryResults) {
;
( entry.values.size(); i < bound; ++i) {
(T)entry.values.get(i);
( .collectionFilter.test(data)) {
results.add(data);
}
}
}
}
String {
.size;
+ var10000 + + ( .root == ? : .root.dump( ));
}
Node<T> {
( .nodePoolIndex < .nodePool.size()) {
Node<T> node = (Node) .nodePool.get( .nodePoolIndex++);
node.reset(vector, data);
node;
} {
Node<T> node = <T>(vector, data);
.nodePool.add(node);
++ .nodePoolIndex;
node;
}
}
List<T> {
( .dataListPoolIndex < .dataListPool.size()) {
(List) .dataListPool.get( .dataListPoolIndex++);
} {
ObjectArrayList<T> set = <T>( );
.dataListPool.add(set);
++ .dataListPoolIndex;
set;
}
}
{
(start + end) / ;
spatialData.getSortedIndex(mid);
spatialData.getVector(sortedIndex);
spatialData.getData(sortedIndex);
List<T> list = .getPooledDataList();
list.add(data);
left;
(left = mid - ; left >= start; --left) {
spatialData.getSortedIndex(left);
spatialData.getVector(leftSortedIndex);
(!leftVector.equals(vector)) {
;
}
spatialData.getData(leftSortedIndex);
list.add(leftData);
}
right;
(right = mid + ; right < end; ++right) {
spatialData.getSortedIndex(right);
spatialData.getVector(rightSortedIndex);
(!rightVector.equals(vector)) {
;
}
spatialData.getData(rightSortedIndex);
list.add(rightData);
}
.put0( .root, vector, list, );
(start < left + ) {
.build0(spatialData, start, left + );
}
(right < end) {
.build0(spatialData, right, end);
}
}
{
(compare(node.vector, vector, axis) < ) {
(node.one == ) {
node.one = .getPooledNode(vector, list);
} {
.put0(node.one, vector, list, (axis + ) % );
}
} (node.two == ) {
node.two = .getPooledNode(vector, list);
} {
.put0(node.two, vector, list, (axis + ) % );
}
}
{
(node != ) {
(vector.equals(node.vector)) {
closestState.distanceSq = ;
closestState.node = node;
} {
depth % ;
compare(node.vector, vector, axis);
node.vector.distanceSquaredTo(vector);
(distanceSq < closestState.distanceSq) {
closestState.node = node;
closestState.distanceSq = distanceSq;
}
depth + ;
(compare < ) {
.closest0(closestState, node.one, vector, newDepth);
} {
.closest0(closestState, node.two, vector, newDepth);
}
get(node.vector, axis);
get(closestState.node.vector, axis);
Math.abs(component - plane);
(planeDistance * planeDistance < closestState.distanceSq) {
(compare < ) {
.closest0(closestState, node.two, vector, newDepth);
} {
.closest0(closestState, node.one, vector, newDepth);
}
}
}
}
}
{
(node != ) {
depth % ;
compare(node.vector, vector, axis);
node.vector.distanceSquaredTo(vector);
(nodeDistanceSq < distanceSq) {
;
( node.data.size(); i < bound; ++i) {
(T)node.data.get(i);
( .collectionFilter.test(data)) {
results.add(data);
}
}
}
depth + ;
(compare < ) {
.collect0(results, node.one, vector, distanceSq, newDepth);
} {
.collect0(results, node.two, vector, distanceSq, newDepth);
}
get(node.vector, axis);
get(vector, axis);
Math.abs(component - plane);
(planeDistance * planeDistance < distanceSq) {
(compare < ) {
.collect0(results, node.two, vector, distanceSq, newDepth);
} {
.collect0(results, node.one, vector, distanceSq, newDepth);
}
}
}
}
{
(node != ) {
depth % ;
compare(node.vector, center, axis);
node.vector.y - center.y;
(Math.abs(dy) <= halfHeight) {
node.vector.x - center.x;
node.vector.z - center.z;
dx * dx + dz * dz;
(xzDistanceSq <= radiusSq) {
;
( node.data.size(); i < bound; ++i) {
(T)node.data.get(i);
( .collectionFilter.test(data)) {
results.add(data);
}
}
}
}
depth + ;
(compare < ) {
.collectCylinder0(results, node.one, center, radiusSq, halfHeight, radius, newDepth);
} {
.collectCylinder0(results, node.two, center, radiusSq, halfHeight, radius, newDepth);
}
get(node.vector, axis);
get(center, axis);
axis == ? halfHeight : radius;
(Math.abs(component - plane) <= axisRadius) {
(compare < ) {
.collectCylinder0(results, node.two, center, radiusSq, halfHeight, radius, newDepth);
} {
.collectCylinder0(results, node.one, center, radiusSq, halfHeight, radius, newDepth);
}
}
}
}
{
(node != ) {
depth % ;
(node.vector.x >= min.x && node.vector.x <= max.x && node.vector.y >= min.y && node.vector.y <= max.y && node.vector.z >= min.z && node.vector.z <= max.z) {
;
( node.data.size(); i < bound; ++i) {
(T)node.data.get(i);
( .collectionFilter.test(data)) {
results.add(data);
}
}
}
depth + ;
get(node.vector, axis);
get(min, axis);
get(max, axis);
(maxComponent >= plane) {
.collectBox0(results, node.one, min, max, newDepth);
}
(minComponent <= plane) {
.collectBox0(results, node.two, min, max, newDepth);
}
}
}
{
(node != ) {
depth % ;
compare(node.vector, vector, axis);
node.vector.distanceSquaredTo(vector);
(nodeDistanceSq < distanceSq) {
results.add( (nodeDistanceSq, node.data));
}
depth + ;
(compare < ) {
.ordered0(results, node.one, vector, distanceSq, newDepth);
} {
.ordered0(results, node.two, vector, distanceSq, newDepth);
}
get(node.vector, axis);
get(vector, axis);
Math.abs(component - plane);
(planeDistance * planeDistance < distanceSq) {
(compare < ) {
.ordered0(results, node.two, vector, distanceSq, newDepth);
} {
.ordered0(results, node.one, vector, distanceSq, newDepth);
}
}
}
}
{
(node != ) {
depth % ;
node.vector.x >= center.x - xSearchRadius && node.vector.x <= center.x + xSearchRadius && node.vector.y >= center.y - ySearchRadius && node.vector.y <= center.y + ySearchRadius && node.vector.z >= center.z - zSearchRadius && node.vector.z <= center.z + zSearchRadius;
(inCuboid) {
node.vector.distanceSquaredTo(center);
results.add( (nodeDistanceSq, node.data));
}
depth + ;
compare(node.vector, center, axis);
Node<T> primary = compare < ? node.one : node.two;
Node<T> secondary = compare < ? node.two : node.one;
._internal_ordered3DAxis(results, primary, center, xSearchRadius, ySearchRadius, zSearchRadius, newDepth);
get(node.vector, axis);
get(center, axis);
axis == ? xSearchRadius : (axis == ? ySearchRadius : zSearchRadius);
(Math.abs(component - plane) <= radius) {
._internal_ordered3DAxis(results, secondary, center, xSearchRadius, ySearchRadius, zSearchRadius, newDepth);
}
}
}
{
var10000;
(axis) {
-> var10000 = Double.compare(v1.x, v2.x);
-> var10000 = Double.compare(v1.z, v2.z);
-> var10000 = Double.compare(v1.y, v2.y);
-> ( + axis);
}
var10000;
}
{
var10000;
(axis) {
-> var10000 = v.x;
-> var10000 = v.z;
-> var10000 = v.y;
-> ( + axis);
}
var10000;
}
<T> {
Vector3d vector;
List<T> data;
Node<T> one;
Node<T> two;
{
.vector = vector;
.data = data;
}
{
.vector = vector;
.data = data;
.one = ;
.two = ;
}
String {
depth + ;
String.valueOf( .vector);
+ var10000 + + String.valueOf( .data) + + .repeat(depth) + + ( .one == ? : .one.dump(nextDepth)) + + .repeat(depth) + + ( .two == ? : .two.dump(nextDepth));
}
}
<T> {
Node<T> node;
distanceSq;
{
.node = node;
.distanceSq = distanceSq;
}
}
<T> {
distanceSq;
List<T> values;
{
.distanceSq = distanceSq;
.values = values;
}
}
}
com/hypixel/hytale/component/spatial/MortonCode.java
package com.hypixel.hytale.component.spatial;
public class MortonCode {
private static final int BITS_PER_AXIS = 21 ;
private static final long MAX_COORD = 2097151L ;
public MortonCode () {
}
public static long encode (double x, double y, double z, double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
double nx = (x - minX) / (maxX - minX);
double ny = (y - minY) / (maxY - minY);
double nz = (z - minZ) / (maxZ - minZ);
long ix = Math.min(Math.max((long )(nx * 2097151.0 ), 0L ), 2097151L );
long Math.min(Math.max(( )(ny * ), ), );
Math.min(Math.max(( )(nz * ), ), );
interleaveBits(ix, iy, iz);
}
{
x = expandBits(x);
y = expandBits(y);
z = expandBits(z);
x | y << | z << ;
}
{
value &= ;
value = (value | value << ) & ;
value = (value | value << ) & ;
value = (value | value << ) & ;
value = (value | value << ) & ;
value = (value | value << ) & ;
value;
}
}
com/hypixel/hytale/component/spatial/SpatialData.java
package com.hypixel.hytale.component.spatial;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import it.unimi.dsi.fastutil.ints.IntArrays;
import java.util.Arrays;
import java.util.Objects;
import javax.annotation.Nonnull;
public class SpatialData <T> {
public static final Vector3d[] EMPTY_VECTOR_ARRAY = new Vector3d [0 ];
@Nonnull
private int [] indexes;
@Nonnull
private long [] moroton;
private Vector3d[] vectors;
@Nonnull
private T[] data;
private int size;
public SpatialData () {
this .indexes = ArrayUtil.EMPTY_INT_ARRAY;
this .moroton = ArrayUtil.EMPTY_LONG_ARRAY;
this .vectors = EMPTY_VECTOR_ARRAY;
this .data = (T[])ArrayUtil.emptyArray();
}
public int size () {
return this .size;
}
public int getSortedIndex (int i) {
.indexes[i];
}
Vector3d {
.vectors[i];
}
T {
(T) .data[i];
}
{
Objects.requireNonNull(value);
( .vectors.length < .size + ) {
ArrayUtil.grow( .size);
.indexes = Arrays.copyOf( .indexes, newLength);
.vectors = (Vector3d[])Arrays.copyOf( .vectors, newLength);
.data = (T[])Arrays.copyOf( .data, newLength);
( .size; i < newLength; ++i) {
.vectors[i] = ();
}
}
.size++;
.indexes[index] = index;
.vectors[index].assign(vector);
.data[index] = value;
}
{
.size + additionalSize;
( .vectors.length < newSize) {
ArrayUtil.grow(newSize);
.indexes = Arrays.copyOf( .indexes, newLength);
.vectors = (Vector3d[])Arrays.copyOf( .vectors, newLength);
.data = (T[])Arrays.copyOf( .data, newLength);
( .size; i < newLength; ++i) {
.vectors[i] = ();
}
}
}
{
Objects.requireNonNull(value);
.size++;
.indexes[index] = index;
.vectors[index].assign(vector);
.data[index] = value;
}
{
IntArrays.quickSort( .indexes, , .size, (i1, i2) -> {
.vectors[i1];
.vectors[i2];
Double.compare(v1.x, v2.x);
(xComp != ) {
xComp;
} {
Double.compare(v1.z, v2.z);
zComp != ? zComp : Double.compare(v1.y, v2.y);
}
});
}
{
/ ;
/ ;
/ ;
- / ;
- / ;
- / ;
( ; i < .size; ++i) {
.vectors[i];
(v.x < minX) {
minX = v.x;
}
(v.y < minY) {
minY = v.y;
}
(v.z < minZ) {
minZ = v.z;
}
(v.x > maxX) {
maxX = v.x;
}
(v.y > maxY) {
maxY = v.y;
}
(v.z > maxZ) {
maxZ = v.z;
}
}
.moroton = .moroton.length < .size ? Arrays.copyOf( .moroton, .size) : .moroton;
( ; i < .size; ++i) {
.vectors[i];
.moroton[i] = Long.reverse(MortonCode.encode(v.x, v.y, v.z, minX, minY, minZ, maxX, maxY, maxZ));
}
IntArrays.quickSort( .indexes, , .size, (i1, i2) -> Long.compare( .moroton[i1], .moroton[i2]));
}
{
Arrays.fill( .data, , .size, (Object) );
.size = ;
}
}
com/hypixel/hytale/component/spatial/SpatialResource.java
package com.hypixel.hytale.component.spatial;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Resource;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectList;
import javax.annotation.Nonnull;
public class SpatialResource <T, ECS_TYPE> implements Resource <ECS_TYPE> {
@Nonnull
private static final ThreadLocal<ObjectList<Ref<?>>> THREAD_LOCAL_REFERENCE_LIST = ThreadLocal.withInitial(ObjectArrayList::new );
@Nonnull
private final SpatialData<Ref<ECS_TYPE>> spatialData = new SpatialData <Ref<ECS_TYPE>>();
@Nonnull
private final SpatialStructure<T> spatialStructure;
@Nonnull
public static <ECS_TYPE> ObjectList<Ref<ECS_TYPE>> getThreadLocalReferenceList () {
ObjectList list = (ObjectList)THREAD_LOCAL_REFERENCE_LIST.get();
list.clear();
return list;
}
public SpatialResource (@Nonnull SpatialStructure<T> spatialStructure) {
this .spatialStructure = spatialStructure;
}
@Nonnull
public SpatialData<Ref<ECS_TYPE>> {
.spatialData;
}
SpatialStructure<T> {
.spatialStructure;
}
Resource<ECS_TYPE> {
( );
}
}
com/hypixel/hytale/component/spatial/SpatialStructure.java
package com.hypixel.hytale.component.spatial;
import com.hypixel.hytale.math.vector.Vector3d;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface SpatialStructure <T> {
int size () ;
void rebuild (@Nonnull SpatialData<T> var1) ;
@Nullable
T closest (@Nonnull Vector3d var1) ;
void collect (@Nonnull Vector3d var1, double var2, @Nonnull List<T> var4) ;
void collectCylinder (@Nonnull Vector3d var1, double var2, double var4, @Nonnull List<T> var6) ;
void collectBox (@Nonnull Vector3d var1, @Nonnull Vector3d var2, @Nonnull List<T> var3) ;
void ordered (@Nonnull Vector3d var1, double var2, @Nonnull List<T> var4) ;
void ordered3DAxis (@Nonnull Vector3d var1, var2, var4, var6, List<T> var8) ;
String ;
}
com/hypixel/hytale/component/spatial/SpatialSystem.java
package com.hypixel.hytale.component.spatial;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.QuerySystem;
import com.hypixel.hytale.component.system.tick.TickingSystem;
import com.hypixel.hytale.math.vector.Vector3d;
import java.util.function.BiConsumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class SpatialSystem <ECS_TYPE> extends TickingSystem <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
@Nonnull
private final ResourceType<ECS_TYPE, SpatialResource<Ref<ECS_TYPE>, ECS_TYPE>> resourceType;
public SpatialSystem (@Nonnull ResourceType<ECS_TYPE, SpatialResource<Ref<ECS_TYPE>, ECS_TYPE>> resourceType) {
this .resourceType = resourceType;
}
public void tick (float dt, int systemIndex, @Nonnull Store<ECS_TYPE> store) {
SpatialResource<Ref<ECS_TYPE>, ECS_TYPE> spatialResource = (SpatialResource)store.getResource(this .resourceType);
SpatialData<Ref<ECS_TYPE>> spatialData = spatialResource.getSpatialData();
spatialData.clear();
store.forEachChunk(systemIndex, (BiConsumer)((archetypeChunk, commandBuffer) -> {
int archetypeChunk.size();
spatialData.addCapacity(size);
( ; index < size; ++index) {
.getPosition(archetypeChunk, index);
(position != ) {
Ref<ECS_TYPE> ref = archetypeChunk.getReferenceTo(index);
spatialData.append(position, ref);
}
}
}));
spatialResource.getSpatialStructure().rebuild(spatialData);
}
Vector3d ;
}
com/hypixel/hytale/component/system/ArchetypeChunkSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.ArchetypeChunk;
public abstract class ArchetypeChunkSystem <ECS_TYPE> extends System <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
public ArchetypeChunkSystem () {
}
public abstract void onSystemAddedToArchetypeChunk (ArchetypeChunk<ECS_TYPE> var1) ;
public abstract void onSystemRemovedFromArchetypeChunk (ArchetypeChunk<ECS_TYPE> var1) ;
}
com/hypixel/hytale/component/system/CancellableEcsEvent.java
package com.hypixel.hytale.component.system;
public abstract class CancellableEcsEvent extends EcsEvent implements ICancellableEcsEvent {
private boolean cancelled = false ;
public CancellableEcsEvent () {
}
public final boolean isCancelled () {
return this .cancelled;
}
public final void setCancelled (boolean cancelled) {
this .cancelled = cancelled;
}
}
com/hypixel/hytale/component/system/DelayedSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.tick.TickingSystem;
import javax.annotation.Nonnull;
public abstract class DelayedSystem <ECS_TYPE> extends TickingSystem <ECS_TYPE> {
@Nonnull
private final ResourceType<ECS_TYPE, Data<ECS_TYPE>> resourceType = this .registerResource(Data.class, Data::new );
private final float intervalSec;
public DelayedSystem (float intervalSec) {
this .intervalSec = intervalSec;
}
@Nonnull
public ResourceType<ECS_TYPE, Data<ECS_TYPE>> getResourceType () {
return this .resourceType;
}
public float getIntervalSec () {
return this .intervalSec;
}
public void tick (float dt, int systemIndex, @Nonnull Store<ECS_TYPE> store) {
Data<ECS_TYPE> data = (Data)store.getResource( .resourceType);
data.dt += dt;
(data.dt >= .intervalSec) {
data.dt;
data.dt = ;
.delayedTick(fullDeltaTime, systemIndex, store);
}
}
;
<ECS_TYPE> <ECS_TYPE> {
dt;
{
}
Resource<ECS_TYPE> {
Data<ECS_TYPE> data = <ECS_TYPE>();
data.dt = .dt;
data;
}
}
}
com/hypixel/hytale/component/system/EcsEvent.java
package com.hypixel.hytale.component.system;
public abstract class EcsEvent {
public EcsEvent () {
}
}
com/hypixel/hytale/component/system/EntityEventSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
public abstract class EntityEventSystem <ECS_TYPE, EventType extends EcsEvent > extends EventSystem <EventType> implements QuerySystem <ECS_TYPE> {
protected EntityEventSystem (@Nonnull Class<EventType> eventType) {
super (eventType);
}
public abstract void handle (int var1, @Nonnull ArchetypeChunk<ECS_TYPE> var2, @Nonnull Store<ECS_TYPE> var3, @Nonnull CommandBuffer<ECS_TYPE> var4, @Nonnull EventType var5) ;
public void handleInternal (int index, @Nonnull ArchetypeChunk<ECS_TYPE> archetypeChunk, @Nonnull Store<ECS_TYPE> store, @Nonnull CommandBuffer<ECS_TYPE> commandBuffer, @Nonnull EventType event) {
if (this .shouldProcessEvent(event)) {
this .handle(index, archetypeChunk, store, commandBuffer, event);
}
}
}
com/hypixel/hytale/component/system/EventSystem.java
package com.hypixel.hytale.component.system;
import javax.annotation.Nonnull;
public abstract class EventSystem <EventType extends EcsEvent > {
@Nonnull
private final Class<EventType> eventType;
protected EventSystem (@Nonnull Class<EventType> eventType) {
this .eventType = eventType;
}
protected boolean shouldProcessEvent (@Nonnull EventType event) {
boolean var10000;
if (event instanceof ICancellableEcsEvent cancellable) {
if (cancellable.isCancelled()) {
var10000 = false ;
return var10000;
}
}
var10000 = true ;
return var10000;
}
@Nonnull
public Class<EventType> getEventType () {
return this .eventType;
}
}
com/hypixel/hytale/component/system/HolderSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
public abstract class HolderSystem <ECS_TYPE> extends System <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
public HolderSystem () {
}
public abstract void onEntityAdd (@Nonnull Holder<ECS_TYPE> var1, @Nonnull AddReason var2, @Nonnull Store<ECS_TYPE> var3) ;
public abstract void onEntityRemoved (@Nonnull Holder<ECS_TYPE> var1, @Nonnull RemoveReason var2, @Nonnull Store<ECS_TYPE> var3) ;
}
com/hypixel/hytale/component/system/ICancellableEcsEvent.java
package com.hypixel.hytale.component.system;
public interface ICancellableEcsEvent {
boolean isCancelled () ;
void setCancelled (boolean var1) ;
}
com/hypixel/hytale/component/system/ISystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.DependencyGraph;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface ISystem <ECS_TYPE> {
ISystem[] EMPTY_ARRAY = new ISystem [0 ];
default void onSystemRegistered () {
}
default void onSystemUnregistered () {
}
@Nullable
default SystemGroup<ECS_TYPE> getGroup () {
return null ;
}
@Nonnull
default Set<Dependency<ECS_TYPE>> getDependencies () {
return Collections.emptySet();
}
static <ECS_TYPE> void calculateOrder (@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull ISystem<ECS_TYPE>[] sortedSystems, int systemSize) {
DependencyGraph<ECS_TYPE> graph = <ECS_TYPE>((ISystem[])Arrays.copyOf(sortedSystems, systemSize));
graph.resolveEdges(registry);
graph.sort(sortedSystems);
}
}
com/hypixel/hytale/component/system/MetricSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.metrics.MetricResults;
public interface MetricSystem <ECS_TYPE> {
MetricResults toMetricResults (Store<ECS_TYPE> var1) ;
}
com/hypixel/hytale/component/system/QuerySystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.query.Query;
import javax.annotation.Nullable;
public interface QuerySystem <ECS_TYPE> extends ISystem <ECS_TYPE> {
default boolean test (ComponentRegistry<ECS_TYPE> componentRegistry, Archetype<ECS_TYPE> archetype) {
return this .getQuery().test(archetype);
}
@Nullable
Query<ECS_TYPE> getQuery () ;
}
com/hypixel/hytale/component/system/RefChangeSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class RefChangeSystem <ECS_TYPE, T extends Component <ECS_TYPE>> extends System <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
public RefChangeSystem () {
}
@Nonnull
public abstract ComponentType<ECS_TYPE, T> componentType () ;
public abstract void onComponentAdded (@Nonnull Ref<ECS_TYPE> var1, @Nonnull T var2, @Nonnull Store<ECS_TYPE> var3, @Nonnull CommandBuffer<ECS_TYPE> var4) ;
public abstract void onComponentSet (@Nonnull Ref<ECS_TYPE> var1, @Nullable T var2, @Nonnull T var3, @Nonnull Store<ECS_TYPE> var4, CommandBuffer<ECS_TYPE> var5) ;
;
}
com/hypixel/hytale/component/system/RefSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
public abstract class RefSystem <ECS_TYPE> extends System <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
public RefSystem () {
}
public abstract void onEntityAdded (@Nonnull Ref<ECS_TYPE> var1, @Nonnull AddReason var2, @Nonnull Store<ECS_TYPE> var3, @Nonnull CommandBuffer<ECS_TYPE> var4) ;
public abstract void onEntityRemove (@Nonnull Ref<ECS_TYPE> var1, @Nonnull RemoveReason var2, @Nonnull Store<ECS_TYPE> var3, @Nonnull CommandBuffer<ECS_TYPE> var4) ;
}
com/hypixel/hytale/component/system/StoreSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
public abstract class StoreSystem <ECS_TYPE> extends System <ECS_TYPE> {
public StoreSystem () {
}
public abstract void onSystemAddedToStore (@Nonnull Store<ECS_TYPE> var1) ;
public abstract void onSystemRemovedFromStore (@Nonnull Store<ECS_TYPE> var1) ;
}
com/hypixel/hytale/component/system/System.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentRegistration;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceRegistration;
import com.hypixel.hytale.component.ResourceType;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectList;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class System <ECS_TYPE> implements ISystem <ECS_TYPE> {
@Nonnull
private final ObjectList<ComponentRegistration<ECS_TYPE, ?>> componentRegistrations = new ObjectArrayList <ComponentRegistration<ECS_TYPE, ?>>();
@Nonnull
private final ObjectList<ResourceRegistration<ECS_TYPE, ?>> resourceRegistrations = new ObjectArrayList <ResourceRegistration<ECS_TYPE, ?>>();
public System () {
}
@Nonnull
protected <T extends Component <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
.registerComponent(tClass, (String) , (BuilderCodec) , supplier);
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
Objects.requireNonNull(codec);
.registerComponent(tClass, id, codec, codec::getDefaultValue);
}
<T <ECS_TYPE>> ComponentType<ECS_TYPE, T> {
ComponentType<ECS_TYPE, T> componentType = <ECS_TYPE, T>();
.componentRegistrations.add( (tClass, id, codec, supplier, componentType));
componentType;
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
.registerResource(tClass, (String) , (BuilderCodec) , supplier);
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
Objects.requireNonNull(codec);
.registerResource(tClass, id, codec, codec::getDefaultValue);
}
<T <ECS_TYPE>> ResourceType<ECS_TYPE, T> {
ResourceType<ECS_TYPE, T> componentType = <ECS_TYPE, T>();
.resourceRegistrations.add( (tClass, id, codec, supplier, componentType));
componentType;
}
List<ComponentRegistration<ECS_TYPE, ?>> getComponentRegistrations() {
.componentRegistrations;
}
List<ResourceRegistration<ECS_TYPE, ?>> getResourceRegistrations() {
.resourceRegistrations;
}
}
com/hypixel/hytale/component/system/WorldEventSystem.java
package com.hypixel.hytale.component.system;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
public abstract class WorldEventSystem <ECS_TYPE, EventType extends EcsEvent > extends EventSystem <EventType> implements ISystem <ECS_TYPE> {
protected WorldEventSystem (@Nonnull Class<EventType> eventType) {
super (eventType);
}
public abstract void handle (@Nonnull Store<ECS_TYPE> var1, @Nonnull CommandBuffer<ECS_TYPE> var2, @Nonnull EventType var3) ;
public void handleInternal (@Nonnull Store<ECS_TYPE> store, @Nonnull CommandBuffer<ECS_TYPE> commandBuffer, @Nonnull EventType event) {
if (this .shouldProcessEvent(event)) {
this .handle(store, commandBuffer, event);
}
}
}
com/hypixel/hytale/component/system/data/ArchetypeDataSystem.java
package com.hypixel.hytale.component.system.data;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.QuerySystem;
import com.hypixel.hytale.component.system.System;
import java.util.List;
public abstract class ArchetypeDataSystem <ECS_TYPE, Q, R> extends System <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
public ArchetypeDataSystem () {
}
public abstract void fetch (ArchetypeChunk<ECS_TYPE> var1, Store<ECS_TYPE> var2, CommandBuffer<ECS_TYPE> var3, Q var4, List<R> var5) ;
}
com/hypixel/hytale/component/system/data/EntityDataSystem.java
package com.hypixel.hytale.component.system.data;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.task.ParallelRangeTask;
import com.hypixel.hytale.component.task.ParallelTask;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.function.IntConsumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class EntityDataSystem <ECS_TYPE, Q, R> extends ArchetypeDataSystem <ECS_TYPE, Q, R> {
public EntityDataSystem () {
}
public boolean isParallel () {
return false ;
}
public void fetch (@Nonnull ArchetypeChunk<ECS_TYPE> archetypeChunk, @Nonnull Store<ECS_TYPE> store, @Nonnull CommandBuffer<ECS_TYPE> commandBuffer, Q query, List<R> results) {
doFetch(this , archetypeChunk, store, commandBuffer, query, results);
}
public abstract void fetch (int var1, ArchetypeChunk<ECS_TYPE> var2, Store<ECS_TYPE> var3, CommandBuffer<ECS_TYPE> var4, Q var5, List<R> var6) ;
<ECS_TYPE, Q, R> {
(system.isParallel()) {
archetypeChunk.size();
(size == ) {
;
}
ParallelTask<SystemTaskData<ECS_TYPE, ?, ?>> task = store.getFetchTask();
ParallelRangeTask<SystemTaskData<ECS_TYPE, ?, ?>> systemTask = task.appendTask();
systemTask.init( , size);
;
( systemTask.size(); i < systemTaskSize; ++i) {
(systemTask.get(i)).init(system, archetypeChunk, store, commandBuffer.fork(), query);
}
} {
;
( archetypeChunk.size(); index < archetypeChunkSize; ++index) {
system.fetch(index, archetypeChunk, store, commandBuffer, query, results);
}
}
}
<ECS_TYPE, Q, R> {
List<R> results = <R>();
EntityDataSystem<ECS_TYPE, Q, R> system;
ArchetypeChunk<ECS_TYPE> archetypeChunk;
Store<ECS_TYPE> store;
CommandBuffer<ECS_TYPE> commandBuffer;
Q query;
{
}
{
.system = system;
.archetypeChunk = archetypeChunk;
.store = store;
.commandBuffer = commandBuffer;
.query = query;
}
{
.commandBuffer.setThread();
.system.fetch(index, .archetypeChunk, .store, .commandBuffer, .query, .results);
}
{
.system = ;
.archetypeChunk = ;
.store = ;
.commandBuffer = ;
.query = ;
.results.clear();
}
<ECS_TYPE, Q, R> {
parallelTask.size();
(parallelTaskSize > ) {
parallelTask.doInvoke();
( ; x < parallelTaskSize; ++x) {
ParallelRangeTask<SystemTaskData<ECS_TYPE, Q, R>> systemTask = parallelTask.get(x);
;
( systemTask.size(); i < systemTaskSize; ++i) {
SystemTaskData<ECS_TYPE, Q, R> taskData = systemTask.get(i);
results.addAll(taskData.results);
taskData.commandBuffer.mergeParallel(commandBuffer);
taskData.clear();
}
}
}
}
}
}
com/hypixel/hytale/component/system/tick/ArchetypeTickingSystem.java
package com.hypixel.hytale.component.system.tick;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.QuerySystem;
import javax.annotation.Nonnull;
public abstract class ArchetypeTickingSystem <ECS_TYPE> extends TickingSystem <ECS_TYPE> implements QuerySystem <ECS_TYPE> {
public ArchetypeTickingSystem () {
}
public boolean test (@Nonnull ComponentRegistry<ECS_TYPE> componentRegistry, @Nonnull Archetype<ECS_TYPE> archetype) {
return !this .isExplicitQuery() && componentRegistry.getNonTickingComponentType().test(archetype) ? false : this .getQuery().test(archetype);
}
public boolean isExplicitQuery () {
return false ;
}
public void tick (float dt, int systemIndex, @Nonnull Store<ECS_TYPE> store) {
store.tick( , dt, systemIndex);
}
;
}
com/hypixel/hytale/component/system/tick/DelayedEntitySystem.java
package com.hypixel.hytale.component.system.tick;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
public abstract class DelayedEntitySystem <ECS_TYPE> extends EntityTickingSystem <ECS_TYPE> {
private final ResourceType<ECS_TYPE, Data<ECS_TYPE>> resourceType = this .registerResource(Data.class, Data::new );
private final float intervalSec;
public DelayedEntitySystem (float intervalSec) {
this .intervalSec = intervalSec;
}
@Nonnull
public ResourceType<ECS_TYPE, Data<ECS_TYPE>> getResourceType () {
return this .resourceType;
}
public float getIntervalSec () {
return this .intervalSec;
}
public void tick (float dt, int systemIndex, @Nonnull Store<ECS_TYPE> store) {
Data<ECS_TYPE> data = (Data)store.getResource(this .resourceType);
data.dt += dt;
(data.dt >= .intervalSec) {
data.dt;
data.dt = ;
.tick(fullDt, systemIndex, store);
}
}
<ECS_TYPE> <ECS_TYPE> {
dt;
{
}
Resource<ECS_TYPE> {
Data<ECS_TYPE> data = <ECS_TYPE>();
data.dt = .dt;
data;
}
}
}
com/hypixel/hytale/component/system/tick/EntityTickingSystem.java
package com.hypixel.hytale.component.system.tick;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.task.ParallelRangeTask;
import com.hypixel.hytale.component.task.ParallelTask;
import java.util.function.IntConsumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class EntityTickingSystem <ECS_TYPE> extends ArchetypeTickingSystem <ECS_TYPE> {
public EntityTickingSystem () {
}
protected static boolean maybeUseParallel (int archetypeChunkSize, int taskCount) {
return false ;
}
protected static boolean useParallel (int archetypeChunkSize, int taskCount) {
return taskCount > 0 || archetypeChunkSize > ParallelRangeTask.PARALLELISM;
}
public boolean isParallel (int archetypeChunkSize, int taskCount) {
return false ;
}
{
doTick( , dt, archetypeChunk, store, commandBuffer);
}
;
<ECS_TYPE> {
archetypeChunk.size();
(archetypeChunkSize != ) {
ParallelTask<SystemTaskData<ECS_TYPE>> task = store.getParallelTask();
(system.isParallel(archetypeChunkSize, task.size())) {
ParallelRangeTask<SystemTaskData<ECS_TYPE>> systemTask = task.appendTask();
systemTask.init( , archetypeChunkSize);
;
( systemTask.size(); i < systemTaskSize; ++i) {
(systemTask.get(i)).init(system, dt, archetypeChunk, store, commandBuffer.fork());
}
} {
( ; index < archetypeChunkSize; ++index) {
system.tick(dt, index, archetypeChunk, store, commandBuffer);
}
}
}
}
<ECS_TYPE> {
EntityTickingSystem<ECS_TYPE> system;
dt;
ArchetypeChunk<ECS_TYPE> archetypeChunk;
Store<ECS_TYPE> store;
CommandBuffer<ECS_TYPE> commandBuffer;
{
}
{
.system = system;
.dt = dt;
.archetypeChunk = archetypeChunk;
.store = store;
.commandBuffer = commandBuffer;
}
{
.commandBuffer.setThread();
.system.tick( .dt, index, .archetypeChunk, .store, .commandBuffer);
}
{
.system = ;
.archetypeChunk = ;
.store = ;
.commandBuffer = ;
}
<ECS_TYPE> {
parallelTask.size();
(parallelTaskSize > ) {
parallelTask.doInvoke();
( ; x < parallelTaskSize; ++x) {
ParallelRangeTask<SystemTaskData<ECS_TYPE>> systemTask = parallelTask.get(x);
;
( systemTask.size(); i < systemTaskSize; ++i) {
SystemTaskData<ECS_TYPE> taskData = systemTask.get(i);
taskData.commandBuffer.mergeParallel(commandBuffer);
taskData.clear();
}
}
}
}
}
}
com/hypixel/hytale/component/system/tick/RunWhenPausedSystem.java
package com.hypixel.hytale.component.system.tick;
public interface RunWhenPausedSystem <ECS_TYPE> extends TickableSystem <ECS_TYPE> {
}
com/hypixel/hytale/component/system/tick/TickableSystem.java
package com.hypixel.hytale.component.system.tick;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.ISystem;
import javax.annotation.Nonnull;
public interface TickableSystem <ECS_TYPE> extends ISystem <ECS_TYPE> {
void tick (float var1, int var2, @Nonnull Store<ECS_TYPE> var3) ;
}
com/hypixel/hytale/component/system/tick/TickingSystem.java
package com.hypixel.hytale.component.system.tick;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.System;
import javax.annotation.Nonnull;
public abstract class TickingSystem <ECS_TYPE> extends System <ECS_TYPE> implements TickableSystem <ECS_TYPE> {
public TickingSystem () {
}
public abstract void tick (float var1, int var2, @Nonnull Store<ECS_TYPE> var3) ;
}
com/hypixel/hytale/component/task/ParallelRangeTask.java
package com.hypixel.hytale.component.task;
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ForkJoinPool;
import java.util.function.IntConsumer;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public class ParallelRangeTask <D extends IntConsumer > extends CountedCompleter <Void> {
public static final int PARALLELISM = Math.max(ForkJoinPool.getCommonPoolParallelism(), 1 );
public static final int TASK_COUNT = Math.max(ForkJoinPool.getCommonPoolParallelism() << 2 , 1 );
@Nonnull
private final SubTask<D>[] subTasks;
private int size;
public volatile boolean running;
public ParallelRangeTask (@Nonnull Supplier<D> supplier) {
this ((CountedCompleter)null , supplier);
}
public ParallelRangeTask (CountedCompleter<?> completer, @Nonnull Supplier<D> supplier) {
(completer);
.subTasks = [TASK_COUNT];
( ; i < .subTasks.length; ++i) {
.subTasks[i] = ( , (IntConsumer)supplier.get());
}
}
{
( .running) {
( );
} {
.reinitialize();
}
}
ParallelRangeTask<D> {
.reinitialize();
Math.max((to - from + ( .subTasks.length - )) / .subTasks.length, );
( .size = ; .size < .subTasks.length && from < to; ++ .size) {
Math.min(from + perTask, to);
.subTasks[ .size].init(from, next);
from = next;
}
(from < to) {
( );
} {
;
}
}
{
.size;
}
D {
(D) .subTasks[i].getData();
}
{
( .running) {
( );
} {
.subTasks[i].setData(data);
}
}
{
.setPendingCount( .size - );
( ; i < .size - ; ++i) {
.subTasks[i].fork();
}
.subTasks[ .size - ].compute();
}
<D > <Void> {
from;
to;
D data;
SubTask(ParallelRangeTask parent, D data) {
(parent);
.data = data;
}
{
.reinitialize();
.from = from;
.to = to;
}
D {
.data;
}
{
.data = data;
}
{
( .from; i < .to; ++i) {
.data.accept(i);
}
.propagateCompletion();
}
}
}
com/hypixel/hytale/component/task/ParallelTask.java
package com.hypixel.hytale.component.task;
import com.hypixel.hytale.common.util.ArrayUtil;
import java.util.Arrays;
import java.util.concurrent.CountedCompleter;
import java.util.function.IntConsumer;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public class ParallelTask <D extends IntConsumer > extends CountedCompleter <Void> {
private final Supplier<D> supplier;
@Nonnull
private ParallelRangeTask<D>[] subTasks;
private int size;
private volatile boolean running;
public ParallelTask (Supplier<D> supplier) {
this ((CountedCompleter)null , supplier);
}
public ParallelTask (CountedCompleter<?> completer, Supplier<D> supplier) {
super (completer);
this .subTasks = new ParallelRangeTask [0 ];
this .supplier = supplier;
}
public void reinitialize () {
if (this .running) {
throw ( );
} {
.reinitialize();
}
}
{
.reinitialize();
.size = ;
}
ParallelRangeTask<D> {
( .running) {
( );
} {
( .subTasks.length <= .size) {
.subTasks = (ParallelRangeTask[])Arrays.copyOf( .subTasks, ArrayUtil.grow( .size));
( .size; i < .subTasks.length; ++i) {
.subTasks[i] = ( , .supplier);
}
}
.subTasks[ .size++];
}
}
{
.size;
}
ParallelRangeTask<D> {
.subTasks[i];
}
{
.setPendingCount( .size - );
( ; i < .size - ; ++i) {
.subTasks[i].fork();
}
.subTasks[ .size - ].compute();
}
{
.running = ;
( ; i < .size; ++i) {
.subTasks[i].running = ;
}
.invoke();
( ; i < .size; ++i) {
.subTasks[i].running = ;
}
.running = ;
}
}