From 936839062a428a2bb8fe88a58b9df751c0aba5bb Mon Sep 17 00:00:00 2001 From: XProger Date: Mon, 25 Sep 2017 05:25:31 +0300 Subject: [PATCH] #22 add Nathla Mines cabin --- src/format.h | 2 +- src/level.h | 3 +++ src/trigger.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/format.h b/src/format.h index c8a6c5b..6ea3e85 100644 --- a/src/format.h +++ b/src/format.h @@ -173,7 +173,7 @@ E( UNUSED_12 ) \ E( SMOKE ) \ E( STATUE ) \ - E( SHACK ) \ + E( CABIN ) \ E( MUTANT_EGG_SMALL ) \ E( RICOCHET ) \ E( SPARKLES ) \ diff --git a/src/level.h b/src/level.h index 330e54e..5dcf5da 100644 --- a/src/level.h +++ b/src/level.h @@ -439,6 +439,9 @@ struct Level : IGame { case TR::Entity::TRAP_LAVA : entity.controller = new TrapLava(this, i); break; + case TR::Entity::CABIN : + entity.controller = new Cabin(this, i); + break; default : if (entity.modelIndex > 0) entity.controller = new Controller(this, i); diff --git a/src/trigger.h b/src/trigger.h index 9bc3a88..23a0f3e 100644 --- a/src/trigger.h +++ b/src/trigger.h @@ -710,6 +710,37 @@ struct TrapLava : Controller { }; +struct Cabin : Controller { + enum { + STATE_UP, + STATE_DOWN_1, + STATE_DOWN_2, + STATE_DOWN_3, + STATE_GROUND, + }; + + Cabin(IGame *game, int entity) : Controller(game, entity) {} + + virtual void update() { + TR::Entity &e = getEntity(); + + if (e.flags.active == TR::ACTIVE) { + if (state >= STATE_UP && state <= STATE_DOWN_2) + animation.setState(state + 1); + e.flags.active = 0; + } + + if (state == STATE_GROUND) { + e.flags.invisible = true; + level->flipmap[3].active = TR::ACTIVE; + level->isFlipped = !level->isFlipped; + deactivate(true); + } + + updateAnimation(true); + } +}; + struct KeyHole : Controller { KeyHole(IGame *game, int entity) : Controller(game, entity) {}