mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
feat: Add Restart Behavior (#1836)
Resets the model to the default state at the end of the models frame. Will see if in the future designers want this to be more strict on the resetting timing.
This commit is contained in:
@@ -63,6 +63,12 @@ void ModelComponent::Update(float deltaTime) {
|
||||
for (auto& behavior : m_Behaviors) {
|
||||
behavior.Update(deltaTime, *this);
|
||||
}
|
||||
|
||||
if (!m_RestartAtEndOfFrame) return;
|
||||
|
||||
GameMessages::ResetModelToDefaults reset{};
|
||||
OnResetModelToDefaults(reset);
|
||||
m_RestartAtEndOfFrame = false;
|
||||
}
|
||||
|
||||
void ModelComponent::LoadBehaviors() {
|
||||
|
@@ -146,7 +146,11 @@ public:
|
||||
|
||||
void OnChatMessageReceived(const std::string& sMessage);
|
||||
|
||||
// Sets the speed of the model
|
||||
void SetSpeed(const float newSpeed) { m_Speed = newSpeed; }
|
||||
|
||||
// Whether or not to restart at the end of the frame
|
||||
void RestartAtEndOfFrame() { m_RestartAtEndOfFrame = true; }
|
||||
private:
|
||||
|
||||
// Loads a behavior from the database.
|
||||
@@ -190,4 +194,7 @@ private:
|
||||
|
||||
// The speed at which this model moves
|
||||
float m_Speed{ 3.0f };
|
||||
|
||||
// Whether or not to restart at the end of the frame.
|
||||
bool m_RestartAtEndOfFrame{ false };
|
||||
};
|
||||
|
Reference in New Issue
Block a user