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


package engine.devcmd.cmds;

import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3f;
import engine.objects.*;

import java.lang.reflect.Field;

public class RegionCmd extends AbstractDevCmd {

    public RegionCmd() {
        super("region");
    }

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

        String newline = "\r\n ";
        String output;
        output = "Target Region Information:" + newline;

        Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc);
        if(building == null){
            this.throwbackInfo(pc, "No Building At This Location.") ;
        }
        Regions region = ((AbstractCharacter)target).region;
        output += "In Floor: " + ((AbstractCharacter) target).getInFloorID() + newline;
        output += "In Building: " + ((AbstractCharacter) target).getInBuilding() + newline;
        if (region == null) {
            output += "No Region Found." + newline;
        }else{
            output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
            output +=  "Region Building: " + building.getName() + newline;
            output +=  "Region Height: " + region.lerpY((AbstractCharacter)target) + newline;
            output +=  "is Stairs: " + region.isStairs() + newline;
            output += "is Outside: " + region.isOutside() + newline;
            for(Vector3f point : region.regionPoints)
                output += point + newline;
            output += "NavMesh Data" + newline;
            this.throwbackInfo(pc, output);
        }
        Zone zone = ZoneManager.findSmallestZone(((AbstractCharacter) target).loc);
        if(zone != null) {
            output += "zone: " + zone.zoneName + newline;
            output += "on navmesh: " + zone.navMesh.contains(((AbstractCharacter) target).loc.x,((AbstractCharacter) target).loc.z) + newline;
        }else {
            output += "zone: null" + newline;
        }
        this.throwbackInfo(pc, output);
    }

    @Override
    protected String _getHelpString() {
        return "Temporarily Changes SubRace";
    }

    @Override
    protected String _getUsageString() {
        return "' /setBuildingCollidables add/remove 'add creates a collision line.' needs 4 integers. startX, endX, startY, endY";

    }

}
