mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 23:47:21 +00:00
ModuleAssemblyComponent pass
This commit is contained in:
parent
5301346ed5
commit
28fbe20b97
@ -1,70 +1,31 @@
|
|||||||
#include "ModuleAssemblyComponent.h"
|
#include "ModuleAssemblyComponent.h"
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
|
||||||
ModuleAssemblyComponent::ModuleAssemblyComponent(Entity* parent) : Component(parent) {
|
ModuleAssemblyComponent::ModuleAssemblyComponent(Entity* parent) : Component(parent) {
|
||||||
m_SubKey = LWOOBJID_EMPTY;
|
m_SubKey = LWOOBJID_EMPTY;
|
||||||
m_UseOptionalParts = false;
|
m_UseOptionalParts = false;
|
||||||
m_AssemblyPartsLOTs = u"";
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleAssemblyComponent::~ModuleAssemblyComponent() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleAssemblyComponent::SetSubKey(LWOOBJID value) {
|
|
||||||
m_SubKey = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
LWOOBJID ModuleAssemblyComponent::GetSubKey() const {
|
|
||||||
return m_SubKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleAssemblyComponent::SetUseOptionalParts(bool value) {
|
|
||||||
m_UseOptionalParts = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModuleAssemblyComponent::GetUseOptionalParts() const {
|
|
||||||
return m_UseOptionalParts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleAssemblyComponent::SetAssemblyPartsLOTs(const std::u16string& value) {
|
void ModuleAssemblyComponent::SetAssemblyPartsLOTs(const std::u16string& value) {
|
||||||
std::u16string val{};
|
m_AssemblyPartsLOTs = value;
|
||||||
|
std::replace(m_AssemblyPartsLOTs.begin(), m_AssemblyPartsLOTs.end(), u'+', u';');
|
||||||
val.reserve(value.size() + 1);
|
// 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.
|
||||||
for (auto character : value) {
|
m_AssemblyPartsLOTs.push_back(u';');
|
||||||
if (character == '+') character = ';';
|
|
||||||
|
|
||||||
val.push_back(character);
|
|
||||||
}
|
|
||||||
|
|
||||||
val.push_back(';');
|
|
||||||
|
|
||||||
m_AssemblyPartsLOTs = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::u16string& ModuleAssemblyComponent::GetAssemblyPartsLOTs() const {
|
|
||||||
return m_AssemblyPartsLOTs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
if (bIsInitialUpdate) {
|
if (!bIsInitialUpdate) return;
|
||||||
outBitStream->Write1();
|
outBitStream->Write(bIsInitialUpdate);
|
||||||
|
|
||||||
outBitStream->Write(m_SubKey != LWOOBJID_EMPTY);
|
outBitStream->Write(m_SubKey != LWOOBJID_EMPTY);
|
||||||
if (m_SubKey != LWOOBJID_EMPTY) {
|
if (m_SubKey != LWOOBJID_EMPTY) outBitStream->Write(m_SubKey);
|
||||||
outBitStream->Write(m_SubKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
outBitStream->Write(m_UseOptionalParts);
|
outBitStream->Write(m_UseOptionalParts);
|
||||||
|
|
||||||
outBitStream->Write(static_cast<uint16_t>(m_AssemblyPartsLOTs.size()));
|
outBitStream->Write<uint16_t>(m_AssemblyPartsLOTs.size());
|
||||||
for (char16_t character : m_AssemblyPartsLOTs) {
|
for (const char16_t character : m_AssemblyPartsLOTs) {
|
||||||
outBitStream->Write(character);
|
outBitStream->Write(character);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleAssemblyComponent::Update(float deltaTime) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
#ifndef __MODULEASSEMBLYCOMPONENT__H__
|
||||||
|
#define __MODULEASSEMBLYCOMPONENT__H__
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BitStream.h"
|
|
||||||
#include "Entity.h"
|
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
|
||||||
|
namespace RakNet {
|
||||||
|
class BitStream;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that belongs to an object that may be modularly built, like cars and rockets. Note that this is not the
|
* Component that belongs to an object that may be modularly built, like cars and rockets. Note that this is not the
|
||||||
* same as having said items in your inventory (the subkey for this component) this component is the one that
|
* same as having said items in your inventory (the subkey for this component) this component is the one that
|
||||||
@ -15,35 +20,32 @@ public:
|
|||||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MODULE_ASSEMBLY;
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MODULE_ASSEMBLY;
|
||||||
|
|
||||||
ModuleAssemblyComponent(Entity* parent);
|
ModuleAssemblyComponent(Entity* parent);
|
||||||
~ModuleAssemblyComponent() override;
|
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
void Update(float deltaTime) override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the subkey of this entity
|
* Sets the subkey of this entity
|
||||||
* @param value the subkey to set
|
* @param value the subkey to set
|
||||||
*/
|
*/
|
||||||
void SetSubKey(LWOOBJID value);
|
void SetSubKey(const LWOOBJID& value) { m_SubKey = value; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the subkey for this entity
|
* Returns the subkey for this entity
|
||||||
* @return the subkey for this entity
|
* @return the subkey for this entity
|
||||||
*/
|
*/
|
||||||
LWOOBJID GetSubKey() const;
|
LWOOBJID GetSubKey() const { return m_SubKey; };
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the optional parts value
|
* Sets the optional parts value
|
||||||
* @param value the value to set
|
* @param value the value to set
|
||||||
*/
|
*/
|
||||||
void SetUseOptionalParts(bool value);
|
void SetUseOptionalParts(bool value) { m_UseOptionalParts = value; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the optional parts value
|
* Returns the optional parts value
|
||||||
* @return the value to set
|
* @return the value to set
|
||||||
*/
|
*/
|
||||||
bool GetUseOptionalParts() const;
|
bool GetUseOptionalParts() const { return m_UseOptionalParts; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the assembly part lots (the subsections of this modular build)
|
* Sets the assembly part lots (the subsections of this modular build)
|
||||||
@ -55,7 +57,7 @@ public:
|
|||||||
* Returns the assembly part lots (the subsections of this modular build)
|
* Returns the assembly part lots (the subsections of this modular build)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
const std::u16string& GetAssemblyPartsLOTs() const;
|
const std::u16string& GetAssemblyPartsLOTs() const { return m_AssemblyPartsLOTs; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -75,3 +77,5 @@ private:
|
|||||||
*/
|
*/
|
||||||
std::u16string m_AssemblyPartsLOTs;
|
std::u16string m_AssemblyPartsLOTs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //!__MODULEASSEMBLYCOMPONENT__H__
|
||||||
|
Loading…
Reference in New Issue
Block a user