diff options
author | Eugene Sandulenko | 2013-08-12 23:39:10 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-09-06 14:51:14 +0300 |
commit | 3cacf6486d09b2062f5cdb57d283977c7c71d2eb (patch) | |
tree | dfd825bfc654ef1550d24b7e193fdaa63d7c905d /engines/fullpipe | |
parent | 13059906c5f68bebb6344cf5617dc62243d146cf (diff) | |
download | scummvm-rg350-3cacf6486d09b2062f5cdb57d283977c7c71d2eb.tar.gz scummvm-rg350-3cacf6486d09b2062f5cdb57d283977c7c71d2eb.tar.bz2 scummvm-rg350-3cacf6486d09b2062f5cdb57d283977c7c71d2eb.zip |
FULLPIPE: Implement BehaviorManager::updateBehaviors()
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/behavior.cpp | 66 | ||||
-rw-r--r-- | engines/fullpipe/behavior.h | 34 |
2 files changed, 83 insertions, 17 deletions
diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp index 4f9e50d96b..cf1a436c6a 100644 --- a/engines/fullpipe/behavior.cpp +++ b/engines/fullpipe/behavior.cpp @@ -24,6 +24,8 @@ #include "fullpipe/objects.h" #include "fullpipe/behavior.h" +#include "fullpipe/statics.h" +#include "fullpipe/messages.h" namespace Fullpipe { @@ -37,7 +39,69 @@ void BehaviorManager::initBehavior(Scene *scene, CGameVar *var) { } void BehaviorManager::updateBehaviors() { - warning("STUB: BehaviorManager::updateBehaviors()"); + if (!_isActive) + return; + + for (uint i = 0; i < _behaviors.size(); i++) { + BehaviorInfo *beh = _behaviors[i]; + + if (!beh->_ani) { + beh->_counter++; + if (beh->_counter >= beh->_counterMax) + updateBehavior(beh, beh->_bheItems[0]); + + continue; + } + + if (beh->_ani->_movement || !(beh->_ani->_flags & 4) || (beh->_ani->_flags & 2)) { + beh->_staticsId = 0; + continue; + } + + if (beh->_ani->_statics->_staticsId == beh->_staticsId) { + beh->_counter++; + if (beh->_counter >= beh->_counterMax) { + if (beh->_subIndex >= 0 && !(beh->_flags & 1) && beh->_ani->_messageQueueId <= 0) + updateStaticAniBehavior(beh->_ani, beh->_counter, beh->_bheItems[beh->_subIndex]); + } + } else { + beh->_staticsId = beh->_ani->_statics->_staticsId; + beh->_counter = 0; + beh->_subIndex = -1; + + for (int j = 0; j < beh->_itemsCount; j++) + if (beh->_bheItems[j]->_staticsId == beh->_staticsId) { + beh->_subIndex = j; + break; + } + + } + } +} + +void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry *entry) { + for (int i = 0; i < entry->_itemsCount; i++) { + BehaviorEntryInfo *bhi = entry->_items[i]; + if (!(bhi->_flags & 1)) { + if (bhi->_flags & 2) { + MessageQueue *mq = new MessageQueue(entry->_items[i]->_messageQueue, 0, 1); + + mq->sendNextCommand(); + + entry->_items[i]->_flags &= 0xFFFFFFFD; + } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fullpipe->_rnd->getRandomNumber(32767) <= entry->_items[i]->_percent) { + MessageQueue *mq = new MessageQueue(entry->_items[i]->_messageQueue, 0, 1); + + mq->sendNextCommand(); + + behaviorInfo->_counter = 0; + } + } + } +} + +void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, unsigned int delay, BehaviorEntry *behaviorEntry) { + warning("STUB: BehaviorManager::updateStaticAniBehavior()"); } } // End of namespace Fullpipe diff --git a/engines/fullpipe/behavior.h b/engines/fullpipe/behavior.h index ea618fdfd6..5029b3ee17 100644 --- a/engines/fullpipe/behavior.h +++ b/engines/fullpipe/behavior.h @@ -25,22 +25,10 @@ namespace Fullpipe { -class BehaviorManager : public CObject { - CObArray _behaviors; - Scene *_scene; - bool _isActive; - - public: - BehaviorManager(); - - void initBehavior(Scene *scene, CGameVar *var); - void updateBehaviors(); -}; - struct BehaviorEntryInfo { - int _messageQueue; + MessageQueue *_messageQueue; int _delay; - int _percent; + uint _percent; int _flags; }; @@ -48,7 +36,7 @@ struct BehaviorEntry { int _staticsId; int _itemsCount; int _flags; - BehaviorEntryInfo *_items; + BehaviorEntryInfo **_items; }; struct BehaviorInfo { @@ -59,7 +47,21 @@ struct BehaviorInfo { int _flags; int _subIndex; int _itemsCount; - BehaviorEntryInfo *_items; + Common::Array<BehaviorEntry *> _bheItems; +}; + +class BehaviorManager : public CObject { + Common::Array<BehaviorInfo *> _behaviors; + Scene *_scene; + bool _isActive; + + public: + BehaviorManager(); + + void initBehavior(Scene *scene, CGameVar *var); + void updateBehaviors(); + void updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry *entry); + void updateStaticAniBehavior(StaticANIObject *ani, unsigned int delay, BehaviorEntry *behaviorEntry); }; } // End of namespace Fullpipe |