package de.frajul.endlessroll.entities.tools;

import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.AnimatedEntity;
import de.frajul.endlessroll.entities.Player;
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
import de.frajul.endlessroll.main.game.Timer;

/**
 * Created by Julian on 04.01.2016.
 */
public abstract class Tool extends AnimatedEntity {

    private boolean placedByRightEdge;
    private boolean updateBounds;
    private Geometry worldCollisionBounds;
    private Geometry playerCollisionBounds;
    private boolean floating = false;

    public Tool(ToolType type, Vector position, float width, float height, boolean updateBounds, boolean placedByRightEdge) {
        super(type.getToolTexture(), position, width, height);
        this.updateBounds = updateBounds;
        this.placedByRightEdge = placedByRightEdge;
        worldCollisionBounds = createWorldCollisionBounds();
        playerCollisionBounds = createPlayerCollisionBounds();
    }

    public abstract void onPlayerCollision(Player player, Timer timer);

    protected abstract Geometry createWorldCollisionBounds();

    protected abstract Geometry createPlayerCollisionBounds();

    public Geometry getWorldCollisionBounds() {
        if (updateBounds)
            return createWorldCollisionBounds();
        return worldCollisionBounds;
    }

    public Geometry getPlayerCollisionBounds() {
        if (updateBounds)
            return createPlayerCollisionBounds();
        return playerCollisionBounds;
    }

    public void setFloating(boolean floating) {
        this.floating = floating;
    }

    public boolean isFloating() {
        return floating;
    }

    public boolean isPlacedByRightEdge() {
        return placedByRightEdge;
    }
}
