diff options
author | krzys-h <krzys_h@interia.pl> | 2013-05-18 16:44:22 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2013-05-18 18:04:48 +0200 |
commit | 47d7b805070e317894efbed653b1d44cd789f2fa (patch) | |
tree | feb09d4dd408f53371b2fbd6fd2f8d37a70554a3 /src/object/auto | |
parent | 07839a561fa876539484fdc44e68d3f17e20a89b (diff) | |
download | colobot-47d7b805070e317894efbed653b1d44cd789f2fa.tar.gz colobot-47d7b805070e317894efbed653b1d44cd789f2fa.tar.bz2 colobot-47d7b805070e317894efbed653b1d44cd789f2fa.zip |
Added object.factory(cat)
Diffstat (limited to 'src/object/auto')
-rw-r--r-- | src/object/auto/auto.cpp | 6 | ||||
-rw-r--r-- | src/object/auto/auto.h | 2 | ||||
-rw-r--r-- | src/object/auto/autofactory.cpp | 81 | ||||
-rw-r--r-- | src/object/auto/autofactory.h | 2 |
4 files changed, 58 insertions, 33 deletions
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp index 3d88012..8dc1d94 100644 --- a/src/object/auto/auto.cpp +++ b/src/object/auto/auto.cpp @@ -107,6 +107,12 @@ void CAuto::Start(int param) { } +// Starts an action + +Error CAuto::StartAction(int param) +{ + return ERR_GENERIC; +} // Gete a type. diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h index 53ccdf9..e27804c 100644 --- a/src/object/auto/auto.h +++ b/src/object/auto/auto.h @@ -61,6 +61,8 @@ public: virtual Error IsEnded(); virtual bool Abort(); + virtual Error StartAction(int param); + virtual bool SetType(ObjectType type); virtual bool SetValue(int rank, float value); virtual bool SetString(char *string); 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<ObjectType>(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; diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h index 7c5013d..e5a415b 100644 --- a/src/object/auto/autofactory.h +++ b/src/object/auto/autofactory.h @@ -48,6 +48,8 @@ public: void Init(); bool EventProcess(const Event &event); + Error StartAction(int param); + bool CreateInterface(bool bSelect); bool Write(char *line); |