From c25ab2537cb201dc46b7c1d375dd1c12411fe85c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 10 Feb 2021 20:09:42 -0500 Subject: Player movement/input is halted during cutscenes --- src/character_system.cpp | 12 ++++++++++++ src/character_system.h | 2 ++ src/script_system.cpp | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/character_system.cpp b/src/character_system.cpp index 781b50d..aad8c1b 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp @@ -248,6 +248,18 @@ void CharacterSystem::stopRunningSound(Sprite& sprite) { } } +void CharacterSystem::halt(int spriteId) { + // Because special stuff happens when we stop running, we have to handle the + // running case here. + Sprite& sprite = game_.getSprite(spriteId); + if (sprite.characterState == CharacterState::Running) { + stopRunning(spriteId); + } else { + // Other than that, it is simple to go to Still from Walking or Crouching. + setPartyState(spriteId, CharacterState::Still); + } +} + void CharacterSystem::clearSpriteCache() { for (Sprite& sprite : game_.getSprites() | game_.spriteView()) { if (sprite.runningSfxChannel != -1) { diff --git a/src/character_system.h b/src/character_system.h index 3933e1b..c6d4e6d 100644 --- a/src/character_system.h +++ b/src/character_system.h @@ -33,6 +33,8 @@ public: void startRunning(int spriteId); + void halt(int spriteId); + void clearSpriteCache() override; private: diff --git a/src/script_system.cpp b/src/script_system.cpp index 8fd5028..0fa0c1b 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -31,7 +31,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { engine_.new_usertype( "character", - "startRunning", &CharacterSystem::startRunning); + "startRunning", &CharacterSystem::startRunning, + "halt", &CharacterSystem::halt); engine_.new_usertype( "mixer", -- cgit 1.4.1