package dev.loki.hook; import dev.loki.player.Survivor; import org.bukkit.Location; import java.util.UUID; public class Hook { private final UUID id; private final Location location; private Survivor hookedSurvivor; private HookStage currentStage; private int stageProgress; private boolean occupied; private boolean basement; private boolean disabled; // саботирован выжившим public Hook(UUID id, Location location, boolean basement) { this.id = id; this.location = location; this.basement = basement; this.currentStage = HookStage.STAGE_1; this.stageProgress = 0; this.occupied = false; } public void hookSurvivor(Survivor survivor) { this.hookedSurvivor = survivor; this.occupied = true; this.currentStage = HookStage.STAGE_1; this.stageProgress = 0; } public void unhookSurvivor() { this.hookedSurvivor = null; this.occupied = false; this.currentStage = HookStage.STAGE_1; this.stageProgress = 0; } public void tick() { if (!occupied || hookedSurvivor == null) return; stageProgress++; int stageDuration = currentStage.getDurationSeconds() * 20; if (stageProgress >= stageDuration && currentStage != HookStage.SACRIFICE) { advanceStage(); } } private void advanceStage() { currentStage = currentStage.next(); stageProgress = 0; } public double getStageProgressPercent() { if (currentStage == HookStage.SACRIFICE) return 100; int stageDuration = currentStage.getDurationSeconds() * 20; return (double) stageProgress / stageDuration * 100; } public boolean isInStruggle() { return currentStage == HookStage.STAGE_2; } public UUID getId() { return id; } public Location getLocation() { return location; } public Survivor getHookedSurvivor() { return hookedSurvivor; } public HookStage getCurrentStage() { return currentStage; } public boolean isOccupied() { return occupied; } public boolean isBasement() { return basement; } public boolean isDisabled() { return disabled; } public void setDisabled(boolean disabled) { this.disabled = disabled; } }