mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
ad a bunch of update methods
This commit is contained in:
parent
af943278fb
commit
06897eb2ae
@ -66,6 +66,10 @@ void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialU
|
|||||||
if (bIsInitialUpdate) outBitStream.Write0(); // We are not writing model editing info
|
if (bIsInitialUpdate) outBitStream.Write0(); // We are not writing model editing info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelComponent::Update(float deltaTime) {
|
||||||
|
for (auto& behavior : m_Behaviors) behavior.Update(deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) {
|
void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) {
|
||||||
for (auto& behavior : m_Behaviors) if (behavior.GetBehaviorId() == -1) behavior.SetBehaviorId(newId);
|
for (auto& behavior : m_Behaviors) if (behavior.GetBehaviorId() == -1) behavior.SetBehaviorId(newId);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ public:
|
|||||||
|
|
||||||
ModelComponent(Entity* parent);
|
ModelComponent(Entity* parent);
|
||||||
|
|
||||||
|
void Update(float deltaTime) override;
|
||||||
|
|
||||||
void LoadBehaviors();
|
void LoadBehaviors();
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
@ -22,6 +22,14 @@ Action::Action(const AMFArrayValue& arguments) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Action::Update(float deltaTime) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Action::Done() const noexcept {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Action::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
void Action::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
||||||
auto* const actionArgs = args.PushArray();
|
auto* const actionArgs = args.PushArray();
|
||||||
actionArgs->Insert("Type", m_Type);
|
actionArgs->Insert("Type", m_Type);
|
||||||
|
@ -17,6 +17,11 @@ class Action {
|
|||||||
public:
|
public:
|
||||||
Action() = default;
|
Action() = default;
|
||||||
Action(const AMFArrayValue& arguments);
|
Action(const AMFArrayValue& arguments);
|
||||||
|
|
||||||
|
void Update(float deltaTime);
|
||||||
|
|
||||||
|
bool Done() const noexcept;
|
||||||
|
|
||||||
[[nodiscard]] const std::string& GetType() const { return m_Type; };
|
[[nodiscard]] const std::string& GetType() const { return m_Type; };
|
||||||
[[nodiscard]] const std::string& GetValueParameterName() const { return m_ValueParameterName; };
|
[[nodiscard]] const std::string& GetValueParameterName() const { return m_ValueParameterName; };
|
||||||
[[nodiscard]] const std::string& GetValueParameterString() const { return m_ValueParameterString; };
|
[[nodiscard]] const std::string& GetValueParameterString() const { return m_ValueParameterString; };
|
||||||
|
@ -9,6 +9,12 @@ PropertyBehavior::PropertyBehavior() {
|
|||||||
m_LastEditedState = BehaviorState::HOME_STATE;
|
m_LastEditedState = BehaviorState::HOME_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyBehavior::Update(float deltaTime) {
|
||||||
|
for (auto& [stateId, state] : m_States) {
|
||||||
|
state.Update(deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void PropertyBehavior::HandleMsg(AddStripMessage& msg) {
|
void PropertyBehavior::HandleMsg(AddStripMessage& msg) {
|
||||||
m_States[msg.GetActionContext().GetStateId()].HandleMsg(msg);
|
m_States[msg.GetActionContext().GetStateId()].HandleMsg(msg);
|
||||||
|
@ -18,6 +18,8 @@ class PropertyBehavior {
|
|||||||
public:
|
public:
|
||||||
PropertyBehavior();
|
PropertyBehavior();
|
||||||
|
|
||||||
|
void Update(float deltaTime);
|
||||||
|
|
||||||
template <typename Msg>
|
template <typename Msg>
|
||||||
void HandleMsg(Msg& msg);
|
void HandleMsg(Msg& msg);
|
||||||
|
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
#include "ControlBehaviorMsgs.h"
|
#include "ControlBehaviorMsgs.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
void State::Update(float deltaTime) {
|
||||||
|
for (auto& strip : m_Strips) {
|
||||||
|
strip.Update(deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void State::HandleMsg(AddStripMessage& msg) {
|
void State::HandleMsg(AddStripMessage& msg) {
|
||||||
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
if (m_Strips.size() <= msg.GetActionContext().GetStripId()) {
|
||||||
|
@ -11,6 +11,8 @@ class AMFArrayValue;
|
|||||||
|
|
||||||
class State {
|
class State {
|
||||||
public:
|
public:
|
||||||
|
void Update(float deltaTime);
|
||||||
|
|
||||||
template <typename Msg>
|
template <typename Msg>
|
||||||
void HandleMsg(Msg& msg);
|
void HandleMsg(Msg& msg);
|
||||||
|
|
||||||
|
@ -4,6 +4,15 @@
|
|||||||
#include "ControlBehaviorMsgs.h"
|
#include "ControlBehaviorMsgs.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
void Strip::Update(float deltaTime) {
|
||||||
|
if (m_Actions.empty() || m_ActionIndex >= m_Actions.size()) return;
|
||||||
|
|
||||||
|
auto& action = m_Actions[m_ActionIndex];
|
||||||
|
action.Update(deltaTime);
|
||||||
|
LOG("Running action %s", action.GetType().c_str());
|
||||||
|
if (action.Done()) m_ActionIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(AddStripMessage& msg) {
|
void Strip::HandleMsg(AddStripMessage& msg) {
|
||||||
m_Actions = msg.GetActionsToAdd();
|
m_Actions = msg.GetActionsToAdd();
|
||||||
|
@ -14,6 +14,8 @@ class AMFArrayValue;
|
|||||||
|
|
||||||
class Strip {
|
class Strip {
|
||||||
public:
|
public:
|
||||||
|
void Update(float deltaTime);
|
||||||
|
|
||||||
template <typename Msg>
|
template <typename Msg>
|
||||||
void HandleMsg(Msg& msg);
|
void HandleMsg(Msg& msg);
|
||||||
|
|
||||||
@ -23,6 +25,8 @@ public:
|
|||||||
void Serialize(tinyxml2::XMLElement& strip) const;
|
void Serialize(tinyxml2::XMLElement& strip) const;
|
||||||
void Deserialize(const tinyxml2::XMLElement& strip);
|
void Deserialize(const tinyxml2::XMLElement& strip);
|
||||||
private:
|
private:
|
||||||
|
uint32_t m_ActionIndex{ 0 };
|
||||||
|
|
||||||
std::vector<Action> m_Actions;
|
std::vector<Action> m_Actions;
|
||||||
StripUiPosition m_Position;
|
StripUiPosition m_Position;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user