DarkflameServer/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
1.0 KiB
C++
Raw Permalink Normal View History

#include "ActionContext.h"
#include <stdexcept>
#include "Amf3.h"
2024-02-27 07:29:51 +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) } {
}
2024-02-27 07:29:51 +00:00
BehaviorState ActionContext::GetBehaviorStateFromArgument(const AMFArrayValue& arguments, const std::string& key) const {
const auto* const stateIDValue = arguments.Get<double>(key);
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
return static_cast<BehaviorState>(stateIDValue->GetValue());
}
2024-02-27 07:29:51 +00:00
StripId ActionContext::GetStripIdFromArgument(const AMFArrayValue& arguments, const std::string& key) const {
const auto* const stripIdValue = arguments.Get<double>(key);
if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
return static_cast<StripId>(stripIdValue->GetValue());
}