diff options
author | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:15:38 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2014-07-01 12:16:32 +0200 |
commit | d9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch) | |
tree | f6b71cc2daa719c10c1ce31cf738e1c6ec934a73 /src/object/task/taskgungoal.cpp | |
parent | 0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff) | |
parent | 1835d2ae580525603308206f7b8e6b4552b3ca0f (diff) | |
download | colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2 colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip |
Release 0.1.3-alpha
Diffstat (limited to 'src/object/task/taskgungoal.cpp')
-rw-r--r-- | src/object/task/taskgungoal.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp index 3373610..c9c8d30 100644 --- a/src/object/task/taskgungoal.cpp +++ b/src/object/task/taskgungoal.cpp @@ -26,6 +26,7 @@ CTaskGunGoal::CTaskGunGoal(CObject* object) : CTask(object) { + m_aimImpossible = false; } // Object's destructor. @@ -116,6 +117,12 @@ Error CTaskGunGoal::Start(float dirV, float dirH) m_progress = 0.0f; + // direction was constrainted, hence resulting in impossible move + if (dirV != m_finalDirV || dirH != m_finalDirH) + { + m_aimImpossible = true; + } + return ERR_OK; } @@ -126,12 +133,25 @@ Error CTaskGunGoal::IsEnded() if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_initialDirV == m_finalDirV && - m_initialDirH == m_finalDirH ) return ERR_STOP; - if ( m_progress < 1.0f ) return ERR_CONTINUE; + m_initialDirH == m_finalDirH ) + { + if ( m_aimImpossible ) + return ERR_AIM_IMPOSSIBLE; + else + return ERR_STOP; + } + + if ( m_progress < 1.0f ) return ERR_CONTINUE; m_object->SetGunGoalV(m_finalDirV); m_object->SetGunGoalH(m_finalDirH); Abort(); + + if ( m_aimImpossible ) + { + return ERR_AIM_IMPOSSIBLE; + } + return ERR_STOP; } |