コード例 #1
0
ファイル: GameState.cpp プロジェクト: mkristofik/battle-sim
std::vector<int> GameState::getReachableHexes(const Unit &unit) const
{
    std::vector<int> reachable;

    // Flying units don't need a clear path.
    if (unit.canFly()) {
        for (int i = 0; i < grid_.size(); ++i) {
            if (isHexFlyable(unit, i)) {
                reachable.push_back(i);
            }
        }
    }
    else {
        Pathfinder pf;
        pf.setNeighbors([&] (int aIndex) {return getOpenNeighbors(aIndex);});
        reachable = pf.getReachableNodes(unit.aHex, unit.type->moves);
    }

    return reachable;
}