Breakout rest of the enums from dCommonVars and clean it up (#1061)

* Breakout rest of the enums from dcommonvars
so we don't have to deal with merge conflicts
ePlayerFlags is not a scoped enum, yet, due to it's complexity

* address feedback

* make player flag types consistent

* fix typo
This commit is contained in:
Aaron Kimbrell
2023-05-02 17:39:21 -05:00
committed by GitHub
parent e8590a5853
commit 6aa90ad5b2
161 changed files with 960 additions and 776 deletions

View File

@@ -9,6 +9,9 @@
#include "MissionComponent.h"
#include "eMissionTaskType.h"
#include "eTriggerEventType.h"
#include "eQuickBuildFailReason.h"
#include "eTerminateType.h"
#include "eGameActivity.h"
#include "dServer.h"
#include "PacketUtils.h"
@@ -47,7 +50,7 @@ RebuildComponent::~RebuildComponent() {
Entity* builder = GetBuilder();
if (builder) {
CancelRebuild(builder, eFailReason::REASON_BUILD_ENDED, true);
CancelRebuild(builder, eQuickBuildFailReason::BUILD_ENDED, true);
}
DespawnActivator();
@@ -66,7 +69,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
// If build state is completed and we've already serialized once in the completed state,
// don't serializing this component anymore as this will cause the build to jump again.
// If state changes, serialization will begin again.
if (!m_StateDirty && m_State == REBUILD_COMPLETED) {
if (!m_StateDirty && m_State == eRebuildState::COMPLETED) {
outBitStream->Write0();
outBitStream->Write0();
return;
@@ -90,7 +93,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
outBitStream->Write1();
outBitStream->Write<uint32_t>(m_State);
outBitStream->Write(m_State);
outBitStream->Write(m_ShowResetEffect);
outBitStream->Write(m_Activator != nullptr);
@@ -120,7 +123,7 @@ void RebuildComponent::Update(float deltaTime) {
}*/
switch (m_State) {
case REBUILD_OPEN: {
case eRebuildState::OPEN: {
SpawnActivator();
m_TimeBeforeDrain = 0;
@@ -150,7 +153,7 @@ void RebuildComponent::Update(float deltaTime) {
break;
}
case REBUILD_COMPLETED: {
case eRebuildState::COMPLETED: {
m_Timer += deltaTime;
// For reset times < 0 this has to be handled manually
@@ -172,7 +175,7 @@ void RebuildComponent::Update(float deltaTime) {
}
break;
}
case REBUILD_BUILDING:
case eRebuildState::BUILDING:
{
Entity* builder = GetBuilder();
@@ -201,7 +204,7 @@ void RebuildComponent::Update(float deltaTime) {
++m_DrainedImagination;
if (newImagination == 0 && m_DrainedImagination < m_TakeImagination) {
CancelRebuild(builder, eFailReason::REASON_OUT_OF_IMAGINATION, true);
CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true);
break;
}
@@ -213,7 +216,7 @@ void RebuildComponent::Update(float deltaTime) {
break;
}
case REBUILD_INCOMPLETE: {
case eRebuildState::INCOMPLETE: {
m_TimerIncomplete += deltaTime;
// For reset times < 0 this has to be handled manually
@@ -234,12 +237,12 @@ void RebuildComponent::Update(float deltaTime) {
}
break;
}
case REBUILD_RESETTING: break;
case eRebuildState::RESETTING: break;
}
}
void RebuildComponent::OnUse(Entity* originator) {
if (GetBuilder() != nullptr || m_State == REBUILD_COMPLETED) {
if (GetBuilder() != nullptr || m_State == eRebuildState::COMPLETED) {
return;
}
@@ -393,18 +396,18 @@ void RebuildComponent::SetRepositionPlayer(bool value) {
}
void RebuildComponent::StartRebuild(Entity* user) {
if (m_State == eRebuildState::REBUILD_OPEN || m_State == eRebuildState::REBUILD_COMPLETED || m_State == eRebuildState::REBUILD_INCOMPLETE) {
if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) {
m_Builder = user->GetObjectID();
auto* character = user->GetComponent<CharacterComponent>();
character->SetCurrentActivity(eGameActivities::ACTIVITY_QUICKBUILDING);
character->SetCurrentActivity(eGameActivity::QUICKBUILDING);
EntityManager::Instance()->SerializeEntity(user);
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_BUILDING, user->GetObjectID());
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eFailReason::REASON_NOT_GIVEN, 0.0f, user->GetObjectID());
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::BUILDING, user->GetObjectID());
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
m_State = eRebuildState::REBUILD_BUILDING;
m_State = eRebuildState::BUILDING;
m_StateDirty = true;
EntityManager::Instance()->SerializeEntity(m_Parent);
@@ -432,7 +435,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
auto* characterComponent = user->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE);
characterComponent->SetCurrentActivity(eGameActivity::NONE);
characterComponent->TrackRebuildComplete();
} else {
Game::logger->Log("RebuildComponent", "Some user tried to finish the rebuild but they didn't have a character somehow.");
@@ -441,13 +444,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
EntityManager::Instance()->SerializeEntity(user);
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_COMPLETED, user->GetObjectID());
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::COMPLETED, user->GetObjectID());
GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
GameMessages::SendEnableRebuild(m_Parent, false, false, true, eFailReason::REASON_NOT_GIVEN, m_ResetTime, user->GetObjectID());
GameMessages::SendEnableRebuild(m_Parent, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
m_State = eRebuildState::REBUILD_COMPLETED;
m_State = eRebuildState::COMPLETED;
m_StateDirty = true;
m_Timer = 0.0f;
m_DrainedImagination = 0;
@@ -520,17 +523,17 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
void RebuildComponent::ResetRebuild(bool failed) {
Entity* builder = GetBuilder();
if (m_State == eRebuildState::REBUILD_BUILDING && builder) {
GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eFailReason::REASON_NOT_GIVEN, m_ResetTime, builder->GetObjectID());
if (m_State == eRebuildState::BUILDING && builder) {
GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
if (failed) {
GameMessages::SendPlayAnimation(builder, u"rebuild-fail");
}
}
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_RESETTING, LWOOBJID_EMPTY);
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY);
m_State = eRebuildState::REBUILD_RESETTING;
m_State = eRebuildState::RESETTING;
m_StateDirty = true;
m_Timer = 0.0f;
m_TimerIncomplete = 0.0f;
@@ -552,15 +555,15 @@ void RebuildComponent::ResetRebuild(bool failed) {
}
}
void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, bool skipChecks) {
if (m_State != eRebuildState::REBUILD_COMPLETED || skipChecks) {
void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks) {
if (m_State != eRebuildState::COMPLETED || skipChecks) {
m_Builder = LWOOBJID_EMPTY;
const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY;
// Notify the client that a state has changed
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_INCOMPLETE, entityID);
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::INCOMPLETE, entityID);
GameMessages::SendEnableRebuild(m_Parent, false, true, false, failReason, m_Timer, entityID);
// Now terminate any interaction with the rebuild
@@ -568,7 +571,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo
GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
// Now update the component itself
m_State = eRebuildState::REBUILD_INCOMPLETE;
m_State = eRebuildState::INCOMPLETE;
m_StateDirty = true;
// Notify scripts and possible subscribers
@@ -586,7 +589,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo
CharacterComponent* characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent) {
characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE);
characterComponent->SetCurrentActivity(eGameActivity::NONE);
EntityManager::Instance()->SerializeEntity(entity);
}
}