diff options
author | Treeki <treeki@gmail.com> | 2011-07-23 17:29:24 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-07-23 17:29:24 +0200 |
commit | 4a904e527a014430118c8e6b889599ba1cce43a9 (patch) | |
tree | 36f928a88d732f7a4799b95211a1c0d23828c7bd /src/eventblock.cpp | |
parent | 66a79a749c5decd612502923dadca10208b536ff (diff) | |
download | kamek-4a904e527a014430118c8e6b889599ba1cce43a9.tar.gz kamek-4a904e527a014430118c8e6b889599ba1cce43a9.zip |
added modes to event block
Diffstat (limited to '')
-rw-r--r-- | src/eventblock.cpp | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/src/eventblock.cpp b/src/eventblock.cpp index ad4e5e8..f285da8 100644 --- a/src/eventblock.cpp +++ b/src/eventblock.cpp @@ -5,12 +5,21 @@ class daEnEventBlock_c : public daEnBlockMain_c { public: + enum Mode { + TOGGLE_EVENT = 0, + SWAP_EVENTS = 1 + }; + typedef State<daEnEventBlock_c> State; TileRenderer tile; Physics::Info physicsInfo; - u8 eventNum; + u8 event1; + u8 event2; + Mode mode; + + void equaliseEvents(); int onCreate(); int onDelete(); @@ -62,7 +71,12 @@ int daEnEventBlock_c::onCreate() { tile.y = -(16 + pos.y); tile.tileNumber = 0x97; - eventNum = (settings & 0xFF) - 1; + mode = (Mode)((settings >> 16) & 0xF); + event1 = ((settings >> 8) & 0xFF) - 1; + event2 = (settings & 0xFF) - 1; + + equaliseEvents(); + doStateChange(&daEnEventBlock_c::StateID_Wait); return true; @@ -87,7 +101,11 @@ int daEnEventBlock_c::onExecute() { tile.setPosition(pos.x-8, -(16+pos.y), pos.z); tile.setVars(scale.x); - tile.tileNumber = (dFlagMgr_c::instance->active(eventNum) ? 0x96 : 0x97); + equaliseEvents(); + + bool isActive = dFlagMgr_c::instance->active(event2); + + tile.tileNumber = (isActive ? 0x96 : 0x97); // now check zone bounds based on state if (acState.getCurrentState()->isEqual(&StateID_Wait)) { @@ -110,13 +128,41 @@ daEnEventBlock_c *daEnEventBlock_c::build() { } +void daEnEventBlock_c::equaliseEvents() { + if (mode != SWAP_EVENTS) + return; + + bool f1 = dFlagMgr_c::instance->active(event1); + bool f2 = dFlagMgr_c::instance->active(event2); + + if (!f1 && !f2) { + dFlagMgr_c::instance->set(event1, 0, true, false, false); + } + + if (f1 && f2) { + dFlagMgr_c::instance->set(event2, 0, false, false, false); + } +} + + void daEnEventBlock_c::blockWasHit(bool isDown) { pos.y = initialY; - if (dFlagMgr_c::instance->active(eventNum)) - dFlagMgr_c::instance->set(eventNum, 0, false, false, false); - else - dFlagMgr_c::instance->set(eventNum, 0, true, false, false); + if (mode == TOGGLE_EVENT) { + if (dFlagMgr_c::instance->active(event2)) + dFlagMgr_c::instance->set(event2, 0, false, false, false); + else + dFlagMgr_c::instance->set(event2, 0, true, false, false); + + } else if (mode == SWAP_EVENTS) { + if (dFlagMgr_c::instance->active(event1)) { + dFlagMgr_c::instance->set(event1, 0, false, false, false); + dFlagMgr_c::instance->set(event2, 0, true, false, false); + } else { + dFlagMgr_c::instance->set(event1, 0, true, false, false); + dFlagMgr_c::instance->set(event2, 0, false, false, false); + } + } physics.setup(this, &physicsInfo, 3, currentLayerID); physics.addToList(); |