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

package com.hypixel.hytale.server.npc.systems;

import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.server.core.entity.Frozen;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.components.StepComponent;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;

public abstract class SteppableTickingSystem extends EntityTickingSystem<EntityStore>
{
    @Nonnull
    private final ComponentType<EntityStore, StepComponent> stepComponentType;
    @Nonnull
    private final ComponentType<EntityStore, Frozen> frozenComponentType;
    
    public SteppableTickingSystem() {
        this.stepComponentType = StepComponent.getComponentType();
        this.frozenComponentType = Frozen.getComponentType();
    }
    
    @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 World world = store.getExternalData().getWorld();
        final Frozen frozenComponent = archetypeChunk.getComponent(index, this.frozenComponentType);
        float tickLength;
        if (frozenComponent != null || world.getWorldConfig().isAllNPCFrozen()) {
            final StepComponent stepComponent = archetypeChunk.getComponent(index, this.stepComponentType);
            if (stepComponent == null) {
                return;
            }
            tickLength = stepComponent.getTickLength();
        }
        else {
            tickLength = dt;
        }
        this.steppedTick(tickLength, index, archetypeChunk, store, commandBuffer);
    }
    
    public abstract void steppedTick(final float p0, final int p1, @Nonnull final ArchetypeChunk<EntityStore> p2, @Nonnull final Store<EntityStore> p3, @Nonnull final CommandBuffer<EntityStore> p4);
}
