mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-21 21:17:25 +00:00
Consilidating
This commit is contained in:
parent
1bdce8384f
commit
e5bea0a5ef
@ -521,52 +521,7 @@ void Entity::Initialize() {
|
||||
}
|
||||
|
||||
if (int componentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD) > 0) {
|
||||
auto* quickBuildComponent = AddComponent<QuickBuildComponent>();
|
||||
|
||||
CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable<CDRebuildComponentTable>();
|
||||
std::vector<CDRebuildComponent> rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == quickBuildComponentID); });
|
||||
|
||||
if (rebCompData.size() > 0) {
|
||||
quickBuildComponent->SetResetTime(rebCompData[0].reset_time);
|
||||
quickBuildComponent->SetCompleteTime(rebCompData[0].complete_time);
|
||||
quickBuildComponent->SetTakeImagination(rebCompData[0].take_imagination);
|
||||
quickBuildComponent->SetInterruptible(rebCompData[0].interruptible);
|
||||
quickBuildComponent->SetSelfActivator(rebCompData[0].self_activator);
|
||||
quickBuildComponent->SetActivityId(rebCompData[0].activityID);
|
||||
quickBuildComponent->SetPostImaginationCost(rebCompData[0].post_imagination_cost);
|
||||
quickBuildComponent->SetTimeBeforeSmash(rebCompData[0].time_before_smash);
|
||||
|
||||
const auto rebuildResetTime = GetVar<float>(u"rebuild_reset_time");
|
||||
|
||||
if (rebuildResetTime != 0.0f) {
|
||||
quickBuildComponent->SetResetTime(rebuildResetTime);
|
||||
|
||||
// Known bug with moving platform in FV that casues it to build at the end instead of the start.
|
||||
// This extends the smash time so players can ride up the lift.
|
||||
if (m_TemplateID == 9483) {
|
||||
quickBuildComponent->SetResetTime(quickBuildComponent->GetResetTime() + 25);
|
||||
}
|
||||
}
|
||||
|
||||
const auto activityID = GetVar<int32_t>(u"activityID");
|
||||
|
||||
if (activityID > 0) {
|
||||
quickBuildComponent->SetActivityId(activityID);
|
||||
Loot::CacheMatrix(activityID);
|
||||
}
|
||||
|
||||
const auto timeBeforeSmash = GetVar<float>(u"tmeSmsh");
|
||||
|
||||
if (timeBeforeSmash > 0) {
|
||||
quickBuildComponent->SetTimeBeforeSmash(timeBeforeSmash);
|
||||
}
|
||||
|
||||
const auto compTime = GetVar<float>(u"compTime");
|
||||
|
||||
if (compTime > 0) {
|
||||
quickBuildComponent->SetCompleteTime(compTime);
|
||||
}
|
||||
}
|
||||
auto* quickBuildComponent = AddComponent<QuickBuildComponent>(componentID);
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SWITCH, -1) != -1) {
|
||||
@ -2023,6 +1978,10 @@ LDFBaseData* Entity::GetVarData(const std::u16string& name) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Entity::CheckIfVarExists(const std::u16string& name) const {
|
||||
return GetVarData(name) != nullptr;
|
||||
}
|
||||
|
||||
std::string Entity::GetVarAsString(const std::u16string& name) const {
|
||||
auto* data = GetVarData(name);
|
||||
|
||||
|
@ -282,6 +282,12 @@ public:
|
||||
*/
|
||||
LDFBaseData* GetVarData(const std::u16string& name) const;
|
||||
|
||||
/**
|
||||
* Returns if a var exists
|
||||
*/
|
||||
bool CheckIfVarExists(const std::u16string& name) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the LDF value and convert it to a string.
|
||||
*/
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "Logger.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "BehaviorContext.h"
|
||||
#include "BaseCombatAIComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "QuickBuildComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
|
||||
#include <vector>
|
||||
|
@ -30,8 +30,14 @@
|
||||
#include "LeaderboardManager.h"
|
||||
|
||||
ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Component(parent) {
|
||||
m_Parent = parent;
|
||||
if (activityID == -1) return;
|
||||
SetupActivity(activityID);
|
||||
}
|
||||
|
||||
void ActivityComponent::SetupActivity(int32_t activityID){
|
||||
if (activityID > 0) m_ActivityID = activityID;
|
||||
else m_ActivityID = parent->GetVar<int32_t>(u"activityID");
|
||||
else m_ActivityID = m_Parent->GetVar<int32_t>(u"activityID");
|
||||
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
||||
std::vector<CDActivities> activities = activitiesTable->Query([=](CDActivities entry) {return (entry.ActivityID == m_ActivityID); });
|
||||
|
||||
@ -42,7 +48,7 @@ ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Compo
|
||||
m_ActivityInfo.minTeams = 1;
|
||||
}
|
||||
if (m_ActivityInfo.instanceMapID == -1) {
|
||||
const auto& transferOverride = parent->GetVarAsString(u"transferZoneID");
|
||||
const auto& transferOverride = m_Parent->GetVarAsString(u"transferZoneID");
|
||||
if (!transferOverride.empty()) {
|
||||
GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ struct ActivityPlayer {
|
||||
*/
|
||||
class ActivityComponent : public Component {
|
||||
public:
|
||||
ActivityComponent(Entity* parent, int32_t activityID);
|
||||
ActivityComponent(Entity* parent, int32_t activityID = -1);
|
||||
|
||||
void Update(float deltaTime) override;
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||
@ -205,6 +205,12 @@ public:
|
||||
*/
|
||||
int GetActivityID() { return m_ActivityInfo.ActivityID; }
|
||||
|
||||
/**
|
||||
* Sets the ID of this activity
|
||||
*/
|
||||
void SetActivityID(int32_t activityID) { m_ActivityID = activityID; }
|
||||
|
||||
|
||||
/**
|
||||
* Returns if this activity has a lobby, e.g. if it needs to instance players to some other map
|
||||
* @return true if this activity has a lobby, false otherwise
|
||||
@ -280,7 +286,7 @@ public:
|
||||
* Returns all the score for the players that are currently playing this activity
|
||||
* @return
|
||||
*/
|
||||
std::vector<ActivityPlayer*> GetActivityPlayers() { return m_ActivityPlayers; };
|
||||
std::vector<ActivityPlayer*> GetActivityPlayers() const { return m_ActivityPlayers; };
|
||||
|
||||
/**
|
||||
* Returns activity data for a specific entity (e.g. score and such).
|
||||
@ -330,6 +336,13 @@ public:
|
||||
* @return the LMI that this activity points to for a team size
|
||||
*/
|
||||
uint32_t GetLootMatrixForTeamSize(uint32_t teamSize) { return m_ActivityLootMatrices[teamSize]; }
|
||||
|
||||
/**
|
||||
* Sets up the activity data for a gievn activity
|
||||
*/
|
||||
void SetupActivity(int32_t activityID);
|
||||
|
||||
void ClearActivityPlayerData() { m_ActivityPlayers.clear(); m_DirtyActivityInfo = true;};
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -21,16 +21,46 @@
|
||||
#include "Loot.h"
|
||||
#include "TeamManager.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "CDRebuildComponentTable.h"
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
QuickBuildComponent::QuickBuildComponent(Entity* entity) : Component(entity) {
|
||||
std::u16string checkPreconditions = entity->GetVar<std::u16string>(u"CheckPrecondition");
|
||||
QuickBuildComponent::QuickBuildComponent(Entity* parent, uint32_t id) : ActivityComponent(parent) {
|
||||
m_Parent = parent;
|
||||
|
||||
CDRebuildComponentTable* rebCompTable = CDClientManager::Instance().GetTable<CDRebuildComponentTable>();
|
||||
std::vector<CDRebuildComponent> rebCompData = rebCompTable->Query([=](CDRebuildComponent entry) { return (entry.id == id); });
|
||||
|
||||
if (rebCompData.size() > 0) {
|
||||
SetResetTime(rebCompData[0].reset_time);
|
||||
SetCompleteTime(rebCompData[0].complete_time);
|
||||
SetTakeImagination(rebCompData[0].take_imagination);
|
||||
SetActivityID(rebCompData[0].activityID);
|
||||
SetInterruptible(rebCompData[0].interruptible);
|
||||
SetSelfActivator(rebCompData[0].self_activator);
|
||||
SetPostImaginationCost(rebCompData[0].post_imagination_cost);
|
||||
SetTimeBeforeSmash(rebCompData[0].time_before_smash);
|
||||
const auto compTime = m_Parent->GetVar<float>(u"compTime");
|
||||
if (compTime > 0) SetCompleteTime(compTime);
|
||||
}
|
||||
std::u16string checkPreconditions = m_Parent->GetVar<std::u16string>(u"CheckPrecondition");
|
||||
|
||||
if (!checkPreconditions.empty()) {
|
||||
m_Precondition = new PreconditionExpression(GeneralUtils::UTF16ToWTF8(checkPreconditions));
|
||||
}
|
||||
|
||||
const auto activityID = m_Parent->GetVar<int32_t>(u"activityID");
|
||||
if (activityID > 0) SetActivityID(activityID);
|
||||
SetupActivity(GetActivityID());
|
||||
|
||||
const auto rebuildResetTime = m_Parent->GetVar<float>(u"rebuild_reset_time");
|
||||
if (rebuildResetTime != 0.0f) {
|
||||
SetResetTime(rebuildResetTime);
|
||||
// Known bug with moving platform in FV that casues it to build at the end instead of the start.
|
||||
// This extends the smash time so players can ride up the lift.
|
||||
if (m_Parent->GetLOT() == 9483) SetResetTime(GetResetTime() + 25);
|
||||
}
|
||||
|
||||
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
|
||||
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
|
||||
auto positionAsVector = GeneralUtils::SplitString(m_Parent->GetVarAsString(u"rebuild_activators"), 0x1F);
|
||||
@ -38,11 +68,22 @@ QuickBuildComponent::QuickBuildComponent(Entity* entity) : Component(entity) {
|
||||
GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) &&
|
||||
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
|
||||
GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) {
|
||||
} else if (
|
||||
m_Parent->CheckIfVarExists(u"position.x") &&
|
||||
m_Parent->CheckIfVarExists(u"position.y") &&
|
||||
m_Parent->CheckIfVarExists(u"position.z")) {
|
||||
m_ActivatorPosition.x = m_Parent->GetVar<float>(u"position.x");
|
||||
m_ActivatorPosition.y = m_Parent->GetVar<float>(u"position.y");
|
||||
m_ActivatorPosition.x = m_Parent->GetVar<float>(u"position.z");
|
||||
} else {
|
||||
LOG("Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT());
|
||||
m_ActivatorPosition = m_Parent->GetPosition();
|
||||
}
|
||||
|
||||
|
||||
const auto timeBeforeSmash = m_Parent->GetVar<float>(u"tmeSmsh");
|
||||
if (timeBeforeSmash > 0) SetTimeBeforeSmash(timeBeforeSmash);
|
||||
m_IsChoiceBuild = m_Parent->GetBoolean(u"is_ChoiceBuild");
|
||||
|
||||
SpawnActivator();
|
||||
}
|
||||
|
||||
@ -58,71 +99,27 @@ QuickBuildComponent::~QuickBuildComponent() {
|
||||
}
|
||||
|
||||
void QuickBuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
||||
if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) {
|
||||
ActivityComponent::Serialize(outBitStream, bIsInitialUpdate);
|
||||
outBitStream->Write(m_StateDirty);
|
||||
if (m_StateDirty) {
|
||||
outBitStream->Write(m_State);
|
||||
outBitStream->Write(m_ShowResetEffect);
|
||||
outBitStream->Write(m_Activator != nullptr);
|
||||
outBitStream->Write(m_Timer);
|
||||
outBitStream->Write(m_TimerIncomplete);
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write(false);
|
||||
outBitStream->Write(m_IsChoiceBuild);
|
||||
if (m_IsChoiceBuild) outBitStream->Write(m_ResetTime);
|
||||
outBitStream->Write(m_ActivatorPosition);
|
||||
outBitStream->Write(m_RepositionPlayer);
|
||||
}
|
||||
|
||||
outBitStream->Write(false);
|
||||
|
||||
outBitStream->Write(false);
|
||||
if (!bIsInitialUpdate) m_StateDirty = false;
|
||||
}
|
||||
// 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 == eQuickBuildState::COMPLETED) {
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write0();
|
||||
return;
|
||||
}
|
||||
// BEGIN Scripted Activity
|
||||
outBitStream->Write1();
|
||||
|
||||
Entity* builder = GetBuilder();
|
||||
|
||||
if (builder) {
|
||||
outBitStream->Write<uint32_t>(1);
|
||||
outBitStream->Write(builder->GetObjectID());
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
outBitStream->Write(0.0f);
|
||||
}
|
||||
} else {
|
||||
outBitStream->Write<uint32_t>(0);
|
||||
}
|
||||
// END Scripted Activity
|
||||
|
||||
outBitStream->Write1();
|
||||
|
||||
outBitStream->Write(m_State);
|
||||
|
||||
outBitStream->Write(m_ShowResetEffect);
|
||||
outBitStream->Write(m_Activator != nullptr);
|
||||
|
||||
outBitStream->Write(m_Timer);
|
||||
outBitStream->Write(m_TimerIncomplete);
|
||||
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write(false);
|
||||
outBitStream->Write(m_ActivatorPosition);
|
||||
outBitStream->Write(m_RepositionPlayer);
|
||||
}
|
||||
m_StateDirty = false;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::Update(float deltaTime) {
|
||||
m_Activator = GetActivator();
|
||||
|
||||
// Serialize the quickbuild every so often, fixes the odd bug where the quickbuild is not buildable
|
||||
/*if (m_SoftTimer > 0.0f) {
|
||||
m_SoftTimer -= deltaTime;
|
||||
}
|
||||
else {
|
||||
m_SoftTimer = 5.0f;
|
||||
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}*/
|
||||
|
||||
switch (m_State) {
|
||||
case eQuickBuildState::OPEN: {
|
||||
SpawnActivator();
|
||||
@ -138,14 +135,14 @@ void QuickBuildComponent::Update(float deltaTime) {
|
||||
if (m_TimeBeforeSmash > 0) {
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
m_StateDirty = true;
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
ClearActivityPlayerData();
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
GameMessages::SendDie(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
ResetQuickBuild(false);
|
||||
}
|
||||
@ -162,14 +159,14 @@ void QuickBuildComponent::Update(float deltaTime) {
|
||||
if (m_Timer >= m_ResetTime - 4.0f) {
|
||||
if (!m_ShowResetEffect) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
m_StateDirty = true;
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Timer >= m_ResetTime) {
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
GameMessages::SendDie(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
ResetQuickBuild(false);
|
||||
}
|
||||
@ -190,7 +187,7 @@ void QuickBuildComponent::Update(float deltaTime) {
|
||||
m_Timer += deltaTime;
|
||||
m_TimerIncomplete = 0;
|
||||
m_ShowResetEffect = false;
|
||||
|
||||
m_StateDirty = true;
|
||||
if (m_TimeBeforeDrain <= 0.0f) {
|
||||
m_TimeBeforeDrain = m_CompleteTime / static_cast<float>(m_TakeImagination);
|
||||
|
||||
@ -223,14 +220,14 @@ void QuickBuildComponent::Update(float deltaTime) {
|
||||
if (m_TimeBeforeSmash > 0) {
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
m_StateDirty = true;
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
ClearActivityPlayerData();
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
GameMessages::SendDie(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
ResetQuickBuild(false);
|
||||
}
|
||||
@ -317,10 +314,6 @@ std::vector<int> QuickBuildComponent::GetCustomModules() {
|
||||
return m_CustomModules;
|
||||
}
|
||||
|
||||
int QuickBuildComponent::GetActivityId() {
|
||||
return m_ActivityId;
|
||||
}
|
||||
|
||||
int QuickBuildComponent::GetPostImaginationCost() {
|
||||
return m_PostImaginationCost;
|
||||
}
|
||||
@ -334,7 +327,9 @@ eQuickBuildState QuickBuildComponent::GetState() {
|
||||
}
|
||||
|
||||
Entity* QuickBuildComponent::GetBuilder() const {
|
||||
auto* builder = Game::entityManager->GetEntity(m_Builder);
|
||||
const auto players = GetActivityPlayers();
|
||||
if (players.empty()) return nullptr;
|
||||
auto* builder = Game::entityManager->GetEntity(players[0]->playerID);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@ -348,15 +343,13 @@ void QuickBuildComponent::SetActivatorPosition(NiPoint3 value) {
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetResetTime(float value) {
|
||||
m_ResetTime = value;
|
||||
if (value < 0) m_ResetTime = 20.0f;
|
||||
else m_ResetTime = value;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetCompleteTime(float value) {
|
||||
if (value < 0) {
|
||||
m_CompleteTime = 4.5f;
|
||||
} else {
|
||||
m_CompleteTime = value;
|
||||
}
|
||||
if (value < 0) m_CompleteTime = 4.5f;
|
||||
else m_CompleteTime = value;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetTakeImagination(int value) {
|
||||
@ -375,20 +368,13 @@ void QuickBuildComponent::SetCustomModules(std::vector<int> value) {
|
||||
m_CustomModules = value;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetActivityId(int value) {
|
||||
m_ActivityId = value;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetPostImaginationCost(int value) {
|
||||
m_PostImaginationCost = value;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetTimeBeforeSmash(float value) {
|
||||
if (value < 0) {
|
||||
m_TimeBeforeSmash = 10.0f;
|
||||
} else {
|
||||
m_TimeBeforeSmash = value;
|
||||
}
|
||||
if (value < 0) m_TimeBeforeSmash = 10.0f;
|
||||
else m_TimeBeforeSmash = value;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SetRepositionPlayer(bool value) {
|
||||
@ -397,7 +383,8 @@ void QuickBuildComponent::SetRepositionPlayer(bool value) {
|
||||
|
||||
void QuickBuildComponent::StartQuickBuild(Entity* user) {
|
||||
if (m_State == eQuickBuildState::OPEN || m_State == eQuickBuildState::COMPLETED || m_State == eQuickBuildState::INCOMPLETE) {
|
||||
m_Builder = user->GetObjectID();
|
||||
// user->GetObjectID();
|
||||
AddActivityPlayerData(user->GetObjectID());
|
||||
|
||||
auto* character = user->GetComponent<CharacterComponent>();
|
||||
character->SetCurrentActivity(eGameActivity::QUICKBUILDING);
|
||||
@ -478,14 +465,14 @@ void QuickBuildComponent::CompleteQuickBuild(Entity* user) {
|
||||
auto* member = Game::entityManager->GetEntity(memberId);
|
||||
if (member) {
|
||||
auto* missionComponent = member->GetComponent<MissionComponent>();
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, GetActivityID());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto* missionComponent = builder->GetComponent<MissionComponent>();
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, GetActivityID());
|
||||
}
|
||||
Loot::DropActivityLoot(builder, m_Parent, m_ActivityId, 1);
|
||||
Loot::DropActivityLoot(builder, m_Parent, GetActivityID(), 1);
|
||||
}
|
||||
|
||||
// Notify scripts
|
||||
@ -557,8 +544,7 @@ void QuickBuildComponent::ResetQuickBuild(bool failed) {
|
||||
|
||||
void QuickBuildComponent::CancelQuickBuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks) {
|
||||
if (m_State != eQuickBuildState::COMPLETED || skipChecks) {
|
||||
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
RemoveActivityPlayerData(entity->GetObjectID());
|
||||
|
||||
const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "NiPoint3.h"
|
||||
#include "ScriptedActivityComponent.h"
|
||||
#include "Preconditions.h"
|
||||
#include "Component.h"
|
||||
#include "ActivityComponent.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "eQuickBuildState.h"
|
||||
|
||||
@ -20,11 +20,11 @@ enum class eQuickBuildFailReason : uint32_t;
|
||||
* consists of an activator that shows a popup and then the actual entity that the bricks are built into. Note
|
||||
* that quick builds are also scripted activities so this shared some logic with the ScriptedActivityComponent.
|
||||
*/
|
||||
class QuickBuildComponent : public Component {
|
||||
class QuickBuildComponent : public ActivityComponent {
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD;
|
||||
|
||||
QuickBuildComponent(Entity* entity);
|
||||
QuickBuildComponent(Entity* parent, uint32_t id);
|
||||
~QuickBuildComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||
@ -213,11 +213,11 @@ public:
|
||||
|
||||
/**
|
||||
* Cancels the quickbuild if it wasn't completed
|
||||
* @param builder the player that's currently building
|
||||
* @param entity the player that's currently building
|
||||
* @param failReason the reason the quickbuild was cancelled
|
||||
* @param skipChecks whether or not to skip the check for the quickbuild not being completed
|
||||
*/
|
||||
void CancelQuickBuild(Entity* builder, eQuickBuildFailReason failReason, bool skipChecks = false);
|
||||
void CancelQuickBuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks = false);
|
||||
private:
|
||||
/**
|
||||
* Whether or not the quickbuild state has been changed since we last serialized it.
|
||||
@ -304,11 +304,6 @@ private:
|
||||
*/
|
||||
std::vector<int> m_CustomModules{};
|
||||
|
||||
/**
|
||||
* The activity ID that players partake in when doing this quickbuild
|
||||
*/
|
||||
int m_ActivityId = 0;
|
||||
|
||||
/**
|
||||
* Currently unused
|
||||
*/
|
||||
@ -339,11 +334,6 @@ private:
|
||||
*/
|
||||
float m_SoftTimer = 0;
|
||||
|
||||
/**
|
||||
* The ID of the entity that's currently building the quickbuild
|
||||
*/
|
||||
LWOOBJID m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
/**
|
||||
* Preconditions to be met before being able to start the quickbuild
|
||||
*/
|
||||
@ -360,6 +350,11 @@ private:
|
||||
* @param user the entity that completed the quickbuild
|
||||
*/
|
||||
void CompleteQuickBuild(Entity* user);
|
||||
|
||||
/**
|
||||
* Is this quickbuild from a choicebuild
|
||||
*/
|
||||
bool m_IsChoiceBuild = false;
|
||||
};
|
||||
|
||||
#endif // QUICKBUILDCOMPONENT_H
|
||||
|
@ -814,28 +814,6 @@ void GameMessages::SendTerminateInteraction(const LWOOBJID& objectID, eTerminate
|
||||
SEND_PACKET_BROADCAST;
|
||||
}
|
||||
|
||||
void GameMessages::SendDieNoImplCode(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(entity->GetObjectID());
|
||||
bitStream.Write(eGameMessageType::DIE);
|
||||
bitStream.Write(bClientDeath);
|
||||
bitStream.Write(bSpawnLoot);
|
||||
bitStream.Write(deathType);
|
||||
bitStream.Write(directionRelative_AngleXZ);
|
||||
bitStream.Write(directionRelative_AngleY);
|
||||
bitStream.Write(directionRelative_Force);
|
||||
|
||||
bitStream.Write(killType != eKillType::VIOLENT);
|
||||
if (killType != eKillType::VIOLENT) bitStream.Write(killType);
|
||||
|
||||
bitStream.Write(killerID);
|
||||
bitStream.Write(lootOwnerID);
|
||||
|
||||
SEND_PACKET_BROADCAST;
|
||||
}
|
||||
|
||||
void GameMessages::SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot, float coinSpawnTime) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
@ -4953,7 +4931,7 @@ void GameMessages::HandleQuickBuildCancel(RakNet::BitStream* inStream, Entity* e
|
||||
inStream->Read(bEarlyRelease);
|
||||
inStream->Read(userID);
|
||||
|
||||
auto* quickBuildComponent = static_cast<QuickBuildComponent*>(entity->GetComponent(eReplicaComponentType::QUICK_BUILD));;
|
||||
auto* quickBuildComponent = entity->GetComponent<QuickBuildComponent>();
|
||||
if (!quickBuildComponent) return;
|
||||
|
||||
quickBuildComponent->CancelQuickBuild(Game::entityManager->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY);
|
||||
|
@ -105,7 +105,6 @@ namespace GameMessages {
|
||||
void AddActivityOwner(Entity* entity, LWOOBJID& ownerID);
|
||||
void SendTerminateInteraction(const LWOOBJID& objectID, eTerminateType type, const LWOOBJID& terminator);
|
||||
|
||||
void SendDieNoImplCode(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot);
|
||||
void SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot, float coinSpawnTime);
|
||||
|
||||
void SendSetInventorySize(Entity* entity, int invType, int size);
|
||||
|
Loading…
Reference in New Issue
Block a user