package com.hypixel.hytale.server.core.modules.entity.player;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.server.core.entity.entities.player.movement.MovementManager;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class PlayerMovementManagerSystems {
public PlayerMovementManagerSystems() {
}
public static class AssignmentSystem extends HolderSystem<EntityStore> {
@Nonnull
private static final ComponentType<EntityStore, MovementManager> MOVEMENT_MANAGER_COMPONENT_TYPE = MovementManager.getComponentType();
@Nonnull
private static final Query<EntityStore> QUERY;
public AssignmentSystem() {
}
@Nonnull
public Query<EntityStore> getQuery() {
return QUERY;
}
public void onEntityAdd(@Nonnull Holder<EntityStore> holder, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store) {
holder.ensureComponent(MOVEMENT_MANAGER_COMPONENT_TYPE);
}
public void onEntityRemoved(@Nonnull Holder<EntityStore> holder, @Nonnull RemoveReason reason, @Nonnull Store<EntityStore> store) {
}
static {
QUERY = Query.<EntityStore>and(PlayerRef.getComponentType(), Query.not(MOVEMENT_MANAGER_COMPONENT_TYPE));
}
}
public static class PostAssignmentSystem extends RefSystem<EntityStore> {
@Nonnull
private static final ComponentType<EntityStore, MovementManager> MOVEMENT_MANAGER_COMPONENT_TYPE = MovementManager.getComponentType();
@Nonnull
private static final Query<EntityStore> QUERY;
public PostAssignmentSystem() {
}
@Nonnull
public Query<EntityStore> getQuery() {
return QUERY;
}
public void onEntityAdded(@Nonnull Ref<EntityStore> ref, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
MovementManager movementManagerComponent = (MovementManager)commandBuffer.getComponent(ref, MOVEMENT_MANAGER_COMPONENT_TYPE);
assert movementManagerComponent != null;
movementManagerComponent.resetDefaultsAndUpdate(ref, commandBuffer);
}
public void onEntityRemove(@Nonnull Ref<EntityStore> ref, @Nonnull RemoveReason reason, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
static {
QUERY = Query.<EntityStore>and(MOVEMENT_MANAGER_COMPONENT_TYPE, PlayerRef.getComponentType());
}
}
}