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

package com.hypixel.hytale.builtin.npccombatactionevaluator.memory;

import com.hypixel.hytale.component.system.EcsEvent;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.core.modules.entity.damage.DamageModule;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.ArchetypeChunk;
import javax.annotation.Nonnull;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.server.core.modules.entity.damage.DamageEventSystem;

public class DamageMemorySystems
{
    public static class CollectDamage extends DamageEventSystem
    {
        private final ComponentType<EntityStore, DamageMemory> damageMemoryComponentType;
        @Nonnull
        private final Query<EntityStore> query;
        
        public CollectDamage(final ComponentType<EntityStore, DamageMemory> damageMemoryComponentType) {
            this.damageMemoryComponentType = damageMemoryComponentType;
            this.query = damageMemoryComponentType;
        }
        
        @Nonnull
        @Override
        public Query<EntityStore> getQuery() {
            return this.query;
        }
        
        @Override
        public void handle(final int index, @Nonnull final ArchetypeChunk<EntityStore> archetypeChunk, @Nonnull final Store<EntityStore> store, @Nonnull final CommandBuffer<EntityStore> commandBuffer, @Nonnull final Damage damage) {
            final DamageMemory memory = archetypeChunk.getComponent(index, this.damageMemoryComponentType);
            memory.addDamage(damage.getAmount());
        }
        
        @Nullable
        @Override
        public SystemGroup<EntityStore> getGroup() {
            return DamageModule.get().getInspectDamageGroup();
        }
    }
}
