mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-26 16:46:31 +00:00
i am surprised no one noticed this for 3 yeasr (#1721)
This commit is contained in:
parent
a6c6d892cf
commit
7599a2e81e
@ -386,6 +386,9 @@ void Entity::Initialize() {
|
|||||||
if (m_Character) {
|
if (m_Character) {
|
||||||
comp->LoadFromXml(m_Character->GetXMLDoc());
|
comp->LoadFromXml(m_Character->GetXMLDoc());
|
||||||
} else {
|
} else {
|
||||||
|
// extraInfo overrides. Client ORs the database smashable and the luz smashable.
|
||||||
|
comp->SetIsSmashable(comp->GetIsSmashable() | isSmashable);
|
||||||
|
|
||||||
if (componentID > 0) {
|
if (componentID > 0) {
|
||||||
std::vector<CDDestructibleComponent> destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); });
|
std::vector<CDDestructibleComponent> destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); });
|
||||||
|
|
||||||
@ -420,9 +423,6 @@ void Entity::Initialize() {
|
|||||||
comp->SetMinCoins(currencyValues[0].minvalue);
|
comp->SetMinCoins(currencyValues[0].minvalue);
|
||||||
comp->SetMaxCoins(currencyValues[0].maxvalue);
|
comp->SetMaxCoins(currencyValues[0].maxvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// extraInfo overrides. Client ORs the database smashable and the luz smashable.
|
|
||||||
comp->SetIsSmashable(comp->GetIsSmashable() | isSmashable);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comp->SetHealth(1);
|
comp->SetHealth(1);
|
||||||
@ -1565,7 +1565,7 @@ void Entity::Kill(Entity* murderer, const eKillType killType) {
|
|||||||
|
|
||||||
m_DieCallbacks.clear();
|
m_DieCallbacks.clear();
|
||||||
|
|
||||||
//OMAI WA MOU, SHINDERIU
|
//お前はもう死んでいる
|
||||||
|
|
||||||
GetScript()->OnDie(this, murderer);
|
GetScript()->OnDie(this, murderer);
|
||||||
|
|
||||||
@ -2208,7 +2208,7 @@ void Entity::SetRespawnRot(const NiQuaternion& rotation) {
|
|||||||
|
|
||||||
int32_t Entity::GetCollisionGroup() const {
|
int32_t Entity::GetCollisionGroup() const {
|
||||||
for (const auto* component : m_Components | std::views::values) {
|
for (const auto* component : m_Components | std::views::values) {
|
||||||
auto* compToCheck = dynamic_cast<const PhysicsComponent*>(component);
|
auto* compToCheck = dynamic_cast<const PhysicsComponent*>(component);
|
||||||
if (compToCheck) {
|
if (compToCheck) {
|
||||||
return compToCheck->GetCollisionGroup();
|
return compToCheck->GetCollisionGroup();
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,7 @@ void QuickBuildComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsIni
|
|||||||
|
|
||||||
outBitStream.Write(false);
|
outBitStream.Write(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
|
// BEGIN Scripted Activity
|
||||||
outBitStream.Write1();
|
outBitStream.Write1();
|
||||||
|
|
||||||
@ -90,26 +83,27 @@ void QuickBuildComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsIni
|
|||||||
}
|
}
|
||||||
// END Scripted Activity
|
// END Scripted Activity
|
||||||
|
|
||||||
outBitStream.Write1();
|
outBitStream.Write(m_StateDirty || bIsInitialUpdate);
|
||||||
|
if (m_StateDirty || bIsInitialUpdate) {
|
||||||
|
outBitStream.Write(m_State);
|
||||||
|
|
||||||
outBitStream.Write(m_State);
|
outBitStream.Write(m_ShowResetEffect);
|
||||||
|
outBitStream.Write(m_Activator != nullptr);
|
||||||
|
|
||||||
outBitStream.Write(m_ShowResetEffect);
|
outBitStream.Write(m_Timer);
|
||||||
outBitStream.Write(m_Activator != nullptr);
|
outBitStream.Write(m_TimerIncomplete);
|
||||||
|
|
||||||
outBitStream.Write(m_Timer);
|
if (bIsInitialUpdate) {
|
||||||
outBitStream.Write(m_TimerIncomplete);
|
outBitStream.Write(false); // IsChoiceBuild
|
||||||
|
outBitStream.Write(m_ActivatorPosition);
|
||||||
if (bIsInitialUpdate) {
|
outBitStream.Write(m_RepositionPlayer);
|
||||||
outBitStream.Write(false);
|
}
|
||||||
outBitStream.Write(m_ActivatorPosition);
|
m_StateDirty = false;
|
||||||
outBitStream.Write(m_RepositionPlayer);
|
|
||||||
}
|
}
|
||||||
m_StateDirty = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickBuildComponent::Update(float deltaTime) {
|
void QuickBuildComponent::Update(float deltaTime) {
|
||||||
m_Activator = GetActivator();
|
SetActivator(GetActivator());
|
||||||
|
|
||||||
// Serialize the quickbuild every so often, fixes the odd bug where the quickbuild is not buildable
|
// Serialize the quickbuild every so often, fixes the odd bug where the quickbuild is not buildable
|
||||||
/*if (m_SoftTimer > 0.0f) {
|
/*if (m_SoftTimer > 0.0f) {
|
||||||
@ -130,12 +124,13 @@ void QuickBuildComponent::Update(float deltaTime) {
|
|||||||
const bool isSmashGroup = spawner != nullptr ? spawner->GetIsSpawnSmashGroup() : false;
|
const bool isSmashGroup = spawner != nullptr ? spawner->GetIsSpawnSmashGroup() : false;
|
||||||
|
|
||||||
if (isSmashGroup) {
|
if (isSmashGroup) {
|
||||||
m_TimerIncomplete += deltaTime;
|
ModifyIncompleteTimer(deltaTime);
|
||||||
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
// For reset times < 0 this has to be handled manually
|
// For reset times < 0 this has to be handled manually
|
||||||
if (m_TimeBeforeSmash > 0) {
|
if (m_TimeBeforeSmash > 0) {
|
||||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||||
m_ShowResetEffect = true;
|
SetShowResetEffect(true);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
@ -153,21 +148,20 @@ void QuickBuildComponent::Update(float deltaTime) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eQuickBuildState::COMPLETED: {
|
case eQuickBuildState::COMPLETED: {
|
||||||
m_Timer += deltaTime;
|
ModifyTimer(deltaTime);
|
||||||
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
// For reset times < 0 this has to be handled manually
|
// For reset times < 0 this has to be handled manually
|
||||||
if (m_ResetTime > 0) {
|
if (m_ResetTime > 0) {
|
||||||
if (m_Timer >= m_ResetTime - 4.0f) {
|
if (m_Timer >= m_ResetTime - 4.0f) {
|
||||||
if (!m_ShowResetEffect) {
|
SetShowResetEffect(true);
|
||||||
m_ShowResetEffect = true;
|
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Timer >= m_ResetTime) {
|
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::SendDieNoImplCode(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 7.0f, false, true);
|
||||||
|
|
||||||
ResetQuickBuild(false);
|
ResetQuickBuild(false);
|
||||||
}
|
}
|
||||||
@ -185,9 +179,9 @@ void QuickBuildComponent::Update(float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_TimeBeforeDrain -= deltaTime;
|
m_TimeBeforeDrain -= deltaTime;
|
||||||
m_Timer += deltaTime;
|
ModifyTimer(deltaTime);
|
||||||
m_TimerIncomplete = 0;
|
SetIncompleteTimer(0.0f);
|
||||||
m_ShowResetEffect = false;
|
SetShowResetEffect(false);
|
||||||
|
|
||||||
if (m_TimeBeforeDrain <= 0.0f) {
|
if (m_TimeBeforeDrain <= 0.0f) {
|
||||||
m_TimeBeforeDrain = m_CompleteTime / static_cast<float>(m_TakeImagination);
|
m_TimeBeforeDrain = m_CompleteTime / static_cast<float>(m_TakeImagination);
|
||||||
@ -215,12 +209,13 @@ void QuickBuildComponent::Update(float deltaTime) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eQuickBuildState::INCOMPLETE: {
|
case eQuickBuildState::INCOMPLETE: {
|
||||||
m_TimerIncomplete += deltaTime;
|
ModifyIncompleteTimer(deltaTime);
|
||||||
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
// For reset times < 0 this has to be handled manually
|
// For reset times < 0 this has to be handled manually
|
||||||
if (m_TimeBeforeSmash > 0) {
|
if (m_TimeBeforeSmash > 0) {
|
||||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||||
m_ShowResetEffect = true;
|
SetShowResetEffect(true);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
@ -260,7 +255,7 @@ void QuickBuildComponent::SpawnActivator() {
|
|||||||
info.spawnerID = m_Parent->GetObjectID();
|
info.spawnerID = m_Parent->GetObjectID();
|
||||||
info.pos = m_ActivatorPosition == NiPoint3Constant::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition;
|
info.pos = m_ActivatorPosition == NiPoint3Constant::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition;
|
||||||
|
|
||||||
m_Activator = Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
SetActivator(Game::entityManager->CreateEntity(info, nullptr, m_Parent));
|
||||||
if (m_Activator) {
|
if (m_Activator) {
|
||||||
m_ActivatorId = m_Activator->GetObjectID();
|
m_ActivatorId = m_Activator->GetObjectID();
|
||||||
Game::entityManager->ConstructEntity(m_Activator);
|
Game::entityManager->ConstructEntity(m_Activator);
|
||||||
@ -277,7 +272,7 @@ void QuickBuildComponent::DespawnActivator() {
|
|||||||
|
|
||||||
m_Activator->ScheduleKillAfterUpdate();
|
m_Activator->ScheduleKillAfterUpdate();
|
||||||
|
|
||||||
m_Activator = nullptr;
|
SetActivator(nullptr);
|
||||||
|
|
||||||
m_ActivatorId = LWOOBJID_EMPTY;
|
m_ActivatorId = LWOOBJID_EMPTY;
|
||||||
}
|
}
|
||||||
@ -405,8 +400,7 @@ void QuickBuildComponent::StartQuickBuild(Entity* const user) {
|
|||||||
GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::BUILDING, user->GetObjectID());
|
GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::BUILDING, user->GetObjectID());
|
||||||
GameMessages::SendEnableQuickBuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
GameMessages::SendEnableQuickBuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||||
|
|
||||||
m_State = eQuickBuildState::BUILDING;
|
SetState(eQuickBuildState::BUILDING);
|
||||||
m_StateDirty = true;
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
|
|
||||||
auto* movingPlatform = m_Parent->GetComponent<MovingPlatformComponent>();
|
auto* movingPlatform = m_Parent->GetComponent<MovingPlatformComponent>();
|
||||||
@ -444,9 +438,8 @@ void QuickBuildComponent::CompleteQuickBuild(Entity* const user) {
|
|||||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||||
|
|
||||||
|
|
||||||
m_State = eQuickBuildState::COMPLETED;
|
SetState(eQuickBuildState::COMPLETED);
|
||||||
m_StateDirty = true;
|
SetTimer(0.0f);
|
||||||
m_Timer = 0.0f;
|
|
||||||
m_DrainedImagination = 0;
|
m_DrainedImagination = 0;
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
@ -526,11 +519,10 @@ void QuickBuildComponent::ResetQuickBuild(const bool failed) {
|
|||||||
|
|
||||||
GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::RESETTING, LWOOBJID_EMPTY);
|
GameMessages::SendQuickBuildNotifyState(m_Parent, m_State, eQuickBuildState::RESETTING, LWOOBJID_EMPTY);
|
||||||
|
|
||||||
m_State = eQuickBuildState::RESETTING;
|
SetState(eQuickBuildState::RESETTING);
|
||||||
m_StateDirty = true;
|
SetTimer(0.0f);
|
||||||
m_Timer = 0.0f;
|
SetIncompleteTimer(0.0f);
|
||||||
m_TimerIncomplete = 0.0f;
|
SetShowResetEffect(false);
|
||||||
m_ShowResetEffect = false;
|
|
||||||
m_DrainedImagination = 0;
|
m_DrainedImagination = 0;
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
@ -563,8 +555,7 @@ void QuickBuildComponent::CancelQuickBuild(Entity* const entity, const eQuickBui
|
|||||||
GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||||
|
|
||||||
// Now update the component itself
|
// Now update the component itself
|
||||||
m_State = eQuickBuildState::INCOMPLETE;
|
SetState(eQuickBuildState::INCOMPLETE);
|
||||||
m_StateDirty = true;
|
|
||||||
|
|
||||||
// Notify scripts and possible subscribers
|
// Notify scripts and possible subscribers
|
||||||
m_Parent->GetScript()->OnQuickBuildNotifyState(m_Parent, m_State);
|
m_Parent->GetScript()->OnQuickBuildNotifyState(m_Parent, m_State);
|
||||||
|
@ -218,6 +218,48 @@ public:
|
|||||||
* @param skipChecks whether or not to skip the check for the quickbuild not being completed
|
* @param skipChecks whether or not to skip the check for the quickbuild not being completed
|
||||||
*/
|
*/
|
||||||
void CancelQuickBuild(Entity* const builder, const eQuickBuildFailReason failReason, const bool skipChecks = false);
|
void CancelQuickBuild(Entity* const builder, const eQuickBuildFailReason failReason, const bool skipChecks = false);
|
||||||
|
|
||||||
|
void SetState(const eQuickBuildState state) {
|
||||||
|
if (m_State == state) return;
|
||||||
|
m_State = state;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetShowResetEffect(const bool value) {
|
||||||
|
if (m_ShowResetEffect == value) return;
|
||||||
|
m_ShowResetEffect = value;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetActivator(Entity* const activator) {
|
||||||
|
if (m_Activator == activator) return;
|
||||||
|
m_Activator = activator;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTimer(const float value) {
|
||||||
|
if (m_Timer == value) return;
|
||||||
|
m_Timer = value;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModifyTimer(const float value) {
|
||||||
|
if (value == 0.0f) return;
|
||||||
|
m_Timer += value;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetIncompleteTimer(const float value) {
|
||||||
|
if (m_TimerIncomplete == value) return;
|
||||||
|
m_TimerIncomplete = value;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModifyIncompleteTimer(const float value) {
|
||||||
|
if (value == 0.0f) return;
|
||||||
|
m_TimerIncomplete += value;
|
||||||
|
m_StateDirty = true;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Whether or not the quickbuild state has been changed since we last serialized it.
|
* Whether or not the quickbuild state has been changed since we last serialized it.
|
||||||
|
@ -843,8 +843,10 @@ void GameMessages::SendDieNoImplCode(Entity* entity, const LWOOBJID& killerID, c
|
|||||||
|
|
||||||
bitStream.Write(entity->GetObjectID());
|
bitStream.Write(entity->GetObjectID());
|
||||||
bitStream.Write(MessageType::Game::DIE);
|
bitStream.Write(MessageType::Game::DIE);
|
||||||
|
|
||||||
bitStream.Write(bClientDeath);
|
bitStream.Write(bClientDeath);
|
||||||
bitStream.Write(bSpawnLoot);
|
bitStream.Write(bSpawnLoot);
|
||||||
|
bitStream.Write<uint32_t>(deathType.size());
|
||||||
bitStream.Write(deathType);
|
bitStream.Write(deathType);
|
||||||
bitStream.Write(directionRelative_AngleXZ);
|
bitStream.Write(directionRelative_AngleXZ);
|
||||||
bitStream.Write(directionRelative_AngleY);
|
bitStream.Write(directionRelative_AngleY);
|
||||||
@ -854,7 +856,10 @@ void GameMessages::SendDieNoImplCode(Entity* entity, const LWOOBJID& killerID, c
|
|||||||
if (killType != eKillType::VIOLENT) bitStream.Write(killType);
|
if (killType != eKillType::VIOLENT) bitStream.Write(killType);
|
||||||
|
|
||||||
bitStream.Write(killerID);
|
bitStream.Write(killerID);
|
||||||
bitStream.Write(lootOwnerID);
|
bitStream.Write(lootOwnerID != LWOOBJID_EMPTY);
|
||||||
|
if (lootOwnerID != LWOOBJID_EMPTY) {
|
||||||
|
bitStream.Write(lootOwnerID);
|
||||||
|
}
|
||||||
|
|
||||||
SEND_PACKET_BROADCAST;
|
SEND_PACKET_BROADCAST;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user