示例#1
0
Vector2 GameEntity::TargetPosition() const
{
    Vector2 pos = Vector2::Inf();
    TID target = INVALID_TID;


    // Exhaustive ordered search in all possible positions a unit can head to
    target = g_GameImpl->UnitTarget(m_id);

    if (target != INVALID_TID)
    {
        pos = g_GameImpl->UnitPosition(target);
    }
    else
    {
        target = g_GameImpl->UnitOrderTarget(m_id);

        if (target != INVALID_TID)
        {
            pos = g_GameImpl->UnitPosition(target);
        }
        else
        {
            pos = g_GameImpl->UnitTargetPosition(m_id);

            if (pos.IsInf())
            {
                pos = g_GameImpl->UnitOrderTargetPosition(m_id);
            }
        }
    }

    return pos;
}
示例#2
0
bool GameEntity::Move(Vector2 targetPos)
{
    _ASSERTE(!targetPos.IsInf());
    if (!m_isOnline)
        DEBUG_THROW(InvalidOperationException(XcptHere));

    LogInfo("%s -> Move(%s)", ToString().c_str(), targetPos.ToString().c_str());

    //_ASSERTE(Broodwar->isWalkable(WalkPositionFromUnitPosition(pos.x), WalkPositionFromUnitPosition(pos.y)));
    if (g_GameImpl->UnitMove(m_id, targetPos))
        return true;
    else
    {
        DebugDrawMapLastGameError();
        return false;
    }
}