// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
//      Magicbane Emulator Project © 2013 - 2022
//                www.magicbane.com


package engine.devcmd.cmds;

import engine.InterestManagement.Terrain;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ZoneManager;
import engine.math.Vector2f;
import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
import engine.objects.Zone;

public class GetHeightCmd extends AbstractDevCmd {

    public GetHeightCmd() {
        super("getHeight");
    }

    @Override
    protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
                          AbstractGameObject target) {

        Zone currentZone;
        Zone parentZone;
        Zone heightmapZone;

        currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc());
        heightmapZone = Terrain.getNextZoneWithTerrain(currentZone);
        parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent);

        float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
        float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc());

        Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone);

        Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc);

        this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
        this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
        this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude);
        this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel);
        this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y));
        this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.heightBlend(zoneLoc));
        this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight));

        this.throwbackInfo(playerCharacter, "------------");
        this.throwbackInfo(playerCharacter, "Parent : " + parentZone.zoneName);
        this.throwbackInfo(playerCharacter, "Height returned : " + Math.ceil(parentHeight));
        this.throwbackInfo(playerCharacter, "------------");
    }

    @Override
    protected String _getHelpString() {
        return "Queries heightmap engine";
    }

    @Override
    protected String _getUsageString() {
        return "' /getheight";
    }

}