2021-12-05 17:54:36 +00:00
|
|
|
#include "NjRailActivatorsServer.h"
|
|
|
|
#include "RebuildComponent.h"
|
|
|
|
#include "Character.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) {
|
|
|
|
const auto flag = self->GetVar<int32_t>(u"RailFlagNum");
|
|
|
|
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
// Only allow use if this is not a quick build or the quick build is built
|
|
|
|
if (rebuildComponent == nullptr || rebuildComponent->GetState() == REBUILD_COMPLETED) {
|
|
|
|
auto* character = user->GetCharacter();
|
|
|
|
if (character != nullptr) {
|
|
|
|
character->SetPlayerFlag(flag, true);
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|