DarkflameServer/dGame/dComponents/ModuleAssemblyComponent.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.1 KiB
C++
Raw Normal View History

#include "ModuleAssemblyComponent.h"
2023-07-08 08:31:26 +00:00
#include "Entity.h"
ModuleAssemblyComponent::ModuleAssemblyComponent(Entity* parent) : Component(parent) {
m_SubKey = LWOOBJID_EMPTY;
m_UseOptionalParts = false;
}
void ModuleAssemblyComponent::SetAssemblyPartsLOTs(const std::u16string& value) {
2023-07-08 08:31:26 +00:00
m_AssemblyPartsLOTs = value;
std::replace(m_AssemblyPartsLOTs.begin(), m_AssemblyPartsLOTs.end(), u'+', u';');
// doesn't matter if we push back a ; or a +. The client splits on either of them.
// For congruency however, maintain one or the other.
m_AssemblyPartsLOTs.push_back(u';');
}
void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
2023-07-08 08:31:26 +00:00
if (!bIsInitialUpdate) return;
outBitStream->Write(bIsInitialUpdate);
2022-07-28 13:39:57 +00:00
2023-07-08 08:31:26 +00:00
outBitStream->Write(m_SubKey != LWOOBJID_EMPTY);
if (m_SubKey != LWOOBJID_EMPTY) outBitStream->Write(m_SubKey);
2022-07-28 13:39:57 +00:00
2023-07-08 08:31:26 +00:00
outBitStream->Write(m_UseOptionalParts);
2022-07-28 13:39:57 +00:00
2023-07-08 08:31:26 +00:00
outBitStream->Write<uint16_t>(m_AssemblyPartsLOTs.size());
for (const char16_t character : m_AssemblyPartsLOTs) {
outBitStream->Write(character);
}
}