// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.modules.entity.player;

import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.ArchetypeChunk;
import javax.annotation.Nullable;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.dependency.Dependency;
import java.util.Set;
import com.hypixel.hytale.component.query.Query;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.system.tick.RunWhenPausedSystem;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;

public class PlayerPingSystem extends EntityTickingSystem<EntityStore> implements RunWhenPausedSystem<EntityStore>
{
    @Nonnull
    private static final ComponentType<EntityStore, PlayerRef> PLAYER_REF_COMPONENT_TYPE;
    
    @Override
    public Query<EntityStore> getQuery() {
        return PlayerPingSystem.PLAYER_REF_COMPONENT_TYPE;
    }
    
    @Nonnull
    @Override
    public Set<Dependency<EntityStore>> getDependencies() {
        return RootDependency.lastSet();
    }
    
    @Nullable
    @Override
    public SystemGroup<EntityStore> getGroup() {
        return EntityStore.SEND_PACKET_GROUP;
    }
    
    @Override
    public boolean isParallel(final int archetypeChunkSize, final int taskCount) {
        return EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount);
    }
    
    @Override
    public void tick(final float dt, final int index, @Nonnull final ArchetypeChunk<EntityStore> archetypeChunk, @Nonnull final Store<EntityStore> store, @Nonnull final CommandBuffer<EntityStore> commandBuffer) {
        final PlayerRef playerRefComponent = archetypeChunk.getComponent(index, PlayerPingSystem.PLAYER_REF_COMPONENT_TYPE);
        assert playerRefComponent != null;
        playerRefComponent.getPacketHandler().tickPing(dt);
    }
    
    static {
        PLAYER_REF_COMPONENT_TYPE = PlayerRef.getComponentType();
    }
}
