package net.cobem.grizzly.habbohotel.roleplay;

import net.cobem.grizzly.habbohotel.sessions.Session;

public class WorkoutRunMonitor implements Runnable {
    private Thread Thread;

    private Session User;

    public boolean Active = false;

    public WorkoutRunMonitor(Session Session) {
        this.User = Session;

        this.Thread = new Thread(this);
    }

    @Override
    public void run() {
        try {
            while (Active) {
                User.getActor().removeStatus("sit", false);
                User.getActor().removeStatus("lay", false);
                User.getActor().addStatus("mv", (+User.getActor().CurrentPosition.X + "," + User.getActor().CurrentPosition.Y + "," + Double.toString(User.getActor().CurrentPosition.Z)), true);

                Thread.sleep(120);
            }
        } catch (Exception ignored) {
            stop();
            start();
        }
    }

    public void start() {
        Active = true;

        this.Thread = new Thread(this);
        this.Thread.start();
    }

    public void stop() {
        Active = false;
        this.Thread.stop();
    }

}
