2023-02-16 17:30:33 +00:00
|
|
|
#include "Action.h"
|
2024-01-03 13:34:38 +00:00
|
|
|
#include "Amf3.h"
|
2023-02-16 17:30:33 +00:00
|
|
|
|
2024-02-27 07:29:51 +00:00
|
|
|
Action::Action(const AMFArrayValue& arguments) {
|
|
|
|
for (const auto& [paramName, paramValue] : arguments.GetAssociative()) {
|
2024-01-03 13:34:38 +00:00
|
|
|
if (paramName == "Type") {
|
|
|
|
if (paramValue->GetValueType() != eAmf::String) continue;
|
2024-02-18 06:38:26 +00:00
|
|
|
m_Type = static_cast<AMFStringValue*>(paramValue)->GetValue();
|
2023-02-16 17:30:33 +00:00
|
|
|
} else {
|
2024-02-18 06:38:26 +00:00
|
|
|
m_ValueParameterName = paramName;
|
2023-02-16 17:30:33 +00:00
|
|
|
// Message is the only known string parameter
|
2024-02-18 06:38:26 +00:00
|
|
|
if (m_ValueParameterName == "Message") {
|
2024-01-03 13:34:38 +00:00
|
|
|
if (paramValue->GetValueType() != eAmf::String) continue;
|
2024-02-18 06:38:26 +00:00
|
|
|
m_ValueParameterString = static_cast<AMFStringValue*>(paramValue)->GetValue();
|
2023-02-16 17:30:33 +00:00
|
|
|
} else {
|
2024-01-03 13:34:38 +00:00
|
|
|
if (paramValue->GetValueType() != eAmf::Double) continue;
|
2024-02-18 06:38:26 +00:00
|
|
|
m_ValueParameterDouble = static_cast<AMFDoubleValue*>(paramValue)->GetValue();
|
2023-02-16 17:30:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-03 13:34:38 +00:00
|
|
|
|
|
|
|
void Action::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
2024-02-18 06:38:26 +00:00
|
|
|
auto* const actionArgs = args.PushArray();
|
|
|
|
actionArgs->Insert("Type", m_Type);
|
2024-01-03 13:34:38 +00:00
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
if (m_ValueParameterName.empty()) return;
|
2024-01-03 13:34:38 +00:00
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
if (m_ValueParameterName == "Message") {
|
|
|
|
actionArgs->Insert(m_ValueParameterName, m_ValueParameterString);
|
2024-01-03 13:34:38 +00:00
|
|
|
} else {
|
2024-02-18 06:38:26 +00:00
|
|
|
actionArgs->Insert(m_ValueParameterName, m_ValueParameterDouble);
|
2024-01-03 13:34:38 +00:00
|
|
|
}
|
|
|
|
}
|