mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-07-02 01:29:51 +00:00
pass model component to update
This commit is contained in:
parent
56ec037eb6
commit
ff1523b43f
@ -69,7 +69,7 @@ void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialU
|
|||||||
|
|
||||||
void ModelComponent::Update(float deltaTime) {
|
void ModelComponent::Update(float deltaTime) {
|
||||||
if (!m_Running) return;
|
if (!m_Running) return;
|
||||||
for (auto& behavior : m_Behaviors) behavior.Update(deltaTime);
|
for (auto& behavior : m_Behaviors) behavior.Update(deltaTime, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) {
|
void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) {
|
||||||
|
@ -22,7 +22,7 @@ Action::Action(const AMFArrayValue& arguments) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::Update(float deltaTime) {
|
void Action::Update(float deltaTime, const ModelComponent& modelComponent) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ namespace tinyxml2 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class AMFArrayValue;
|
class AMFArrayValue;
|
||||||
|
class ModelComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sent if a ControlBehavior message has an Action associated with it
|
* @brief Sent if a ControlBehavior message has an Action associated with it
|
||||||
@ -18,7 +19,7 @@ public:
|
|||||||
Action() = default;
|
Action() = default;
|
||||||
Action(const AMFArrayValue& arguments);
|
Action(const AMFArrayValue& arguments);
|
||||||
|
|
||||||
void Update(float deltaTime);
|
void Update(float deltaTime, const ModelComponent& modelComponent);
|
||||||
|
|
||||||
bool Done() const noexcept;
|
bool Done() const noexcept;
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ PropertyBehavior::PropertyBehavior() {
|
|||||||
m_LastEditedState = BehaviorState::HOME_STATE;
|
m_LastEditedState = BehaviorState::HOME_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyBehavior::Update(float deltaTime) {
|
void PropertyBehavior::Update(float deltaTime, const ModelComponent& modelComponent) {
|
||||||
for (auto& [stateId, state] : m_States) {
|
for (auto& [stateId, state] : m_States) {
|
||||||
state.Update(deltaTime);
|
state.Update(deltaTime, modelComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ namespace tinyxml2 {
|
|||||||
enum class BehaviorState : uint32_t;
|
enum class BehaviorState : uint32_t;
|
||||||
|
|
||||||
class AMFArrayValue;
|
class AMFArrayValue;
|
||||||
|
class ModelComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the Entity of a Property Behavior and holds data associated with the behavior
|
* Represents the Entity of a Property Behavior and holds data associated with the behavior
|
||||||
@ -18,7 +19,7 @@ class PropertyBehavior {
|
|||||||
public:
|
public:
|
||||||
PropertyBehavior();
|
PropertyBehavior();
|
||||||
|
|
||||||
void Update(float deltaTime);
|
void Update(float deltaTime, const ModelComponent& modelComponent);
|
||||||
|
|
||||||
template <typename Msg>
|
template <typename Msg>
|
||||||
void HandleMsg(Msg& msg);
|
void HandleMsg(Msg& msg);
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include "ControlBehaviorMsgs.h"
|
#include "ControlBehaviorMsgs.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
void State::Update(float deltaTime) {
|
void State::Update(float deltaTime, const ModelComponent& modelComponent) {
|
||||||
for (auto& strip : m_Strips) {
|
for (auto& strip : m_Strips) {
|
||||||
strip.Update(deltaTime);
|
strip.Update(deltaTime, modelComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ void State::HandleMsg(AddStripMessage& msg) {
|
|||||||
m_Strips.resize(msg.GetActionContext().GetStripId() + 1);
|
m_Strips.resize(msg.GetActionContext().GetStripId() + 1);
|
||||||
}
|
}
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(AddActionMessage& msg) {
|
void State::HandleMsg(AddActionMessage& msg) {
|
||||||
@ -25,7 +25,7 @@ void State::HandleMsg(AddActionMessage& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(UpdateStripUiMessage& msg) {
|
void State::HandleMsg(UpdateStripUiMessage& msg) {
|
||||||
@ -34,7 +34,7 @@ void State::HandleMsg(UpdateStripUiMessage& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(RemoveActionsMessage& msg) {
|
void State::HandleMsg(RemoveActionsMessage& msg) {
|
||||||
@ -43,7 +43,7 @@ void State::HandleMsg(RemoveActionsMessage& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(RearrangeStripMessage& msg) {
|
void State::HandleMsg(RearrangeStripMessage& msg) {
|
||||||
@ -52,7 +52,7 @@ void State::HandleMsg(RearrangeStripMessage& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(UpdateActionMessage& msg) {
|
void State::HandleMsg(UpdateActionMessage& msg) {
|
||||||
@ -61,7 +61,7 @@ void State::HandleMsg(UpdateActionMessage& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(RemoveStripMessage& msg) {
|
void State::HandleMsg(RemoveStripMessage& msg) {
|
||||||
@ -70,7 +70,7 @@ void State::HandleMsg(RemoveStripMessage& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetActionContext().GetStripId()).HandleMsg(msg);
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(SplitStripMessage& msg) {
|
void State::HandleMsg(SplitStripMessage& msg) {
|
||||||
@ -87,7 +87,7 @@ void State::HandleMsg(SplitStripMessage& msg) {
|
|||||||
|
|
||||||
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(MergeStripsMessage& msg) {
|
void State::HandleMsg(MergeStripsMessage& msg) {
|
||||||
@ -104,7 +104,7 @@ void State::HandleMsg(MergeStripsMessage& msg) {
|
|||||||
|
|
||||||
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(MigrateActionsMessage& msg) {
|
void State::HandleMsg(MigrateActionsMessage& msg) {
|
||||||
@ -121,7 +121,7 @@ void State::HandleMsg(MigrateActionsMessage& msg) {
|
|||||||
|
|
||||||
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
m_Strips.at(msg.GetDestinationActionContext().GetStripId()).HandleMsg(msg);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
bool State::IsEmpty() const {
|
bool State::IsEmpty() const {
|
||||||
for (const auto& strip : m_Strips) {
|
for (const auto& strip : m_Strips) {
|
||||||
|
@ -8,10 +8,11 @@ namespace tinyxml2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AMFArrayValue;
|
class AMFArrayValue;
|
||||||
|
class ModelComponent;
|
||||||
|
|
||||||
class State {
|
class State {
|
||||||
public:
|
public:
|
||||||
void Update(float deltaTime);
|
void Update(float deltaTime, const ModelComponent& modelComponent);
|
||||||
|
|
||||||
template <typename Msg>
|
template <typename Msg>
|
||||||
void HandleMsg(Msg& msg);
|
void HandleMsg(Msg& msg);
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
#include "ControlBehaviorMsgs.h"
|
#include "ControlBehaviorMsgs.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
void Strip::Update(float deltaTime) {
|
void Strip::Update(float deltaTime, const ModelComponent& modelComponent) {
|
||||||
if (m_Actions.empty() || m_ActionIndex >= m_Actions.size()) return;
|
if (m_Actions.empty() || m_ActionIndex >= m_Actions.size()) return;
|
||||||
|
|
||||||
auto& action = m_Actions[m_ActionIndex];
|
auto& action = m_Actions[m_ActionIndex];
|
||||||
action.Update(deltaTime);
|
action.Update(deltaTime, modelComponent);
|
||||||
LOG("Running action %s", action.GetType().c_str());
|
LOG("Running action %s", action.GetType().c_str());
|
||||||
if (action.Done()) m_ActionIndex++;
|
if (action.Done()) m_ActionIndex++;
|
||||||
}
|
}
|
||||||
@ -17,41 +17,41 @@ template <>
|
|||||||
void Strip::HandleMsg(AddStripMessage& msg) {
|
void Strip::HandleMsg(AddStripMessage& msg) {
|
||||||
m_Actions = msg.GetActionsToAdd();
|
m_Actions = msg.GetActionsToAdd();
|
||||||
m_Position = msg.GetPosition();
|
m_Position = msg.GetPosition();
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(AddActionMessage& msg) {
|
void Strip::HandleMsg(AddActionMessage& msg) {
|
||||||
if (msg.GetActionIndex() == -1) return;
|
if (msg.GetActionIndex() == -1) return;
|
||||||
m_Actions.insert(m_Actions.begin() + msg.GetActionIndex(), msg.GetAction());
|
auto newAction = m_Actions.insert(m_Actions.begin() + msg.GetActionIndex(), msg.GetAction());
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(UpdateStripUiMessage& msg) {
|
void Strip::HandleMsg(UpdateStripUiMessage& msg) {
|
||||||
m_Position = msg.GetPosition();
|
m_Position = msg.GetPosition();
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(RemoveStripMessage& msg) {
|
void Strip::HandleMsg(RemoveStripMessage& msg) {
|
||||||
m_Actions.clear();
|
m_Actions.clear();
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(RemoveActionsMessage& msg) {
|
void Strip::HandleMsg(RemoveActionsMessage& msg) {
|
||||||
if (msg.GetActionIndex() >= m_Actions.size()) return;
|
if (msg.GetActionIndex() >= m_Actions.size()) return;
|
||||||
m_Actions.erase(m_Actions.begin() + msg.GetActionIndex(), m_Actions.end());
|
m_Actions.erase(m_Actions.begin() + msg.GetActionIndex(), m_Actions.end());
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(UpdateActionMessage& msg) {
|
void Strip::HandleMsg(UpdateActionMessage& msg) {
|
||||||
if (msg.GetActionIndex() >= m_Actions.size()) return;
|
if (msg.GetActionIndex() >= m_Actions.size()) return;
|
||||||
m_Actions.at(msg.GetActionIndex()) = msg.GetAction();
|
m_Actions.at(msg.GetActionIndex()) = msg.GetAction();
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(RearrangeStripMessage& msg) {
|
void Strip::HandleMsg(RearrangeStripMessage& msg) {
|
||||||
if (msg.GetDstActionIndex() >= m_Actions.size() || msg.GetSrcActionIndex() >= m_Actions.size() || msg.GetSrcActionIndex() <= msg.GetDstActionIndex()) return;
|
if (msg.GetDstActionIndex() >= m_Actions.size() || msg.GetSrcActionIndex() >= m_Actions.size() || msg.GetSrcActionIndex() <= msg.GetDstActionIndex()) return;
|
||||||
std::rotate(m_Actions.begin() + msg.GetDstActionIndex(), m_Actions.begin() + msg.GetSrcActionIndex(), m_Actions.end());
|
std::rotate(m_Actions.begin() + msg.GetDstActionIndex(), m_Actions.begin() + msg.GetSrcActionIndex(), m_Actions.end());
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(SplitStripMessage& msg) {
|
void Strip::HandleMsg(SplitStripMessage& msg) {
|
||||||
@ -63,7 +63,7 @@ void Strip::HandleMsg(SplitStripMessage& msg) {
|
|||||||
m_Actions = msg.GetTransferredActions();
|
m_Actions = msg.GetTransferredActions();
|
||||||
m_Position = msg.GetPosition();
|
m_Position = msg.GetPosition();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(MergeStripsMessage& msg) {
|
void Strip::HandleMsg(MergeStripsMessage& msg) {
|
||||||
@ -73,7 +73,7 @@ void Strip::HandleMsg(MergeStripsMessage& msg) {
|
|||||||
} else {
|
} else {
|
||||||
m_Actions.insert(m_Actions.begin() + msg.GetDstActionIndex(), msg.GetMigratedActions().begin(), msg.GetMigratedActions().end());
|
m_Actions.insert(m_Actions.begin() + msg.GetDstActionIndex(), msg.GetMigratedActions().begin(), msg.GetMigratedActions().end());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(MigrateActionsMessage& msg) {
|
void Strip::HandleMsg(MigrateActionsMessage& msg) {
|
||||||
@ -84,7 +84,7 @@ void Strip::HandleMsg(MigrateActionsMessage& msg) {
|
|||||||
} else {
|
} else {
|
||||||
m_Actions.insert(m_Actions.begin() + msg.GetDstActionIndex(), msg.GetMigratedActions().begin(), msg.GetMigratedActions().end());
|
m_Actions.insert(m_Actions.begin() + msg.GetDstActionIndex(), msg.GetMigratedActions().begin(), msg.GetMigratedActions().end());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void Strip::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
void Strip::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
||||||
m_Position.SendBehaviorBlocksToClient(args);
|
m_Position.SendBehaviorBlocksToClient(args);
|
||||||
|
@ -11,10 +11,11 @@ namespace tinyxml2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AMFArrayValue;
|
class AMFArrayValue;
|
||||||
|
class ModelComponent;
|
||||||
|
|
||||||
class Strip {
|
class Strip {
|
||||||
public:
|
public:
|
||||||
void Update(float deltaTime);
|
void Update(float deltaTime, const ModelComponent& modelComponent);
|
||||||
|
|
||||||
template <typename Msg>
|
template <typename Msg>
|
||||||
void HandleMsg(Msg& msg);
|
void HandleMsg(Msg& msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user