From 47d7b805070e317894efbed653b1d44cd789f2fa Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 16:44:22 +0200 Subject: Added object.factory(cat) --- src/object/auto/autofactory.cpp | 81 ++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 33 deletions(-) (limited to 'src/object/auto/autofactory.cpp') diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index 82877c6..6aca426 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -107,17 +107,59 @@ void CAutoFactory::Init() } +// Starts an action + +Error CAutoFactory::StartAction(int param) +{ + CObject* fret; + ObjectType type = static_cast(param); + + if ( type != OBJECT_NULL ) + { + if ( m_phase != AFP_WAIT ) + { + return ERR_OK; + } + + m_type = type; + + fret = SearchFret(); // transform metal? + if ( fret == 0 ) + { + return ERR_FACTORY_NULL; + } + if ( NearestVehicle() ) + { + return ERR_FACTORY_NEAR; + } + + SetBusy(true); + InitProgressTotal(3.0f+2.0f+15.0f+2.0f+3.0f); + UpdateInterface(); + + fret->SetLock(true); // usable metal + SoundManip(3.0f, 1.0f, 0.5f); + + m_phase = AFP_CLOSE_S; + m_progress = 0.0f; + m_speed = 1.0f/3.0f; + return ERR_OK; + } + return ERR_GENERIC; +} + + // Management of an event. bool CAutoFactory::EventProcess(const Event &event) { + ObjectType type; CObject* fret; CObject* vehicle; Math::Matrix* mat; CPhysics* physics; Math::Vector pos, speed; Math::Point dim; - ObjectType type; float zoom, angle, prog; int i; @@ -155,39 +197,12 @@ bool CAutoFactory::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_FACTORYrs ) type = OBJECT_MOBILErs; if ( event.type == EVENT_OBJECT_FACTORYsa ) type = OBJECT_MOBILEsa; - if ( type != OBJECT_NULL ) - { - m_type = type; - - if ( m_phase != AFP_WAIT ) - { - return false; - } + Error err = StartAction(type); + if( err != ERR_OK && err != ERR_GENERIC ) + m_displayText->DisplayError(err, m_object); - fret = SearchFret(); // transform metal? - if ( fret == 0 ) - { - m_displayText->DisplayError(ERR_FACTORY_NULL, m_object); - return false; - } - if ( NearestVehicle() ) - { - m_displayText->DisplayError(ERR_FACTORY_NEAR, m_object); - return false; - } - - SetBusy(true); - InitProgressTotal(3.0f+2.0f+15.0f+2.0f+3.0f); - UpdateInterface(); - - fret->SetLock(true); // usable metal - SoundManip(3.0f, 1.0f, 0.5f); - - m_phase = AFP_CLOSE_S; - m_progress = 0.0f; - m_speed = 1.0f/3.0f; - return true; - } + if( err != ERR_GENERIC ) + return false; } if ( event.type != EVENT_FRAME ) return true; -- cgit v1.2.3-1-g7c22