Example #1
0
bool CMission::SetFailure (ICCItem *pData)

//	SetFailure
//
//	Mission failed

{
    //	Must be in the right state

    if (m_iStatus != statusAccepted && m_iStatus != statusClosed && m_iStatus != statusOpen)
        return false;

    //	Stop the mission

    if (m_iStatus != statusOpen)
    {
        FireOnStop(REASON_FAILURE, pData);

        CSpaceObject *pOwner = m_pOwner.GetObj();
        if (pOwner)
            pOwner->FireOnMissionCompleted(this, REASON_FAILURE);
    }

    //	Done

    CompleteMission(completeFailure);

    return true;
}
Example #2
0
bool CMission::SetSuccess (ICCItem *pData)

//	SetSuccess
//
//	Mission succeeded

{
    //	Must be in the right state

    if (m_iStatus != statusAccepted && m_iStatus != statusClosed && m_iStatus != statusOpen)
        return false;

    //	Stop the mission

    if (m_iStatus != statusOpen)
    {
        FireOnStop(REASON_SUCCESS, pData);

        CSpaceObject *pOwner = m_pOwner.GetObj();
        if (pOwner)
            pOwner->FireOnMissionCompleted(this, REASON_SUCCESS);
    }

    //	Done

    CompleteMission(completeSuccess);

    return true;
}
Example #3
0
void CMission::OnDestroyed (SDestroyCtx &Ctx)

//	OnDestroyed
//
//	Mission is destroyed

{
    if (m_fInOnCreate)
        return;

    //	If the mission is running then we need to stop

    if (m_iStatus == statusClosed || m_iStatus == statusAccepted)
    {
        FireOnStop(REASON_DESTROYED, NULL);

        CSpaceObject *pOwner = m_pOwner.GetObj();
        if (pOwner)
            pOwner->FireOnMissionCompleted(this, REASON_DESTROYED);
    }

    //	Make sure the mission is completed

    CompleteMission(completeDestroyed);

    //	Destroy the mission

    FireOnDestroy(Ctx);
}