int PersonajeModelo::mover(std::pair<int, int>& destino, float& velocidadAni) { Pathfinder pathF; int cambio = SIN_CAMBIO; double coste = 0; float costeF = 0; if (this->target == this->getPosition()) { return (this->quedarseQuieto(velocidadAni)); } if (esNecesarioCalcularNuevoPath()) { posMov = 0; caminoSize = 0; limpiarPath(); targetParcial.first = target.first; targetParcial.second = target.second; caminoSize = pathF.getPath(this->getPosition().first, this->getPosition().second, targetParcial.first, targetParcial.second, xPath, yPath); if (caminoSize == 0) { //Si no se tiene que mover, seteo el destino en los parciales this->orientar(target); target.first = targetParcial.first; target.second = targetParcial.second; } if (caminoSize < 0) { return (this->quedarseQuieto(velocidadAni)); } } if (posMov < caminoSize) { this->moverse(destino, velocidadAni); } else { return (this->quedarseQuieto(velocidadAni)); } cambio = ESTADO_MOVIMIENTO; estado = cambiarEstado(destino.first, destino.second, cambio); return estado; }
std::vector<v3s16> get_path(ServerEnvironment* env, v3s16 source, v3s16 destination, unsigned int searchdistance, unsigned int max_jump, unsigned int max_drop, PathAlgorithm algo) { Pathfinder searchclass; return searchclass.getPath(env, source, destination, searchdistance, max_jump, max_drop, algo); }