mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
Make ControlBehavior messages far more modular (#991)
* Make case consistent * How modular can you go? Holy modular * Add comments * Initialize values
This commit is contained in:
parent
484488e47d
commit
d138b7b878
31
dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp
Normal file
31
dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp
Normal file
@ -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<AMFStringValue*>(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<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
} else {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(typeValueMap.second)->GetDoubleValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.h
Normal file
25
dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.h
Normal file
@ -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__
|
@ -0,0 +1,31 @@
|
||||
#include "ActionContext.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#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<AMFDoubleValue>(key);
|
||||
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
|
||||
|
||||
return static_cast<BehaviorState>(stateIDValue->GetDoubleValue());
|
||||
}
|
||||
|
||||
StripId ActionContext::GetStripIdFromArgument(AMFArrayValue* arguments, const std::string& key) {
|
||||
auto* stripIdValue = arguments->FindValue<AMFDoubleValue>(key);
|
||||
if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
|
||||
|
||||
return static_cast<StripId>(stripIdValue->GetDoubleValue());
|
||||
}
|
@ -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__
|
@ -1,39 +1,13 @@
|
||||
#include "AddActionMessage.h"
|
||||
|
||||
AddActionMessage::AddActionMessage(AMFArrayValue* arguments) {
|
||||
auto* actionIndexAmf = arguments->FindValue<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexAmf) return;
|
||||
AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
actionContext = ActionContext(arguments);
|
||||
actionIndex = GetActionIndexFromArgument(arguments);
|
||||
|
||||
actionIndex = static_cast<uint32_t>(actionIndexAmf->GetDoubleValue());
|
||||
auto* actionValue = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
stripId = GetStripIDFromArgument(arguments);
|
||||
action = Action(actionValue);
|
||||
|
||||
stateId = GetBehaviorStateFromArgument(arguments);
|
||||
|
||||
type = "";
|
||||
valueParameterName = "";
|
||||
valueParameterString = "";
|
||||
valueParameterDouble = 0.0;
|
||||
auto* action = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!action) return;
|
||||
|
||||
for (auto& typeValueMap : action->GetAssociativeMap()) {
|
||||
if (typeValueMap.first == "Type") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
type = static_cast<AMFStringValue*>(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<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
} else {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(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);
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -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<AMFDoubleValue>("BehaviorIndex");
|
||||
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetDoubleValue());
|
||||
Game::logger->LogDebug("AddMessage", "bhId %i ndx %i", behaviorId, behaviorIndex);
|
||||
Game::logger->LogDebug("AddMessage", "behaviorId %i index %i", behaviorId, behaviorIndex);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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<AMFArrayValue>("strip");
|
||||
if (!strip) return;
|
||||
|
||||
auto* actions = strip->FindValue<AMFArrayValue>("actions");
|
||||
if (!actions) return;
|
||||
|
||||
auto* uiArray = arguments->FindValue<AMFArrayValue>("ui");
|
||||
if (!uiArray) return;
|
||||
for (uint32_t actionNumber = 0; actionNumber < actions->GetDenseValueSize(); actionNumber++) {
|
||||
auto* actionValue = actions->GetValueAt<AMFArrayValue>(actionNumber);
|
||||
if (!actionValue) continue;
|
||||
|
||||
auto* xPositionValue = uiArray->FindValue<AMFDoubleValue>("x");
|
||||
if (!xPositionValue) return;
|
||||
actionsToAdd.push_back(Action(actionValue));
|
||||
|
||||
xPosition = xPositionValue->GetDoubleValue();
|
||||
|
||||
auto* yPositionValue = uiArray->FindValue<AMFDoubleValue>("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<AMFArrayValue>(position);
|
||||
if (!actionAsArray) continue;
|
||||
|
||||
for (auto& typeValueMap : actionAsArray->GetAssociativeMap()) {
|
||||
if (typeValueMap.first == "Type") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
|
||||
type = static_cast<AMFStringValue*>(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<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
} else {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(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());
|
||||
}
|
||||
|
@ -1,32 +1,31 @@
|
||||
#ifndef __ADDSTRIPMESSAGE__H__
|
||||
#define __ADDSTRIPMESSAGE__H__
|
||||
|
||||
#include "ActionContext.h"
|
||||
#include "BehaviorMessageBase.h"
|
||||
#include "StripUiPosition.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
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<Action> 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<Action> actionsToAdd;
|
||||
};
|
||||
|
||||
#endif //!__ADDSTRIPMESSAGE__H__
|
||||
|
@ -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<AMFStringValue>(key);
|
||||
int32_t behaviorID = -1;
|
||||
|
||||
if (behaviorIDValue) {
|
||||
behaviorID = std::stoul(behaviorIDValue->GetStringValue());
|
||||
} else if (!arguments->FindValue<AMFUndefinedValue>(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<AMFDoubleValue>(keyName);
|
||||
if (!actionIndexAmf) {
|
||||
throw std::invalid_argument("Unable to find actionIndex");
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>(actionIndexAmf->GetDoubleValue());
|
||||
}
|
@ -5,44 +5,25 @@
|
||||
#include <string>
|
||||
|
||||
#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<AMFStringValue>(key);
|
||||
uint32_t behaviorID = -1;
|
||||
|
||||
if (behaviorIDValue) {
|
||||
behaviorID = std::stoul(behaviorIDValue->GetStringValue());
|
||||
} else if (arguments->FindValue<AMFUndefinedValue>(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<AMFDoubleValue>(key);
|
||||
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
|
||||
|
||||
BehaviorState stateID = static_cast<BehaviorState>(stateIDValue->GetDoubleValue());
|
||||
|
||||
return stateID;
|
||||
}
|
||||
|
||||
StripId GetStripIDFromArgument(AMFArrayValue* arguments, const std::string& key = "stripID") {
|
||||
auto* stripIDValue = arguments->FindValue<AMFDoubleValue>(key);
|
||||
if (!stripIDValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
|
||||
|
||||
StripId stripID = static_cast<StripId>(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__
|
||||
|
@ -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
|
||||
|
@ -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<AMFDoubleValue>("dstActionIndex");
|
||||
if (!dstActionIndexValue) return;
|
||||
|
||||
dstActionIndex = static_cast<uint32_t>(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);
|
||||
}
|
||||
|
||||
|
@ -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__
|
||||
|
@ -1,24 +1,11 @@
|
||||
#include "MigrateActionsMessage.h"
|
||||
|
||||
MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) {
|
||||
auto* srcActionIndexAmf = arguments->FindValue<AMFDoubleValue>("srcActionIndex");
|
||||
if (!srcActionIndexAmf) return;
|
||||
MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
sourceActionContext = ActionContext(arguments, "srcStateID", "srcStripID");
|
||||
srcActionIndex = GetActionIndexFromArgument(arguments, "srcActionIndex");
|
||||
|
||||
srcActionIndex = static_cast<uint32_t>(srcActionIndexAmf->GetDoubleValue());
|
||||
destinationActionContext = ActionContext(arguments, "dstStateID", "dstStripID");
|
||||
dstActionIndex = GetActionIndexFromArgument(arguments, "dstActionIndex");
|
||||
|
||||
srcStripID = GetStripIDFromArgument(arguments, "srcStripID");
|
||||
|
||||
srcStateID = GetBehaviorStateFromArgument(arguments, "srcStateID");
|
||||
|
||||
auto* dstActionIndexAmf = arguments->FindValue<AMFDoubleValue>("dstActionIndex");
|
||||
if (!dstActionIndexAmf) return;
|
||||
|
||||
dstActionIndex = static_cast<uint32_t>(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);
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "MoveToInventoryMessage.h"
|
||||
|
||||
MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) {
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
auto* behaviorIndexValue = arguments->FindValue<AMFDoubleValue>("BehaviorIndex");
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetDoubleValue());
|
||||
Game::logger->LogDebug("MoveToInventoryMessage", "bhId %i bhNdx %i", behaviorID, behaviorIndex);
|
||||
Game::logger->LogDebug("MoveToInventoryMessage", "behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -1,16 +1,10 @@
|
||||
#include "RearrangeStripMessage.h"
|
||||
|
||||
RearrangeStripMessage::RearrangeStripMessage(AMFArrayValue* arguments) {
|
||||
auto* srcActionIndexValue = arguments->FindValue<AMFDoubleValue>("srcActionIndex");
|
||||
srcActionIndex = static_cast<uint32_t>(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<AMFDoubleValue>("dstActionIndex");
|
||||
dstActionIndex = static_cast<uint32_t>(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());
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -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<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexAmf) return;
|
||||
|
||||
actionIndex = static_cast<uint32_t>(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());
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "RenameMessage.h"
|
||||
|
||||
RenameMessage::RenameMessage(AMFArrayValue* arguments) {
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
RenameMessage::RenameMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
auto* nameAmf = arguments->FindValue<AMFStringValue>("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());
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -1,29 +1,11 @@
|
||||
#include "SplitStripMessage.h"
|
||||
|
||||
SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) {
|
||||
auto* srcActionIndexValue = arguments->FindValue<AMFDoubleValue>("srcActionIndex");
|
||||
if (!srcActionIndexValue) return;
|
||||
SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
sourceActionContext = ActionContext(arguments, "srcStateID", "srcStripID");
|
||||
srcActionIndex = GetActionIndexFromArgument(arguments, "srcActionIndex");
|
||||
|
||||
srcActionIndex = static_cast<uint32_t>(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<AMFArrayValue>("dstStripUI");
|
||||
if (!dstStripUiArray) return;
|
||||
|
||||
auto* xPositionValue = dstStripUiArray->FindValue<AMFDoubleValue>("x");
|
||||
auto* yPositionValue = dstStripUiArray->FindValue<AMFDoubleValue>("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);
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -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<AMFArrayValue>(uiKeyName);
|
||||
if (!uiArray) return;
|
||||
|
||||
auto* xPositionValue = uiArray->FindValue<AMFDoubleValue>("x");
|
||||
auto* yPositionValue = uiArray->FindValue<AMFDoubleValue>("y");
|
||||
if (!xPositionValue || !yPositionValue) return;
|
||||
|
||||
yPosition = yPositionValue->GetDoubleValue();
|
||||
xPosition = xPositionValue->GetDoubleValue();
|
||||
}
|
@ -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__
|
@ -1,38 +1,15 @@
|
||||
#include "UpdateActionMessage.h"
|
||||
|
||||
UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) {
|
||||
type = "";
|
||||
valueParameterName = "";
|
||||
valueParameterString = "";
|
||||
valueParameterDouble = 0.0;
|
||||
auto* actionAsArray = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!actionAsArray) return;
|
||||
for (auto& typeValueMap : actionAsArray->GetAssociativeMap()) {
|
||||
if (typeValueMap.first == "Type") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
type = static_cast<AMFStringValue*>(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<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
} else {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(typeValueMap.second)->GetDoubleValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "Action.h"
|
||||
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
actionContext = ActionContext(arguments);
|
||||
|
||||
auto* actionIndexValue = arguments->FindValue<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexValue) return;
|
||||
auto* actionValue = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
actionIndex = static_cast<uint32_t>(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());
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -1,20 +1,8 @@
|
||||
#include "UpdateStripUiMessage.h"
|
||||
|
||||
UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) {
|
||||
auto* uiArray = arguments->FindValue<AMFArrayValue>("ui");
|
||||
if (!uiArray) return;
|
||||
UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
position = StripUiPosition(arguments);
|
||||
actionContext = ActionContext(arguments);
|
||||
|
||||
auto* xPositionValue = uiArray->FindValue<AMFDoubleValue>("x");
|
||||
auto* yPositionValue = uiArray->FindValue<AMFDoubleValue>("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);
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(actionIndex->GetDoubleValue(), 0.0f);
|
||||
|
||||
auto stripIDExecution = stripsPosition0->FindValue<AMFDoubleValue>("id");
|
||||
auto stripIdExecution = stripsPosition0->FindValue<AMFDoubleValue>("id");
|
||||
|
||||
ASSERT_EQ(stripIDExecution->GetDoubleValue(), 0.0f);
|
||||
ASSERT_EQ(stripIdExecution->GetDoubleValue(), 0.0f);
|
||||
|
||||
auto stateIDExecution = executionState->FindValue<AMFDoubleValue>("stateID");
|
||||
|
||||
@ -298,9 +298,9 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
ASSERT_EQ(xPos->GetDoubleValue(), 103.0f);
|
||||
ASSERT_EQ(yPos->GetDoubleValue(), 82.0f);
|
||||
|
||||
auto stripID = firstStrip->FindValue<AMFDoubleValue>("id");
|
||||
auto stripId = firstStrip->FindValue<AMFDoubleValue>("id");
|
||||
|
||||
ASSERT_EQ(stripID->GetDoubleValue(), 0.0f);
|
||||
ASSERT_EQ(stripId->GetDoubleValue(), 0.0f);
|
||||
|
||||
auto firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0]);
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
#include "Action.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "AMFDeserialize.h"
|
||||
#include "GameMessages.h"
|
||||
#include "GameDependencies.h"
|
||||
#include "AMFDeserialize.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// Message includes
|
||||
#include "AddActionMessage.h"
|
||||
#include "AddStripMessage.h"
|
||||
#include "AddMessage.h"
|
||||
@ -16,9 +21,6 @@
|
||||
#include "UpdateActionMessage.h"
|
||||
#include "UpdateStripUiMessage.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <fstream>
|
||||
|
||||
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<uint32_t>(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<uint32_t>(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<int32_t>(removeStrip.GetStripId()), 1);
|
||||
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetBehaviorState()), 0);
|
||||
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStripId()), 1);
|
||||
ASSERT_EQ(static_cast<int32_t>(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<uint32_t>(mergeStrips.GetSrcStateID()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(mergeStrips.GetDstStateID()), 0);
|
||||
ASSERT_EQ(mergeStrips.GetSourceActionContext().GetStripId(), 2);
|
||||
ASSERT_EQ(mergeStrips.GetDestinationActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(mergeStrips.GetSourceActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(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<uint32_t>(splitStrip.GetSrcStateId()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(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<uint32_t>(splitStrip.GetSourceActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(migrateActions.GetSrcStateID()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(migrateActions.GetDstStateID()), 0);
|
||||
ASSERT_EQ(migrateActions.GetBehaviorID(), -1);
|
||||
ASSERT_EQ(migrateActions.GetSourceActionContext().GetStripId(), 1);
|
||||
ASSERT_EQ(migrateActions.GetDestinationActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(migrateActions.GetSourceActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(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<uint32_t>(rearrangeStrip.GetStateID()), 0);
|
||||
ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(rearrangeStrip.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(static_cast<uint32_t>(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<uint32_t>(removeActions.GetStateID()), 0);
|
||||
ASSERT_EQ(removeActions.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(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<uint32_t>(updateAction.GetStateID()), 0);
|
||||
ASSERT_EQ(updateAction.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(updateAction.GetActionContext().GetStateId()), 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user