mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
add running flag
This commit is contained in:
parent
06897eb2ae
commit
56ec037eb6
@ -15,6 +15,7 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) {
|
||||
m_OriginalRotation = m_Parent->GetDefaultRotation();
|
||||
|
||||
m_userModelID = m_Parent->GetVarAs<LWOOBJID>(u"userModelID");
|
||||
m_Running = false;
|
||||
}
|
||||
|
||||
void ModelComponent::LoadBehaviors() {
|
||||
@ -67,6 +68,7 @@ void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialU
|
||||
}
|
||||
|
||||
void ModelComponent::Update(float deltaTime) {
|
||||
if (!m_Running) return;
|
||||
for (auto& behavior : m_Behaviors) behavior.Update(deltaTime);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,11 @@ public:
|
||||
|
||||
std::array<std::pair<int32_t, std::string>, 5> GetBehaviorsForSave() const;
|
||||
|
||||
void SetIsRunning(bool isRunning) { m_Running = isRunning; }
|
||||
bool GetIsRunning() const { return m_Running; }
|
||||
|
||||
private:
|
||||
bool m_Running;
|
||||
/**
|
||||
* The behaviors of the model
|
||||
* Note: This is a vector because the order of the behaviors matters when serializing to the client.
|
||||
|
@ -253,6 +253,15 @@ void PropertyManagementComponent::OnStartBuilding() {
|
||||
|
||||
// Push equipped items
|
||||
if (inventoryComponent) inventoryComponent->PushEquippedItems();
|
||||
|
||||
for (const auto obj : models | std::views::keys) {
|
||||
auto* const model = Game::entityManager->GetEntity(obj);
|
||||
|
||||
if (!model) continue;
|
||||
|
||||
auto* const modelComponent = model->GetComponent<ModelComponent>();
|
||||
if (modelComponent) modelComponent->SetIsRunning(false);
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::OnFinishBuilding() {
|
||||
@ -265,6 +274,14 @@ void PropertyManagementComponent::OnFinishBuilding() {
|
||||
UpdateApprovedStatus(false);
|
||||
|
||||
Save();
|
||||
for (const auto obj : models | std::views::keys) {
|
||||
auto* const model = Game::entityManager->GetEntity(obj);
|
||||
|
||||
if (!model) continue;
|
||||
|
||||
auto* const modelComponent = model->GetComponent<ModelComponent>();
|
||||
if (modelComponent) modelComponent->SetIsRunning(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation) {
|
||||
|
Loading…
Reference in New Issue
Block a user