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

package com.hypixel.hytale.server.spawning.local;

import com.hypixel.hytale.component.query.Query;
import java.util.logging.Level;
import com.hypixel.hytale.server.spawning.SpawningPlugin;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.AddReason;
import javax.annotation.Nonnull;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.system.RefSystem;

public class LocalSpawnBeaconSystem extends RefSystem<EntityStore>
{
    private final ComponentType<EntityStore, LocalSpawnBeacon> componentType;
    private final ResourceType<EntityStore, LocalSpawnState> localSpawnStateResourceType;
    
    public LocalSpawnBeaconSystem(final ComponentType<EntityStore, LocalSpawnBeacon> componentType, final ResourceType<EntityStore, LocalSpawnState> localSpawnStateResourceType) {
        this.componentType = componentType;
        this.localSpawnStateResourceType = localSpawnStateResourceType;
    }
    
    @Override
    public void onEntityAdded(@Nonnull final Ref<EntityStore> reference, @Nonnull final AddReason reason, @Nonnull final Store<EntityStore> store, @Nonnull final CommandBuffer<EntityStore> commandBuffer) {
    }
    
    @Override
    public void onEntityRemove(@Nonnull final Ref<EntityStore> reference, @Nonnull final RemoveReason reason, @Nonnull final Store<EntityStore> store, @Nonnull final CommandBuffer<EntityStore> commandBuffer) {
        SpawningPlugin.get().getLogger().at(Level.FINE).log("Triggering forced rerun of local spawn controllers");
        store.getResource(this.localSpawnStateResourceType).forceTriggerControllers();
    }
    
    @Override
    public Query<EntityStore> getQuery() {
        return this.componentType;
    }
}
