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

package com.hypixel.hytale.component.system;

import com.hypixel.hytale.component.dependency.DependencyGraph;
import java.util.Arrays;
import com.hypixel.hytale.component.ComponentRegistry;
import javax.annotation.Nonnull;
import java.util.Collections;
import com.hypixel.hytale.component.dependency.Dependency;
import java.util.Set;
import javax.annotation.Nullable;
import com.hypixel.hytale.component.SystemGroup;

public interface ISystem<ECS_TYPE>
{
    public static final 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();
    }
    
    default <ECS_TYPE> void calculateOrder(@Nonnull final ComponentRegistry<ECS_TYPE> registry, @Nonnull final ISystem<ECS_TYPE>[] sortedSystems, final int systemSize) {
        final DependencyGraph<ECS_TYPE> graph = new DependencyGraph<ECS_TYPE>(Arrays.copyOf(sortedSystems, systemSize));
        graph.resolveEdges(registry);
        graph.sort(sortedSystems);
    }
}
