package me.earthme.luminol.config.modules.optimizations;

import me.earthme.luminol.config.IConfigModule;
import me.earthme.luminol.config.flags.ConfigClassInfo;
import me.earthme.luminol.config.flags.ConfigInfo;
import me.earthme.luminol.enums.EnumConfigCategory;

/**
 * Distance-based mob AI throttling (Dynamic Activation of Brain style).
 *
 * <p>Mobs far from any player run their goal/target selectors and navigation less often. The
 * "distance" signal is reused from Paper's EntityActivationRange ({@code entity.activatedTick}),
 * which records the last tick a player was within activation range — so there is no extra
 * per-mob player scan. As soon as a player comes near, the mob is reactivated and runs at full
 * rate again the same tick.
 *
 * <p>Targeted at hordes (e.g. "100 days"-style zombie waves) where pathfinding for thousands of
 * far-away mobs is the dominant tick cost.
 */
@ConfigClassInfo(category = EnumConfigCategory.OPTIMIZATIONS, name = "mob_ai_throttle")
public class MobAiThrottleConfig implements IConfigModule {

    @ConfigInfo(name = "enabled", comments = "Throttle AI (goal/target selectors + navigation) for mobs that are far from players.")
    public static boolean enabled = false;

    @ConfigInfo(name = "inactive_ticks_tier1", comments = "After this many ticks with no nearby player, run full AI only every 'tier1_interval' ticks.")
    public static int inactiveTicksTier1 = 20; // ~1s without a player nearby

    @ConfigInfo(name = "tier1_interval", comments = "AI tick interval for tier-1 (somewhat inactive) mobs. 2 = every other tick.")
    public static int tier1Interval = 2;

    @ConfigInfo(name = "inactive_ticks_tier2", comments = "After this many inactive ticks, run full AI only every 'tier2_interval' ticks.")
    public static int inactiveTicksTier2 = 100; // ~5s

    @ConfigInfo(name = "tier2_interval", comments = "AI tick interval for tier-2 (very inactive) mobs.")
    public static int tier2Interval = 4;

    @ConfigInfo(name = "inactive_ticks_tier3", comments = "After this many inactive ticks, run full AI only every 'tier3_interval' ticks (deepest throttle).")
    public static int inactiveTicksTier3 = 400; // ~20s

    @ConfigInfo(name = "tier3_interval", comments = "AI tick interval for tier-3 (deeply inactive) mobs. Higher = cheaper but slower to react.")
    public static int tier3Interval = 8;
}
