2023-02-16 17:30:33 +00:00
|
|
|
#include "ActionContext.h"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2023-05-13 22:22:00 +00:00
|
|
|
#include "Amf3.h"
|
2023-02-16 17:30:33 +00:00
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
ActionContext::ActionContext(const AMFArrayValue* arguments, const std::string& customStateKey, const std::string& customStripKey)
|
|
|
|
: m_StripId{ GetStripIdFromArgument(arguments, customStripKey) }
|
|
|
|
, m_StateId{ GetBehaviorStateFromArgument(arguments, customStateKey) } {
|
2023-02-16 17:30:33 +00:00
|
|
|
}
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
BehaviorState ActionContext::GetBehaviorStateFromArgument(const AMFArrayValue* arguments, const std::string& key) const {
|
|
|
|
const auto* const stateIDValue = arguments->Get<double>(key);
|
2023-02-16 17:30:33 +00:00
|
|
|
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
|
|
|
|
|
2023-05-13 22:22:00 +00:00
|
|
|
return static_cast<BehaviorState>(stateIDValue->GetValue());
|
2023-02-16 17:30:33 +00:00
|
|
|
}
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
StripId ActionContext::GetStripIdFromArgument(const AMFArrayValue* arguments, const std::string& key) const {
|
|
|
|
const auto* const stripIdValue = arguments->Get<double>(key);
|
2023-02-16 17:30:33 +00:00
|
|
|
if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
|
|
|
|
|
2023-05-13 22:22:00 +00:00
|
|
|
return static_cast<StripId>(stripIdValue->GetValue());
|
2023-02-16 17:30:33 +00:00
|
|
|
}
|