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

package com.hypixel.hytale.builtin.adventure.npcobjectives.assets;

import com.hypixel.hytale.codec.validation.validator.ArrayValidator;
import com.hypixel.hytale.codec.validation.Validator;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.server.spawning.assets.spawnmarker.config.SpawnMarker;
import com.hypixel.hytale.codec.validation.ValidationResults;
import java.util.Arrays;
import com.hypixel.hytale.builtin.adventure.objectives.config.task.ObjectiveTaskAsset;
import javax.annotation.Nonnull;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.builtin.adventure.objectives.config.taskcondition.TaskConditionAsset;
import com.hypixel.hytale.codec.builder.BuilderCodec;

public class KillSpawnMarkerObjectiveTaskAsset extends KillObjectiveTaskAsset
{
    public static final BuilderCodec<KillSpawnMarkerObjectiveTaskAsset> CODEC;
    protected String[] spawnMarkerIds;
    protected float radius;
    
    public KillSpawnMarkerObjectiveTaskAsset(final String descriptionId, final TaskConditionAsset[] taskConditions, final Vector3i[] mapMarkers, final int count, final String npcGroupId, final String[] spawnMarkerIds, final float radius) {
        super(descriptionId, taskConditions, mapMarkers, count, npcGroupId);
        this.radius = 1.0f;
        this.spawnMarkerIds = spawnMarkerIds;
        this.radius = radius;
    }
    
    protected KillSpawnMarkerObjectiveTaskAsset() {
        this.radius = 1.0f;
    }
    
    @Nonnull
    public String[] getSpawnMarkerIds() {
        return this.spawnMarkerIds;
    }
    
    public float getRadius() {
        return this.radius;
    }
    
    @Override
    protected boolean matchesAsset0(final ObjectiveTaskAsset task) {
        if (!super.matchesAsset0(task)) {
            return false;
        }
        if (task instanceof final KillSpawnMarkerObjectiveTaskAsset killSpawnMarkerObjectiveTaskAsset) {
            return Arrays.equals(killSpawnMarkerObjectiveTaskAsset.spawnMarkerIds, this.spawnMarkerIds) && killSpawnMarkerObjectiveTaskAsset.radius == this.radius;
        }
        return false;
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "KillSpawnMarkerObjectiveTaskAsset{spawnMarkerIds=" + Arrays.toString(this.spawnMarkerIds) + ", radius=" + this.radius + "} " + super.toString();
    }
    
    static {
        CODEC = BuilderCodec.builder(KillSpawnMarkerObjectiveTaskAsset.class, KillSpawnMarkerObjectiveTaskAsset::new, KillObjectiveTaskAsset.CODEC).append(new KeyedCodec<Float>("Radius", Codec.FLOAT), (killSpawnMarkerObjectiveTaskAsset, aFloat) -> killSpawnMarkerObjectiveTaskAsset.radius = aFloat, killSpawnMarkerObjectiveTaskAsset -> killSpawnMarkerObjectiveTaskAsset.radius).addValidator((Validator<? super Float>)Validators.greaterThan(0.0f)).add().append(new KeyedCodec("SpawnMarkerIds", Codec.STRING_ARRAY), (killSpawnMarkerObjectiveTaskAsset, s) -> killSpawnMarkerObjectiveTaskAsset.spawnMarkerIds = s, killSpawnMarkerObjectiveTaskAsset -> killSpawnMarkerObjectiveTaskAsset.spawnMarkerIds).addValidator(Validators.nonEmptyArray()).addValidator(SpawnMarker.VALIDATOR_CACHE.getArrayValidator()).addValidator(new ArrayValidator((o, results) -> {
            final SpawnMarker spawnMarker = SpawnMarker.getAssetMap().getAsset(o);
            if (spawnMarker != null && !spawnMarker.isManualTrigger()) {
                results.fail("SpawnMarker '" + o + "' can't be triggered manually!");
            }
        })).add().build();
    }
}
