diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp new file mode 100644 index 00000000..7da286b0 --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp @@ -0,0 +1,31 @@ +#include "Action.h" + +Action::Action() { + type = ""; + valueParameterName = ""; + valueParameterString = ""; + valueParameterDouble = 0.0; +} + +Action::Action(AMFArrayValue* arguments) { + type = ""; + valueParameterName = ""; + valueParameterString = ""; + valueParameterDouble = 0.0; + for (auto& typeValueMap : arguments->GetAssociativeMap()) { + if (typeValueMap.first == "Type") { + if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; + type = static_cast(typeValueMap.second)->GetStringValue(); + } else { + valueParameterName = typeValueMap.first; + // Message is the only known string parameter + if (valueParameterName == "Message") { + if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; + valueParameterString = static_cast(typeValueMap.second)->GetStringValue(); + } else { + if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue; + valueParameterDouble = static_cast(typeValueMap.second)->GetDoubleValue(); + } + } + } +} diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.h new file mode 100644 index 00000000..c97b4050 --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.h @@ -0,0 +1,25 @@ +#ifndef __ACTION__H__ +#define __ACTION__H__ + +#include "BehaviorMessageBase.h" + +/** + * @brief Sent if a ControlBehavior message has an Action associated with it + * + */ +class Action { +public: + Action(); + Action(AMFArrayValue* arguments); + const std::string& GetType() { return type; }; + const std::string& GetValueParameterName() { return valueParameterName; }; + const std::string& GetValueParameterString() { return valueParameterString; }; + const double GetValueParameterDouble() { return valueParameterDouble; }; +private: + std::string type; + std::string valueParameterName; + std::string valueParameterString; + double valueParameterDouble; +}; + +#endif //!__ACTION__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp new file mode 100644 index 00000000..480eef45 --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp @@ -0,0 +1,31 @@ +#include "ActionContext.h" + +#include + +#include "AMFFormat.h" + +ActionContext::ActionContext() { + stripId = 0; + stateId = BehaviorState::HOME_STATE; +} + +ActionContext::ActionContext(AMFArrayValue* arguments, std::string customStateKey, std::string customStripKey) { + stripId = 0; + stateId = BehaviorState::HOME_STATE; + stripId = GetStripIdFromArgument(arguments, customStripKey); + stateId = GetBehaviorStateFromArgument(arguments, customStateKey); +} + +BehaviorState ActionContext::GetBehaviorStateFromArgument(AMFArrayValue* arguments, const std::string& key) { + auto* stateIDValue = arguments->FindValue(key); + if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\""); + + return static_cast(stateIDValue->GetDoubleValue()); +} + +StripId ActionContext::GetStripIdFromArgument(AMFArrayValue* arguments, const std::string& key) { + auto* stripIdValue = arguments->FindValue(key); + if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\""); + + return static_cast(stripIdValue->GetDoubleValue()); +} diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.h new file mode 100644 index 00000000..5f46fd8c --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.h @@ -0,0 +1,26 @@ +#ifndef __ACTIONCONTEXT__H__ +#define __ACTIONCONTEXT__H__ + +#include "BehaviorStates.h" +#include "dCommonVars.h" + +class AMFArrayValue; + +/** + * @brief Sent if contextual State and Strip informationis needed for a ControlBehaviors message + * + */ +class ActionContext { +public: + ActionContext(); + ActionContext(AMFArrayValue* arguments, std::string customStateKey = "stateID", std::string customStripKey = "stripID"); + const StripId GetStripId() { return stripId; }; + const BehaviorState GetStateId() { return stateId; }; +private: + BehaviorState GetBehaviorStateFromArgument(AMFArrayValue* arguments, const std::string& key); + StripId GetStripIdFromArgument(AMFArrayValue* arguments, const std::string& key); + StripId stripId; + BehaviorState stateId; +}; + +#endif //!__ACTIONCONTEXT__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp index f91512fe..4fc7f82b 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp @@ -1,39 +1,13 @@ #include "AddActionMessage.h" -AddActionMessage::AddActionMessage(AMFArrayValue* arguments) { - auto* actionIndexAmf = arguments->FindValue("actionIndex"); - if (!actionIndexAmf) return; +AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + actionContext = ActionContext(arguments); + actionIndex = GetActionIndexFromArgument(arguments); - actionIndex = static_cast(actionIndexAmf->GetDoubleValue()); + auto* actionValue = arguments->FindValue("action"); + if (!actionValue) return; - stripId = GetStripIDFromArgument(arguments); + action = Action(actionValue); - stateId = GetBehaviorStateFromArgument(arguments); - - type = ""; - valueParameterName = ""; - valueParameterString = ""; - valueParameterDouble = 0.0; - auto* action = arguments->FindValue("action"); - if (!action) return; - - for (auto& typeValueMap : action->GetAssociativeMap()) { - if (typeValueMap.first == "Type") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - type = static_cast(typeValueMap.second)->GetStringValue(); - } else { - valueParameterName = typeValueMap.first; - // Message is the only known string parameter - if (valueParameterName == "Message") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - valueParameterString = static_cast(typeValueMap.second)->GetStringValue(); - } else { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue; - valueParameterDouble = static_cast(typeValueMap.second)->GetDoubleValue(); - } - } - } - - behaviorId = GetBehaviorIDFromArgument(arguments); - Game::logger->LogDebug("AddActionMessage", "acnNdx %i stpId %i sttId %i t %s vpn %s vps %s vpd %f bhId %i", actionIndex, stripId, stateId, type.c_str(), valueParameterName.c_str(), valueParameterString.c_str(), valueParameterDouble, behaviorId); + Game::logger->LogDebug("AddActionMessage", "actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i", actionIndex, actionContext.GetStripId(), actionContext.GetStateId(), action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.h index 1f1577ec..4faf6a53 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.h @@ -1,30 +1,26 @@ #ifndef __ADDACTIONMESSAGE__H__ #define __ADDACTIONMESSAGE__H__ +#include "Action.h" +#include "ActionContext.h" #include "BehaviorMessageBase.h" class AMFArrayValue; +/** + * @brief Send if a player takes an Action A from the toolbox and adds it to an already existing strip + * + */ class AddActionMessage : public BehaviorMessageBase { public: AddActionMessage(AMFArrayValue* arguments); const uint32_t GetActionIndex() { return actionIndex; }; - const StripId GetStripId() { return stripId; }; - const BehaviorState GetStateId() { return stateId; }; - const std::string& GetType() { return type; }; - const std::string& GetValueParameterName() { return valueParameterName; }; - const std::string& GetValueParameterString() { return valueParameterString; }; - const double GetValueParameterDouble() { return valueParameterDouble; }; - const uint32_t GetBehaviorId() { return behaviorId; }; + Action GetAction() { return action; }; + ActionContext GetActionContext() { return actionContext; }; private: uint32_t actionIndex; - StripId stripId; - BehaviorState stateId; - std::string type; - std::string valueParameterName; - std::string valueParameterString; - double valueParameterDouble; - uint32_t behaviorId; + ActionContext actionContext; + Action action; }; #endif //!__ADDACTIONMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp index ecddb8e3..4f2123b4 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp @@ -1,13 +1,11 @@ #include "AddMessage.h" -AddMessage::AddMessage(AMFArrayValue* arguments) { - behaviorId = GetBehaviorIDFromArgument(arguments); - +AddMessage::AddMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { behaviorIndex = 0; auto* behaviorIndexValue = arguments->FindValue("BehaviorIndex"); if (!behaviorIndexValue) return; behaviorIndex = static_cast(behaviorIndexValue->GetDoubleValue()); - Game::logger->LogDebug("AddMessage", "bhId %i ndx %i", behaviorId, behaviorIndex); + Game::logger->LogDebug("AddMessage", "behaviorId %i index %i", behaviorId, behaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.h index ff8e0c8b..a46d5f98 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.h @@ -3,13 +3,15 @@ #include "BehaviorMessageBase.h" +/** + * @brief Sent when a player adds a Behavior A from their inventory to a model. + * + */ class AddMessage : public BehaviorMessageBase { public: AddMessage(AMFArrayValue* arguments); const uint32_t GetBehaviorIndex() { return behaviorIndex; }; - const uint32_t GetBehaviorId() { return behaviorId; }; private: - uint32_t behaviorId; uint32_t behaviorIndex; }; diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp index 23662174..c4729c57 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp @@ -1,56 +1,25 @@ #include "AddStripMessage.h" -AddStripMessage::AddStripMessage(AMFArrayValue* arguments) { +#include "Action.h" + +AddStripMessage::AddStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + actionContext = ActionContext(arguments); + + position = StripUiPosition(arguments); + auto* strip = arguments->FindValue("strip"); if (!strip) return; auto* actions = strip->FindValue("actions"); if (!actions) return; - auto* uiArray = arguments->FindValue("ui"); - if (!uiArray) return; + for (uint32_t actionNumber = 0; actionNumber < actions->GetDenseValueSize(); actionNumber++) { + auto* actionValue = actions->GetValueAt(actionNumber); + if (!actionValue) continue; - auto* xPositionValue = uiArray->FindValue("x"); - if (!xPositionValue) return; + actionsToAdd.push_back(Action(actionValue)); - xPosition = xPositionValue->GetDoubleValue(); - - auto* yPositionValue = uiArray->FindValue("y"); - if (!yPositionValue) return; - - yPosition = yPositionValue->GetDoubleValue(); - - stripId = GetStripIDFromArgument(arguments); - - stateId = GetBehaviorStateFromArgument(arguments); - - behaviorId = GetBehaviorIDFromArgument(arguments); - - type = ""; - valueParameterName = ""; - valueParameterString = ""; - valueParameterDouble = 0.0; - for (uint32_t position = 0; position < actions->GetDenseValueSize(); position++) { - auto* actionAsArray = actions->GetValueAt(position); - if (!actionAsArray) continue; - - for (auto& typeValueMap : actionAsArray->GetAssociativeMap()) { - if (typeValueMap.first == "Type") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - - type = static_cast(typeValueMap.second)->GetStringValue(); - } else { - valueParameterName = typeValueMap.first; - // Message is the only known string parameter - if (valueParameterName == "Message") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - valueParameterString = static_cast(typeValueMap.second)->GetStringValue(); - } else { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue; - valueParameterDouble = static_cast(typeValueMap.second)->GetDoubleValue(); - } - } - } - Game::logger->LogDebug("AddStripMessage", "x %f y %f stpId %i sttId %i bhId %i t %s vpn %s vps %s vpd %f", xPosition, yPosition, stripId, stateId, behaviorId, type.c_str(), valueParameterName.c_str(), valueParameterString.c_str(), valueParameterDouble); + Game::logger->LogDebug("AddStripMessage", "xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId, actionsToAdd.back().GetType().c_str(), actionsToAdd.back().GetValueParameterName().c_str(), actionsToAdd.back().GetValueParameterString().c_str(), actionsToAdd.back().GetValueParameterDouble()); } + Game::logger->Log("AddStripMessage", "number of actions %i", actionsToAdd.size()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.h index bb720bae..db75aef7 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.h @@ -1,32 +1,31 @@ #ifndef __ADDSTRIPMESSAGE__H__ #define __ADDSTRIPMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" +#include "StripUiPosition.h" +#include + +class Action; class AMFArrayValue; +/** + * @brief Sent in 2 contexts: + * A player adds an Action A from their toolbox without attaching it to an existing Strip. In this case, only 1 action is sent. + * A player moves a Strip from BehaviorState A directly to BehaviorState B. In this case, a list of actions are sent. + * + */ class AddStripMessage : public BehaviorMessageBase { public: AddStripMessage(AMFArrayValue* arguments); - const StripId GetStripId() { return stripId; }; - const BehaviorState GetStateId() { return stateId; }; - const std::string& GetType() { return type; }; - const std::string& GetValueParameterName() { return valueParameterName; }; - const std::string& GetValueParameterString() { return valueParameterString; }; - const double GetXPosition() { return xPosition; }; - const double GetYPosition() { return yPosition; }; - const double GetValueParameterDouble() { return valueParameterDouble; }; - const uint32_t GetBehaviorId() { return behaviorId; }; + StripUiPosition GetPosition() { return position; }; + ActionContext GetActionContext() { return actionContext; }; + std::vector GetActionsToAdd() { return actionsToAdd; }; private: - double xPosition; - double yPosition; - StripId stripId; - BehaviorState stateId; - uint32_t behaviorId; - std::string type; - std::string valueParameterName; - std::string valueParameterString; - double valueParameterDouble; + StripUiPosition position; + ActionContext actionContext; + std::vector actionsToAdd; }; #endif //!__ADDSTRIPMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp new file mode 100644 index 00000000..b3d98d51 --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp @@ -0,0 +1,33 @@ +#include "BehaviorMessageBase.h" + +#include "AMFFormat.h" +#include "BehaviorStates.h" +#include "dCommonVars.h" + +BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) { + behaviorId = 0; + behaviorId = GetBehaviorIdFromArgument(arguments); +} + +int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) { + const auto* key = "BehaviorID"; + auto* behaviorIDValue = arguments->FindValue(key); + int32_t behaviorID = -1; + + if (behaviorIDValue) { + behaviorID = std::stoul(behaviorIDValue->GetStringValue()); + } else if (!arguments->FindValue(key)) { + throw std::invalid_argument("Unable to find behavior ID"); + } + + return behaviorID; +} + +uint32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) { + auto* actionIndexAmf = arguments->FindValue(keyName); + if (!actionIndexAmf) { + throw std::invalid_argument("Unable to find actionIndex"); + } + + return static_cast(actionIndexAmf->GetDoubleValue()); +} diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h index 78025672..13b00a35 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h @@ -5,44 +5,25 @@ #include #include "AMFFormat.h" -#include "BehaviorStates.h" #include "dCommonVars.h" #include "Game.h" #include "dLogger.h" +enum class BehaviorState : uint32_t; + +/** + * @brief The behaviorID target of this ControlBehaviors message + * + */ class BehaviorMessageBase { public: - uint32_t GetBehaviorIDFromArgument(AMFArrayValue* arguments, const std::string& key = "BehaviorID") { - auto* behaviorIDValue = arguments->FindValue(key); - uint32_t behaviorID = -1; - - if (behaviorIDValue) { - behaviorID = std::stoul(behaviorIDValue->GetStringValue()); - } else if (arguments->FindValue(key) == nullptr) { - throw std::invalid_argument("Unable to find behavior ID from argument \"" + key + "\""); - } - - return behaviorID; - } - - BehaviorState GetBehaviorStateFromArgument(AMFArrayValue* arguments, const std::string& key = "stateID") { - auto* stateIDValue = arguments->FindValue(key); - if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\""); - - BehaviorState stateID = static_cast(stateIDValue->GetDoubleValue()); - - return stateID; - } - - StripId GetStripIDFromArgument(AMFArrayValue* arguments, const std::string& key = "stripID") { - auto* stripIDValue = arguments->FindValue(key); - if (!stripIDValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\""); - - StripId stripID = static_cast(stripIDValue->GetDoubleValue()); - - return stripID; - } + const uint32_t GetBehaviorId() { return behaviorId; }; +protected: + BehaviorMessageBase(AMFArrayValue* arguments); + int32_t GetBehaviorIdFromArgument(AMFArrayValue* arguments); + uint32_t GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName = "actionIndex"); + int32_t behaviorId = -1; }; #endif //!__BEHAVIORMESSAGEBASE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/CMakeLists.txt b/dGame/dPropertyBehaviors/ControlBehaviorMessages/CMakeLists.txt index 8390cd22..49b0f460 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/CMakeLists.txt +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/CMakeLists.txt @@ -1,7 +1,10 @@ set(DGAME_DPROPERTYBEHAVIORS_CONTROLBEHAVIORMESSAGES + "Action.cpp" + "ActionContext.cpp" "AddActionMessage.cpp" "AddMessage.cpp" "AddStripMessage.cpp" + "BehaviorMessageBase.cpp" "MergeStripsMessage.cpp" "MigrateActionsMessage.cpp" "MoveToInventoryMessage.cpp" @@ -10,6 +13,7 @@ set(DGAME_DPROPERTYBEHAVIORS_CONTROLBEHAVIORMESSAGES "RemoveStripMessage.cpp" "RenameMessage.cpp" "SplitStripMessage.cpp" + "StripUiPosition.cpp" "UpdateActionMessage.cpp" "UpdateStripUiMessage.cpp" PARENT_SCOPE diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp index d810e861..df50641a 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.cpp @@ -1,20 +1,11 @@ #include "MergeStripsMessage.h" -MergeStripsMessage::MergeStripsMessage(AMFArrayValue* arguments) { - srcStripID = GetStripIDFromArgument(arguments, "srcStripID"); +MergeStripsMessage::MergeStripsMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + sourceActionContext = ActionContext(arguments, "srcStateID", "srcStripID"); - dstStateID = GetBehaviorStateFromArgument(arguments, "dstStateID"); + destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID"); + dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex"); - srcStateID = GetBehaviorStateFromArgument(arguments, "srcStateID"); - - auto* dstActionIndexValue = arguments->FindValue("dstActionIndex"); - if (!dstActionIndexValue) return; - - dstActionIndex = static_cast(dstActionIndexValue->GetDoubleValue()); - - dstStripID = GetStripIDFromArgument(arguments, "dstStripID"); - - behaviorID = GetBehaviorIDFromArgument(arguments); - Game::logger->LogDebug("MergeStripsMessage", "srcStpId %i dstStpId %i srcSttId %i dstSttId %i dstAcnNdx %i bhId %i", srcStripID, dstStripID, srcStateID, dstStateID, dstActionIndex, behaviorID); + Game::logger->LogDebug("MergeStripsMessage", "srcstripId %i dststripId %i srcstateId %i dststateId %i dstactionIndex %i behaviorId %i", sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), dstActionIndex, behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.h index af3aa16f..0aff7f3a 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MergeStripsMessage.h @@ -1,26 +1,25 @@ #ifndef __MERGESTRIPSMESSAGE__H__ #define __MERGESTRIPSMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" class AMFArrayValue; +/** + * @brief Sent when a player adds the first Action of Strip A to a Strip B + * + */ class MergeStripsMessage : public BehaviorMessageBase { public: MergeStripsMessage(AMFArrayValue* arguments); - const StripId GetSrcStripID() { return srcStripID; }; - const BehaviorState GetDstStateID() { return dstStateID; }; - const BehaviorState GetSrcStateID() { return srcStateID; }; const uint32_t GetDstActionIndex() { return dstActionIndex; }; - const StripId GetDstStripID() { return dstStripID; }; - const uint32_t GetBehaviorID() { return behaviorID; }; + ActionContext GetSourceActionContext() { return sourceActionContext; }; + ActionContext GetDestinationActionContext() { return destinationActionContext; }; private: - StripId srcStripID; - BehaviorState dstStateID; - BehaviorState srcStateID; + ActionContext sourceActionContext; + ActionContext destinationActionContext; uint32_t dstActionIndex; - StripId dstStripID; - uint32_t behaviorID; }; #endif //!__MERGESTRIPSMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp index 8bb4e819..08f830a4 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.cpp @@ -1,24 +1,11 @@ #include "MigrateActionsMessage.h" -MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) { - auto* srcActionIndexAmf = arguments->FindValue("srcActionIndex"); - if (!srcActionIndexAmf) return; +MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + sourceActionContext = ActionContext(arguments, "srcStateID", "srcStripID"); + srcActionIndex = GetActionIndexFromArgument(arguments, "srcActionIndex"); - srcActionIndex = static_cast(srcActionIndexAmf->GetDoubleValue()); + destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID"); + dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex"); - srcStripID = GetStripIDFromArgument(arguments, "srcStripID"); - - srcStateID = GetBehaviorStateFromArgument(arguments, "srcStateID"); - - auto* dstActionIndexAmf = arguments->FindValue("dstActionIndex"); - if (!dstActionIndexAmf) return; - - dstActionIndex = static_cast(dstActionIndexAmf->GetDoubleValue()); - - dstStripID = GetStripIDFromArgument(arguments, "dstStripID"); - - dstStateID = GetBehaviorStateFromArgument(arguments, "dstStateID"); - - behaviorID = GetBehaviorIDFromArgument(arguments); - Game::logger->LogDebug("MigrateActionsMessage", "srcAcnNdx %i dstAcnNdx %i srcStpId %i dstStpId %i srcSttId %i dstSttId %i bhid %i", srcActionIndex, dstActionIndex, srcStripID, dstStripID, srcStateID, dstStateID, behaviorID); + Game::logger->LogDebug("MigrateActionsMessage", "srcactionIndex %i dstactionIndex %i srcstripId %i dststripId %i srcstateId %i dststateId %i behaviorId %i", srcActionIndex, dstActionIndex, sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.h index 26018d69..f60e8748 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MigrateActionsMessage.h @@ -1,28 +1,27 @@ #ifndef __MIGRATEACTIONSMESSAGE__H__ #define __MIGRATEACTIONSMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" class AMFArrayValue; +/** + * @brief Sent when a player moves an Action after the first Action to a different Strip + * + */ class MigrateActionsMessage : public BehaviorMessageBase { public: MigrateActionsMessage(AMFArrayValue* arguments); const uint32_t GetSrcActionIndex() { return srcActionIndex; }; - const StripId GetSrcStripID() { return srcStripID; }; - const BehaviorState GetSrcStateID() { return srcStateID; }; const uint32_t GetDstActionIndex() { return dstActionIndex; }; - const StripId GetDstStripID() { return dstStripID; }; - const BehaviorState GetDstStateID() { return dstStateID; }; - const uint32_t GetBehaviorID() { return behaviorID; }; + ActionContext GetSourceActionContext() { return sourceActionContext; }; + ActionContext GetDestinationActionContext() { return destinationActionContext; }; private: + ActionContext sourceActionContext; + ActionContext destinationActionContext; uint32_t srcActionIndex; - StripId srcStripID; - BehaviorState srcStateID; uint32_t dstActionIndex; - StripId dstStripID; - BehaviorState dstStateID; - uint32_t behaviorID; }; #endif //!__MIGRATEACTIONSMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp index 7ad7a875..92700076 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp @@ -1,11 +1,9 @@ #include "MoveToInventoryMessage.h" -MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) { - behaviorID = GetBehaviorIDFromArgument(arguments); - +MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { auto* behaviorIndexValue = arguments->FindValue("BehaviorIndex"); if (!behaviorIndexValue) return; behaviorIndex = static_cast(behaviorIndexValue->GetDoubleValue()); - Game::logger->LogDebug("MoveToInventoryMessage", "bhId %i bhNdx %i", behaviorID, behaviorIndex); + Game::logger->LogDebug("MoveToInventoryMessage", "behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h index 2cf71f3c..c48f7d17 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.h @@ -5,14 +5,16 @@ class AMFArrayValue; +/** + * @brief Sent when a player moves a Behavior A at position B to their inventory. + * + */ #pragma warning("This Control Behavior Message does not have a test yet. Non-developers can ignore this warning.") -class MoveToInventoryMessage: public BehaviorMessageBase { +class MoveToInventoryMessage : public BehaviorMessageBase { public: MoveToInventoryMessage(AMFArrayValue* arguments); - const uint32_t GetBehaviorID() { return behaviorID; }; const uint32_t GetBehaviorIndex() { return behaviorIndex; }; private: - uint32_t behaviorID; uint32_t behaviorIndex; }; diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp index 0347aca6..4018a423 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.cpp @@ -1,16 +1,10 @@ #include "RearrangeStripMessage.h" -RearrangeStripMessage::RearrangeStripMessage(AMFArrayValue* arguments) { - auto* srcActionIndexValue = arguments->FindValue("srcActionIndex"); - srcActionIndex = static_cast(srcActionIndexValue->GetDoubleValue()); +RearrangeStripMessage::RearrangeStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + actionContext = ActionContext(arguments); + srcActionIndex = GetActionIndexFromArgument(arguments, "srcActionIndex"); - stripID = GetStripIDFromArgument(arguments); + dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex"); - behaviorID = GetBehaviorIDFromArgument(arguments); - - auto* dstActionIndexValue = arguments->FindValue("dstActionIndex"); - dstActionIndex = static_cast(dstActionIndexValue->GetDoubleValue()); - - stateID = GetBehaviorStateFromArgument(arguments); - Game::logger->LogDebug("RearrangeStripMessage", "srcAcnNdx %i dstAcnNdx %i stpId %i bhId %i sttId %i", srcActionIndex, dstActionIndex, stripID, behaviorID, stateID); + Game::logger->LogDebug("RearrangeStripMessage", "srcactionIndex %i dstactionIndex %i stripId %i behaviorId %i stateId %i", srcActionIndex, dstActionIndex, actionContext.GetStripId(), behaviorId, actionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.h index 4cca0827..46819404 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RearrangeStripMessage.h @@ -1,22 +1,23 @@ #ifndef __REARRANGESTRIPMESSAGE__H__ #define __REARRANGESTRIPMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" +/** + * @brief Sent when a player moves an Action around in the same strip + * + */ class RearrangeStripMessage : public BehaviorMessageBase { public: RearrangeStripMessage(AMFArrayValue* arguments); const uint32_t GetSrcActionIndex() { return srcActionIndex; }; - const uint32_t GetStripID() { return stripID; }; - const uint32_t GetBehaviorID() { return behaviorID; }; const uint32_t GetDstActionIndex() { return dstActionIndex; }; - const BehaviorState GetStateID() { return stateID; }; + ActionContext GetActionContext() { return actionContext; }; private: + ActionContext actionContext; uint32_t srcActionIndex; - uint32_t stripID; - uint32_t behaviorID; uint32_t dstActionIndex; - BehaviorState stateID; }; #endif //!__REARRANGESTRIPMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp index cb1226e3..8f00d2b0 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.cpp @@ -1,15 +1,8 @@ #include "RemoveActionsMessage.h" -RemoveActionsMessage::RemoveActionsMessage(AMFArrayValue* arguments) { - behaviorID = GetBehaviorIDFromArgument(arguments); +RemoveActionsMessage::RemoveActionsMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + actionContext = ActionContext(arguments); + actionIndex = GetActionIndexFromArgument(arguments); - auto* actionIndexAmf = arguments->FindValue("actionIndex"); - if (!actionIndexAmf) return; - - actionIndex = static_cast(actionIndexAmf->GetDoubleValue()); - - stripID = GetStripIDFromArgument(arguments); - - stateID = GetBehaviorStateFromArgument(arguments); - Game::logger->LogDebug("RemoveActionsMessage", "bhId %i acnNdx %i stpId %i sttId %i", behaviorID, actionIndex, stripID, stateID); + Game::logger->LogDebug("RemoveActionsMessage", "behaviorId %i actionIndex %i stripId %i stateId %i", behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.h index 33678f59..457ddba8 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveActionsMessage.h @@ -1,22 +1,23 @@ #ifndef __REMOVEACTIONSMESSAGE__H__ #define __REMOVEACTIONSMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" class AMFArrayValue; +/** + * @brief Sent when a player removes any Action after the first one from a Strip + * + */ class RemoveActionsMessage : public BehaviorMessageBase { public: RemoveActionsMessage(AMFArrayValue* arguments); - const uint32_t GetBehaviorID() { return behaviorID; }; const uint32_t GetActionIndex() { return actionIndex; }; - const StripId GetStripID() { return stripID; }; - const BehaviorState GetStateID() { return stateID; }; + ActionContext GetActionContext() { return actionContext; }; private: - uint32_t behaviorID; + ActionContext actionContext; uint32_t actionIndex; - StripId stripID; - BehaviorState stateID; }; #endif //!__REMOVEACTIONSMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp index 3c48ed16..40288b07 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.cpp @@ -1,8 +1,7 @@ #include "RemoveStripMessage.h" -RemoveStripMessage::RemoveStripMessage(AMFArrayValue* arguments) { - stripId = GetStripIDFromArgument(arguments); - behaviorState = GetBehaviorStateFromArgument(arguments); - behaviorId = GetBehaviorIDFromArgument(arguments); - Game::logger->LogDebug("RemoveStripMessage", "stpId %i bhStt %i bhId %i", stripId, behaviorState, behaviorId); +RemoveStripMessage::RemoveStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + actionContext = ActionContext(arguments); + + Game::logger->LogDebug("RemoveStripMessage", "stripId %i stateId %i behaviorId %i", actionContext.GetStripId(), actionContext.GetStateId(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.h index 312bab31..36e2e401 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RemoveStripMessage.h @@ -1,18 +1,19 @@ #ifndef __REMOVESTRIPMESSAGE__H__ #define __REMOVESTRIPMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" +/** + * @brief Sent when a player removes the first Action from a strip. + * + */ class RemoveStripMessage : public BehaviorMessageBase { public: RemoveStripMessage(AMFArrayValue* arguments); - const StripId GetStripId() { return stripId; }; - const BehaviorState GetBehaviorState() { return behaviorState; }; - const uint32_t GetBehaviorId() { return behaviorId; }; + ActionContext GetActionContext() { return actionContext; }; private: - StripId stripId; - BehaviorState behaviorState; - uint32_t behaviorId; + ActionContext actionContext; }; #endif //!__REMOVESTRIPMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp index 38c49462..0ea3b6d6 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp @@ -1,11 +1,9 @@ #include "RenameMessage.h" -RenameMessage::RenameMessage(AMFArrayValue* arguments) { - behaviorID = GetBehaviorIDFromArgument(arguments); - +RenameMessage::RenameMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { auto* nameAmf = arguments->FindValue("Name"); if (!nameAmf) return; name = nameAmf->GetStringValue(); - Game::logger->LogDebug("RenameMessage", "bhId %i n %s", behaviorID, name.c_str()); + Game::logger->LogDebug("RenameMessage", "behaviorId %i n %s", behaviorId, name.c_str()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.h index be42d66f..ba181f63 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.h @@ -5,13 +5,15 @@ class AMFArrayValue; +/** + * @brief Sent when a player renames this behavior + * + */ class RenameMessage : public BehaviorMessageBase { public: RenameMessage(AMFArrayValue* arguments); - const uint32_t GetBehaviorID() { return behaviorID; }; const std::string& GetName() { return name; }; private: - uint32_t behaviorID; std::string name; }; diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp index d3493aeb..b4601a17 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.cpp @@ -1,29 +1,11 @@ #include "SplitStripMessage.h" -SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) { - auto* srcActionIndexValue = arguments->FindValue("srcActionIndex"); - if (!srcActionIndexValue) return; +SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + sourceActionContext = ActionContext(arguments, "srcStateID", "srcStripID"); + srcActionIndex = GetActionIndexFromArgument(arguments, "srcActionIndex"); - srcActionIndex = static_cast(srcActionIndexValue->GetDoubleValue()); + destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID"); + destinationPosition = StripUiPosition(arguments, "dstStripUI"); - srcStripId = GetStripIDFromArgument(arguments, "srcStripID"); - - srcStateId = GetBehaviorStateFromArgument(arguments, "srcStateID"); - - dstStripId = GetStripIDFromArgument(arguments, "dstStripID"); - - dstStateId = GetBehaviorStateFromArgument(arguments, "dstStateID"); - - auto* dstStripUiArray = arguments->FindValue("dstStripUI"); - if (!dstStripUiArray) return; - - auto* xPositionValue = dstStripUiArray->FindValue("x"); - auto* yPositionValue = dstStripUiArray->FindValue("y"); - if (!xPositionValue || !yPositionValue) return; - - yPosition = yPositionValue->GetDoubleValue(); - xPosition = xPositionValue->GetDoubleValue(); - - behaviorId = GetBehaviorIDFromArgument(arguments); - Game::logger->LogDebug("SplitStripMessage", "bhid %i x %f y %f srcStp %i dstStp %i srcStt %i dstStt %i srcActNdx %i", behaviorId, xPosition, yPosition, srcStripId, dstStripId, srcStateId, dstStateId, srcActionIndex); + Game::logger->LogDebug("SplitStripMessage", "behaviorId %i xPosition %f yPosition %f sourceStrip %i destinationStrip %i sourceState %i destinationState %i srcActindex %i", behaviorId, destinationPosition.GetX(), destinationPosition.GetY(), sourceActionContext.GetStripId(), destinationActionContext.GetStripId(), sourceActionContext.GetStateId(), destinationActionContext.GetStateId(), srcActionIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.h index e06a9dc4..9210efb0 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/SplitStripMessage.h @@ -1,30 +1,28 @@ #ifndef __SPLITSTRIPMESSAGE__H__ #define __SPLITSTRIPMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" +#include "StripUiPosition.h" class AMFArrayValue; +/** + * @brief Sent when a player takes an Action from Strip A and does not add it to an existing strip + * + */ class SplitStripMessage : public BehaviorMessageBase { public: SplitStripMessage(AMFArrayValue* arguments); + ActionContext GetSourceActionContext() { return sourceActionContext; }; + ActionContext GetDestinationActionContext() { return destinationActionContext; }; const uint32_t GetSrcActionIndex() { return srcActionIndex; }; - const StripId GetSrcStripId() { return srcStripId; }; - const BehaviorState GetSrcStateId() { return srcStateId; }; - const StripId GetDstStripId() { return dstStripId; }; - const BehaviorState GetDstStateId() { return dstStateId; }; - const double GetYPosition() { return yPosition; }; - const double GetXPosition() { return xPosition; }; - const uint32_t GetBehaviorId() { return behaviorId; }; + StripUiPosition GetPosition() { return destinationPosition; }; private: + ActionContext sourceActionContext; + ActionContext destinationActionContext; uint32_t srcActionIndex; - StripId srcStripId; - BehaviorState srcStateId; - StripId dstStripId; - BehaviorState dstStateId; - double yPosition; - double xPosition; - uint32_t behaviorId; + StripUiPosition destinationPosition; }; #endif //!__SPLITSTRIPMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp new file mode 100644 index 00000000..4ddccc55 --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp @@ -0,0 +1,22 @@ +#include "StripUiPosition.h" + +#include "AMFFormat.h" + +StripUiPosition::StripUiPosition() { + xPosition = 0.0; + yPosition = 0.0; +} + +StripUiPosition::StripUiPosition(AMFArrayValue* arguments, std::string uiKeyName) { + xPosition = 0.0; + yPosition = 0.0; + auto* uiArray = arguments->FindValue(uiKeyName); + if (!uiArray) return; + + auto* xPositionValue = uiArray->FindValue("x"); + auto* yPositionValue = uiArray->FindValue("y"); + if (!xPositionValue || !yPositionValue) return; + + yPosition = yPositionValue->GetDoubleValue(); + xPosition = xPositionValue->GetDoubleValue(); +} diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.h new file mode 100644 index 00000000..809f8890 --- /dev/null +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.h @@ -0,0 +1,21 @@ +#ifndef __STRIPUIPOSITION__H__ +#define __STRIPUIPOSITION__H__ + +class AMFArrayValue; + +/** + * @brief The position of the first Action in a Strip + * + */ +class StripUiPosition { +public: + StripUiPosition(); + StripUiPosition(AMFArrayValue* arguments, std::string uiKeyName = "ui"); + double GetX() { return xPosition; }; + double GetY() { return yPosition; }; +private: + double xPosition; + double yPosition; +}; + +#endif //!__STRIPUIPOSITION__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp index 1d4cc868..53e2d570 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp @@ -1,38 +1,15 @@ #include "UpdateActionMessage.h" -UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) { - type = ""; - valueParameterName = ""; - valueParameterString = ""; - valueParameterDouble = 0.0; - auto* actionAsArray = arguments->FindValue("action"); - if (!actionAsArray) return; - for (auto& typeValueMap : actionAsArray->GetAssociativeMap()) { - if (typeValueMap.first == "Type") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - type = static_cast(typeValueMap.second)->GetStringValue(); - } else { - valueParameterName = typeValueMap.first; - // Message is the only known string parameter - if (valueParameterName == "Message") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - valueParameterString = static_cast(typeValueMap.second)->GetStringValue(); - } else { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue; - valueParameterDouble = static_cast(typeValueMap.second)->GetDoubleValue(); - } - } - } +#include "Action.h" - behaviorID = GetBehaviorIDFromArgument(arguments); +UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + actionContext = ActionContext(arguments); - auto* actionIndexValue = arguments->FindValue("actionIndex"); - if (!actionIndexValue) return; + auto* actionValue = arguments->FindValue("action"); + if (!actionValue) return; - actionIndex = static_cast(actionIndexValue->GetDoubleValue()); + action = Action(actionValue); + actionIndex = GetActionIndexFromArgument(arguments); - stripID = GetStripIDFromArgument(arguments); - - stateID = GetBehaviorStateFromArgument(arguments); - Game::logger->LogDebug("UpdateActionMessage", "t %s vpn %s vps %s vpd %f bhId %i acnNdx %i stpId %i sttId %i", type.c_str(), valueParameterName.c_str(), valueParameterString.c_str(), valueParameterDouble, behaviorID, actionIndex, stripID, stateID); + Game::logger->LogDebug("UpdateActionMessage", "type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId, actionIndex, actionContext.GetStripId(), actionContext.GetStateId()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.h index a42be22b..0a03ce9e 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.h @@ -1,30 +1,26 @@ #ifndef __UPDATEACTIONMESSAGE__H__ #define __UPDATEACTIONMESSAGE__H__ +#include "Action.h" +#include "ActionContext.h" #include "BehaviorMessageBase.h" class AMFArrayValue; +/** + * @brief Sent when a player updates the value in an Action + * + */ class UpdateActionMessage : public BehaviorMessageBase { public: UpdateActionMessage(AMFArrayValue* arguments); - const std::string& GetType() { return type; }; - const std::string& GetValueParameterName() { return valueParameterName; }; - const std::string& GetValueParameterString() { return valueParameterString; }; - const double GetValueParameterDouble() { return valueParameterDouble; }; - const uint32_t GetBehaviorID() { return behaviorID; }; const uint32_t GetActionIndex() { return actionIndex; }; - const StripId GetStripID() { return stripID; }; - const BehaviorState GetStateID() { return stateID; }; + ActionContext GetActionContext() { return actionContext; }; + Action GetAction() { return action; }; private: - std::string type; - std::string valueParameterName; - std::string valueParameterString; - double valueParameterDouble; - uint32_t behaviorID; uint32_t actionIndex; - StripId stripID; - BehaviorState stateID; -}; + ActionContext actionContext; + Action action; +}; #endif //!__UPDATEACTIONMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp index 60e2f0f3..073db9b4 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.cpp @@ -1,20 +1,8 @@ #include "UpdateStripUiMessage.h" -UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) { - auto* uiArray = arguments->FindValue("ui"); - if (!uiArray) return; +UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { + position = StripUiPosition(arguments); + actionContext = ActionContext(arguments); - auto* xPositionValue = uiArray->FindValue("x"); - auto* yPositionValue = uiArray->FindValue("y"); - if (!xPositionValue || !yPositionValue) return; - - yPosition = yPositionValue->GetDoubleValue(); - xPosition = xPositionValue->GetDoubleValue(); - - stripID = GetStripIDFromArgument(arguments); - - stateID = GetBehaviorStateFromArgument(arguments); - - behaviorID = GetBehaviorIDFromArgument(arguments); - Game::logger->LogDebug("UpdateStripUIMessage", "x %f y %f stpId %i sttId %i bhId %i", xPosition, yPosition, stripID, stateID, behaviorID); + Game::logger->LogDebug("UpdateStripUIMessage", "xPosition %f yPosition %f stripId %i stateId %i behaviorId %i", position.GetX(), position.GetY(), actionContext.GetStripId(), actionContext.GetStateId(), behaviorId); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.h index ca626120..6d96f90c 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateStripUiMessage.h @@ -1,24 +1,24 @@ #ifndef __UPDATESTRIPUIMESSAGE__H__ #define __UPDATESTRIPUIMESSAGE__H__ +#include "ActionContext.h" #include "BehaviorMessageBase.h" +#include "StripUiPosition.h" class AMFArrayValue; +/** + * @brief Sent when a player moves the first Action in a Strip + * + */ class UpdateStripUiMessage : public BehaviorMessageBase { public: UpdateStripUiMessage(AMFArrayValue* arguments); - const double GetYPosition() { return yPosition; }; - const double GetXPosition() { return xPosition; }; - const StripId GetStripID() { return stripID; }; - const BehaviorState GetStateID() { return stateID; }; - const uint32_t GetBehaviorID() { return behaviorID; }; + StripUiPosition GetPosition() { return position; }; + ActionContext GetActionContext() { return actionContext; }; private: - double yPosition; - double xPosition; - StripId stripID; - BehaviorState stateID; - uint32_t behaviorID; + StripUiPosition position; + ActionContext actionContext; }; #endif //!__UPDATESTRIPUIMESSAGE__H__ diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index 3e8bbacc..dfb22b59 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -15,6 +15,7 @@ #include "CDClientDatabase.h" // Message includes +#include "Action.h" #include "AddActionMessage.h" #include "AddStripMessage.h" #include "AddMessage.h" @@ -248,18 +249,23 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent void ControlBehaviors::UpdateAction(AMFArrayValue* arguments) { UpdateActionMessage updateActionMessage(arguments); - auto* blockDefinition = GetBlockInfo(updateActionMessage.GetType()); + auto* blockDefinition = GetBlockInfo(updateActionMessage.GetAction().GetType()); - if (updateActionMessage.GetValueParameterString().size() > 0) { - if (updateActionMessage.GetValueParameterString().size() < blockDefinition->GetMinimumValue() || - updateActionMessage.GetValueParameterString().size() > blockDefinition->GetMaximumValue()) { - Game::logger->Log("ControlBehaviors", "Updated block %s is out of range. Ignoring update", updateActionMessage.GetType().c_str()); + if (!blockDefinition) { + Game::logger->Log("ControlBehaviors", "Received undefined block type %s. Ignoring.", updateActionMessage.GetAction().GetType().c_str()); + return; + } + + if (updateActionMessage.GetAction().GetValueParameterString().size() > 0) { + if (updateActionMessage.GetAction().GetValueParameterString().size() < blockDefinition->GetMinimumValue() || + updateActionMessage.GetAction().GetValueParameterString().size() > blockDefinition->GetMaximumValue()) { + Game::logger->Log("ControlBehaviors", "Updated block %s is out of range. Ignoring update", updateActionMessage.GetAction().GetType().c_str()); return; } } else { - if (updateActionMessage.GetValueParameterDouble() < blockDefinition->GetMinimumValue() || - updateActionMessage.GetValueParameterDouble() > blockDefinition->GetMaximumValue()) { - Game::logger->Log("ControlBehaviors", "Updated block %s is out of range. Ignoring update", updateActionMessage.GetType().c_str()); + if (updateActionMessage.GetAction().GetValueParameterDouble() < blockDefinition->GetMinimumValue() || + updateActionMessage.GetAction().GetValueParameterDouble() > blockDefinition->GetMaximumValue()) { + Game::logger->Log("ControlBehaviors", "Updated block %s is out of range. Ignoring update", updateActionMessage.GetAction().GetType().c_str()); return; } } @@ -452,5 +458,5 @@ ControlBehaviors::ControlBehaviors() { BlockDefinition* ControlBehaviors::GetBlockInfo(const BlockName& blockName) { auto blockDefinition = blockTypes.find(blockName); - return blockDefinition != blockTypes.end() ? blockDefinition->second : &BlockDefinition::blockDefinitionDefault; + return blockDefinition != blockTypes.end() ? blockDefinition->second : nullptr; } diff --git a/tests/dCommonTests/AMFDeserializeTests.cpp b/tests/dCommonTests/AMFDeserializeTests.cpp index a823b0dc..3811a706 100644 --- a/tests/dCommonTests/AMFDeserializeTests.cpp +++ b/tests/dCommonTests/AMFDeserializeTests.cpp @@ -258,9 +258,9 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) { ASSERT_EQ(actionIndex->GetDoubleValue(), 0.0f); - auto stripIDExecution = stripsPosition0->FindValue("id"); + auto stripIdExecution = stripsPosition0->FindValue("id"); - ASSERT_EQ(stripIDExecution->GetDoubleValue(), 0.0f); + ASSERT_EQ(stripIdExecution->GetDoubleValue(), 0.0f); auto stateIDExecution = executionState->FindValue("stateID"); @@ -298,9 +298,9 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) { ASSERT_EQ(xPos->GetDoubleValue(), 103.0f); ASSERT_EQ(yPos->GetDoubleValue(), 82.0f); - auto stripID = firstStrip->FindValue("id"); + auto stripId = firstStrip->FindValue("id"); - ASSERT_EQ(stripID->GetDoubleValue(), 0.0f); + ASSERT_EQ(stripId->GetDoubleValue(), 0.0f); auto firstAction = dynamic_cast(actionsInFirstStrip[0]); diff --git a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp index 7905c19a..631f0d2d 100644 --- a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp +++ b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp @@ -1,7 +1,12 @@ +#include "Action.h" +#include "AMFFormat.h" +#include "AMFDeserialize.h" #include "GameMessages.h" #include "GameDependencies.h" -#include "AMFDeserialize.h" +#include + +// Message includes #include "AddActionMessage.h" #include "AddStripMessage.h" #include "AddMessage.h" @@ -16,9 +21,6 @@ #include "UpdateActionMessage.h" #include "UpdateStripUiMessage.h" -#include -#include - class GameMessageTests: public GameDependenciesTest { protected: void SetUp() override { @@ -27,7 +29,6 @@ protected: void TearDown() override { TearDownDependencies(); } - std::string ReadFromFile(std::string filename) { std::ifstream file(filename, std::ios::binary); std::string readFile; @@ -35,10 +36,8 @@ protected: char readCharacter = file.get(); readFile.push_back(readCharacter); } - return readFile; } - AMFArrayValue* ReadArrayFromBitStream(RakNet::BitStream* inStream) { AMFDeserialize des; AMFValue* readArray = des.Read(inStream); @@ -90,23 +89,23 @@ TEST_F(GameMessageTests, ControlBehaviorAddStrip) { auto data = ReadFromFile("addStrip"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); AddStripMessage addStrip(ReadArrayFromBitStream(&inStream)); - ASSERT_FLOAT_EQ(addStrip.GetXPosition(), 50.65); - ASSERT_FLOAT_EQ(addStrip.GetYPosition(), 178.05); - ASSERT_EQ(addStrip.GetStripId(), 0); - ASSERT_EQ(static_cast(addStrip.GetStateId()), 0); + ASSERT_FLOAT_EQ(addStrip.GetPosition().GetX(), 50.65); + ASSERT_FLOAT_EQ(addStrip.GetPosition().GetY(), 178.05); + ASSERT_EQ(addStrip.GetActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(addStrip.GetActionContext().GetStateId()), 0); ASSERT_EQ(addStrip.GetBehaviorId(), -1); - ASSERT_EQ(addStrip.GetType(), "DropImagination"); - ASSERT_EQ(addStrip.GetValueParameterName(), "Amount"); - ASSERT_EQ(addStrip.GetValueParameterString(), ""); - ASSERT_FLOAT_EQ(addStrip.GetValueParameterDouble(), 1.0); + ASSERT_EQ(addStrip.GetActionsToAdd().front().GetType(), "DropImagination"); + ASSERT_EQ(addStrip.GetActionsToAdd().front().GetValueParameterName(), "Amount"); + ASSERT_EQ(addStrip.GetActionsToAdd().front().GetValueParameterString(), ""); + ASSERT_FLOAT_EQ(addStrip.GetActionsToAdd().front().GetValueParameterDouble(), 1.0); } TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) { auto data = ReadFromFile("removeStrip"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RemoveStripMessage removeStrip(ReadArrayFromBitStream(&inStream)); - ASSERT_EQ(static_cast(removeStrip.GetStripId()), 1); - ASSERT_EQ(static_cast(removeStrip.GetBehaviorState()), 0); + ASSERT_EQ(static_cast(removeStrip.GetActionContext().GetStripId()), 1); + ASSERT_EQ(static_cast(removeStrip.GetActionContext().GetStateId()), 0); ASSERT_EQ(removeStrip.GetBehaviorId(), -1); } @@ -114,12 +113,12 @@ TEST_F(GameMessageTests, ControlBehaviorMergeStrips) { auto data = ReadFromFile("mergeStrips"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); MergeStripsMessage mergeStrips(ReadArrayFromBitStream(&inStream)); - ASSERT_EQ(mergeStrips.GetSrcStripID(), 2); - ASSERT_EQ(mergeStrips.GetDstStripID(), 0); - ASSERT_EQ(static_cast(mergeStrips.GetSrcStateID()), 0); - ASSERT_EQ(static_cast(mergeStrips.GetDstStateID()), 0); + ASSERT_EQ(mergeStrips.GetSourceActionContext().GetStripId(), 2); + ASSERT_EQ(mergeStrips.GetDestinationActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(mergeStrips.GetSourceActionContext().GetStateId()), 0); + ASSERT_EQ(static_cast(mergeStrips.GetDestinationActionContext().GetStateId()), 0); ASSERT_EQ(mergeStrips.GetDstActionIndex(), 0); - ASSERT_EQ(mergeStrips.GetBehaviorID(), -1); + ASSERT_EQ(mergeStrips.GetBehaviorId(), -1); } TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { @@ -128,12 +127,12 @@ TEST_F(GameMessageTests, ControlBehaviorSplitStrip) { SplitStripMessage splitStrip(ReadArrayFromBitStream(&inStream)); ASSERT_EQ(splitStrip.GetBehaviorId(), -1); - ASSERT_FLOAT_EQ(splitStrip.GetXPosition(), 275.65); - ASSERT_FLOAT_EQ(splitStrip.GetYPosition(), 28.7); - ASSERT_EQ(splitStrip.GetSrcStripId(), 0); - ASSERT_EQ(splitStrip.GetDstStripId(), 2); - ASSERT_EQ(static_cast(splitStrip.GetSrcStateId()), 0); - ASSERT_EQ(static_cast(splitStrip.GetDstStateId()), 0); + ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetX(), 275.65); + ASSERT_FLOAT_EQ(splitStrip.GetPosition().GetY(), 28.7); + ASSERT_EQ(splitStrip.GetSourceActionContext().GetStripId(), 0); + ASSERT_EQ(splitStrip.GetDestinationActionContext().GetStripId(), 2); + ASSERT_EQ(static_cast(splitStrip.GetSourceActionContext().GetStateId()), 0); + ASSERT_EQ(static_cast(splitStrip.GetDestinationActionContext().GetStateId()), 0); ASSERT_EQ(splitStrip.GetSrcActionIndex(), 1); } @@ -141,11 +140,11 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) { auto data = ReadFromFile("updateStripUI"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); UpdateStripUiMessage updateStripUi(ReadArrayFromBitStream(&inStream)); - ASSERT_FLOAT_EQ(updateStripUi.GetXPosition(), 116.65); - ASSERT_FLOAT_EQ(updateStripUi.GetYPosition(), 35.35); - ASSERT_EQ(updateStripUi.GetStripID(), 0); - ASSERT_EQ(static_cast(updateStripUi.GetStateID()), 0); - ASSERT_EQ(updateStripUi.GetBehaviorID(), -1); + ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetX(), 116.65); + ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetY(), 35.35); + ASSERT_EQ(updateStripUi.GetActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(updateStripUi.GetActionContext().GetStateId()), 0); + ASSERT_EQ(updateStripUi.GetBehaviorId(), -1); } TEST_F(GameMessageTests, ControlBehaviorAddAction) { @@ -153,12 +152,12 @@ TEST_F(GameMessageTests, ControlBehaviorAddAction) { RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); AddActionMessage addAction(ReadArrayFromBitStream(&inStream)); ASSERT_EQ(addAction.GetActionIndex(), 3); - ASSERT_EQ(addAction.GetStripId(), 0); - ASSERT_EQ(static_cast(addAction.GetStateId()), 0); - ASSERT_EQ(addAction.GetType(), "DoDamage"); - ASSERT_EQ(addAction.GetValueParameterName(), ""); - ASSERT_EQ(addAction.GetValueParameterString(), ""); - ASSERT_EQ(addAction.GetValueParameterDouble(), 0.0); + ASSERT_EQ(addAction.GetActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(addAction.GetActionContext().GetStateId()), 0); + ASSERT_EQ(addAction.GetAction().GetType(), "DoDamage"); + ASSERT_EQ(addAction.GetAction().GetValueParameterName(), ""); + ASSERT_EQ(addAction.GetAction().GetValueParameterString(), ""); + ASSERT_EQ(addAction.GetAction().GetValueParameterDouble(), 0.0); ASSERT_EQ(addAction.GetBehaviorId(), -1); } @@ -168,11 +167,11 @@ TEST_F(GameMessageTests, ControlBehaviorMigrateActions) { MigrateActionsMessage migrateActions(ReadArrayFromBitStream(&inStream)); ASSERT_EQ(migrateActions.GetSrcActionIndex(), 1); ASSERT_EQ(migrateActions.GetDstActionIndex(), 2); - ASSERT_EQ(migrateActions.GetSrcStripID(), 1); - ASSERT_EQ(migrateActions.GetDstStripID(), 0); - ASSERT_EQ(static_cast(migrateActions.GetSrcStateID()), 0); - ASSERT_EQ(static_cast(migrateActions.GetDstStateID()), 0); - ASSERT_EQ(migrateActions.GetBehaviorID(), -1); + ASSERT_EQ(migrateActions.GetSourceActionContext().GetStripId(), 1); + ASSERT_EQ(migrateActions.GetDestinationActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(migrateActions.GetSourceActionContext().GetStateId()), 0); + ASSERT_EQ(static_cast(migrateActions.GetDestinationActionContext().GetStateId()), 0); + ASSERT_EQ(migrateActions.GetBehaviorId(), -1); } TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { @@ -181,9 +180,9 @@ TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) { RearrangeStripMessage rearrangeStrip(ReadArrayFromBitStream(&inStream)); ASSERT_EQ(rearrangeStrip.GetSrcActionIndex(), 2); ASSERT_EQ(rearrangeStrip.GetDstActionIndex(), 1); - ASSERT_EQ(rearrangeStrip.GetStripID(), 0); - ASSERT_EQ(rearrangeStrip.GetBehaviorID(), -1); - ASSERT_EQ(static_cast(rearrangeStrip.GetStateID()), 0); + ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0); + ASSERT_EQ(rearrangeStrip.GetBehaviorId(), -1); + ASSERT_EQ(static_cast(rearrangeStrip.GetActionContext().GetStateId()), 0); } TEST_F(GameMessageTests, ControlBehaviorAdd) { @@ -198,10 +197,10 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveActions) { auto data = ReadFromFile("removeActions"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RemoveActionsMessage removeActions(ReadArrayFromBitStream(&inStream)); - ASSERT_EQ(removeActions.GetBehaviorID(), -1); + ASSERT_EQ(removeActions.GetBehaviorId(), -1); ASSERT_EQ(removeActions.GetActionIndex(), 1); - ASSERT_EQ(removeActions.GetStripID(), 0); - ASSERT_EQ(static_cast(removeActions.GetStateID()), 0); + ASSERT_EQ(removeActions.GetActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(removeActions.GetActionContext().GetStateId()), 0); } TEST_F(GameMessageTests, ControlBehaviorRename) { @@ -209,19 +208,19 @@ TEST_F(GameMessageTests, ControlBehaviorRename) { RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); RenameMessage rename(ReadArrayFromBitStream(&inStream)); ASSERT_EQ(rename.GetName(), "test"); - ASSERT_EQ(rename.GetBehaviorID(), -1); + ASSERT_EQ(rename.GetBehaviorId(), -1); } TEST_F(GameMessageTests, ControlBehaviorUpdateAction) { auto data = ReadFromFile("updateAction"); RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true); UpdateActionMessage updateAction(ReadArrayFromBitStream(&inStream)); - ASSERT_EQ(updateAction.GetType(), "FlyDown"); - ASSERT_EQ(updateAction.GetValueParameterName(), "Distance"); - ASSERT_EQ(updateAction.GetValueParameterString(), ""); - ASSERT_EQ(updateAction.GetValueParameterDouble(), 50.0); - ASSERT_EQ(updateAction.GetBehaviorID(), -1); + ASSERT_EQ(updateAction.GetAction().GetType(), "FlyDown"); + ASSERT_EQ(updateAction.GetAction().GetValueParameterName(), "Distance"); + ASSERT_EQ(updateAction.GetAction().GetValueParameterString(), ""); + ASSERT_EQ(updateAction.GetAction().GetValueParameterDouble(), 50.0); + ASSERT_EQ(updateAction.GetBehaviorId(), -1); ASSERT_EQ(updateAction.GetActionIndex(), 1); - ASSERT_EQ(updateAction.GetStripID(), 0); - ASSERT_EQ(static_cast(updateAction.GetStateID()), 0); + ASSERT_EQ(updateAction.GetActionContext().GetStripId(), 0); + ASSERT_EQ(static_cast(updateAction.GetActionContext().GetStateId()), 0); }