2024-01-03 13:34:38 +00:00
|
|
|
#include "State.h"
|
|
|
|
|
|
|
|
#include "Amf3.h"
|
|
|
|
#include "ControlBehaviorMsgs.h"
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(AddStripMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
m_Strips.resize(msg.GetActionContext().GetStripId() + 1);
|
|
|
|
}
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(AddActionMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(UpdateStripUiMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(RemoveActionsMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(RearrangeStripMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(UpdateActionMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(RemoveStripMessage& msg) {
|
|
|
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(SplitStripMessage& msg) {
|
|
|
|
if (msg.GetTransferredActions().empty()) {
|
|
|
|
if (m_Strips.size() <= msg.GetSourceActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetSourceActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
} else {
|
|
|
|
if (m_Strips.size() <= msg.GetDestinationActionContext().GetStripId()) {
|
|
|
|
m_Strips.resize(msg.GetDestinationActionContext().GetStripId() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(MergeStripsMessage& msg) {
|
|
|
|
if (msg.GetMigratedActions().empty()) {
|
|
|
|
if (m_Strips.size() <= msg.GetSourceActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetSourceActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
} else {
|
|
|
|
if (m_Strips.size() <= msg.GetDestinationActionContext().GetStripId()) {
|
|
|
|
m_Strips.resize(msg.GetDestinationActionContext().GetStripId() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
template <>
|
2024-01-03 13:34:38 +00:00
|
|
|
void State::HandleMsg(MigrateActionsMessage& msg) {
|
|
|
|
if (msg.GetMigratedActions().empty()) {
|
|
|
|
if (m_Strips.size() <= msg.GetSourceActionContext().GetStripId()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetSourceActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
} else {
|
|
|
|
if (m_Strips.size() <= msg.GetDestinationActionContext().GetStripId()) {
|
|
|
|
m_Strips.resize(msg.GetDestinationActionContext().GetStripId() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool State::IsEmpty() const {
|
2024-02-18 06:38:26 +00:00
|
|
|
for (const auto& strip : m_Strips) {
|
2024-01-03 13:34:38 +00:00
|
|
|
if (!strip.IsEmpty()) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void State::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
2024-02-18 06:38:26 +00:00
|
|
|
auto* const strips = args.InsertArray("strips");
|
|
|
|
for (size_t stripId = 0; stripId < m_Strips.size(); ++stripId) {
|
|
|
|
const auto& strip = m_Strips.at(stripId);
|
2024-01-03 13:34:38 +00:00
|
|
|
if (strip.IsEmpty()) continue;
|
|
|
|
|
2024-02-18 06:38:26 +00:00
|
|
|
auto* const stripArgs = strips->PushArray();
|
2024-01-03 13:34:38 +00:00
|
|
|
stripArgs->Insert("id", static_cast<double>(stripId));
|
|
|
|
|
|
|
|
strip.SendBehaviorBlocksToClient(*stripArgs);
|
|
|
|
}
|
|
|
|
};
|