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

package com.hypixel.hytale.builtin.beds.sleep.resources;

import com.hypixel.hytale.protocol.packets.world.SleepClock;
import com.hypixel.hytale.server.core.modules.time.WorldTimeResource;
import com.hypixel.hytale.protocol.InstantData;
import java.time.Instant;

public final class WorldSlumber implements WorldSleep
{
    private final Instant startInstant;
    private final Instant targetInstant;
    private final InstantData startInstantData;
    private final InstantData targetInstantData;
    private final float irlDurationSeconds;
    private float progressSeconds;
    
    public WorldSlumber(final Instant startInstant, final Instant targetInstant, final float irlDurationSeconds) {
        this.progressSeconds = 0.0f;
        this.startInstant = startInstant;
        this.targetInstant = targetInstant;
        this.startInstantData = WorldTimeResource.instantToInstantData(startInstant);
        this.targetInstantData = WorldTimeResource.instantToInstantData(targetInstant);
        this.irlDurationSeconds = irlDurationSeconds;
    }
    
    public Instant getStartInstant() {
        return this.startInstant;
    }
    
    public Instant getTargetInstant() {
        return this.targetInstant;
    }
    
    public InstantData getStartInstantData() {
        return this.startInstantData;
    }
    
    public InstantData getTargetInstantData() {
        return this.targetInstantData;
    }
    
    public float getProgressSeconds() {
        return this.progressSeconds;
    }
    
    public void incProgressSeconds(final float seconds) {
        this.progressSeconds += seconds;
        this.progressSeconds = Math.min(this.progressSeconds, this.irlDurationSeconds);
    }
    
    public float getIrlDurationSeconds() {
        return this.irlDurationSeconds;
    }
    
    public SleepClock createSleepClock() {
        final float progress = this.progressSeconds / this.irlDurationSeconds;
        return new SleepClock(this.startInstantData, this.targetInstantData, progress, this.irlDurationSeconds);
    }
}
