From 714e024128d17a4e7ccc49ef47f0f6bd7af71c70 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Tue, 15 Feb 2022 00:06:16 +0100 Subject: [PATCH] Add custom vars to director --- src/world/Event/Director.cpp | 13 +++++++++++++ src/world/Event/Director.h | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/world/Event/Director.cpp b/src/world/Event/Director.cpp index a3abe1f7..24fc89d3 100644 --- a/src/world/Event/Director.cpp +++ b/src/world/Event/Director.cpp @@ -121,3 +121,16 @@ uint8_t Sapphire::Event::Director::getDirectorVar( uint8_t index, bool shiftLeft { return getDirectorVar( index ) & ( shiftLeft ? 0xF0 : 0x0F ); } + +void Sapphire::Event::Director::setCustomVar( uint32_t index, uint64_t value ) +{ + m_customVarMap[ index ] = value; +} + +uint64_t Sapphire::Event::Director::getCustomVar( uint32_t index ) +{ + auto it = m_customVarMap.find( index ); + if( it != m_customVarMap.end() ) + return it->second; + return 0; +} diff --git a/src/world/Event/Director.h b/src/world/Event/Director.h index f81f9df4..9664c72b 100644 --- a/src/world/Event/Director.h +++ b/src/world/Event/Director.h @@ -100,6 +100,13 @@ namespace Sapphire::Event */ void setDirectorVar( uint8_t index, uint8_t valueLeft, uint8_t valueRight ); + /*! + * @brief Sets a value of a custom var + * @param index of var to set + * @param value to set + */ + void setCustomVar( uint32_t index, uint64_t value ); + /*! * @brief Gets a value of a director var * @param index of var to get @@ -114,6 +121,13 @@ namespace Sapphire::Event * @return 4 bits of selected index */ uint8_t getDirectorVar( uint8_t index, bool shiftLeft ); + + /*! + * @brief Gets a value of a custom var + * @param index of var to get + * @return custom var + */ + uint64_t getCustomVar( uint32_t index ); private: /*! Id of the content of the director */ uint16_t m_contextId; @@ -131,6 +145,9 @@ namespace Sapphire::Event /*! type of the director */ DirectorType m_type; + + /*! custom vars */ + std::unordered_map< uint32_t, uint64_t > m_customVarMap; }; } \ No newline at end of file