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


package engine.devcmd.cmds;

import engine.InterestManagement.HeightMap;
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 = HeightMap.getNextZoneWithTerrain(currentZone);
        parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent());

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

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

        this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.getName());
        this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName());
        this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude);
        this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel());
        this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y);
        this.throwbackInfo(playerCharacter, "***Height returned: " + currentHeight);
        this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight()));
        this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight()));

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

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

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

}