mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-16 16:55:27 +00:00
refactor(entity): each component type has an allocator, as the client
DoObjectComponentLoad walks the client's load order and calls the type's allocator from a table, like ObjectLoader2, instead of one 76-case switch. Components with rules of their own have a static Allocator (the client's LWOxComponent::Allocator); the rest share a registry allocator. The load state moves to ObjectLoadState.h so the allocators can take it. Construction bytes are identical for all 15,962 LOTs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,13 @@
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
#include <ranges>
|
||||
#include "Entity.h"
|
||||
#include "ObjectLoadState.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "MountControlComponent.h"
|
||||
#include "PetCreatorComponent.h"
|
||||
#include "PlayerForcedMovementComponent.h"
|
||||
#include "PossessorComponent.h"
|
||||
|
||||
CharacterComponent::CharacterComponent(Entity* parent, const int32_t componentID, Character* character, const SystemAddress& systemAddress) : Component(parent, componentID) {
|
||||
m_Character = character;
|
||||
@@ -1076,3 +1083,20 @@ void CharacterComponent::SetUScore(int64_t uscore, uint32_t source) {
|
||||
if (const auto* character = m_Parent->GetCharacter()) EconomyLedger::RecordUScore(character->GetID(), uscore - m_Uscore, source);
|
||||
m_Uscore = uscore;
|
||||
}
|
||||
|
||||
void CharacterComponent::Allocator(Entity& entity, ObjectLoadState& state) {
|
||||
const auto characterID = state.GetComponentID(eReplicaComponentType::CHARACTER);
|
||||
if (characterID > 0 || entity.GetCharacter()) {
|
||||
// LWOCharacterComponent::Factory (0x0104db40): possession control, mount control, pet creator, level
|
||||
// progression and forced movement, then the character, all componentID -1
|
||||
entity.AddComponent<PossessorComponent>(-1);
|
||||
entity.AddComponent<MountControlComponent>(-1);
|
||||
entity.AddComponent<PetCreatorComponent>(-1);
|
||||
entity.AddComponent<LevelProgressionComponent>(-1);
|
||||
entity.AddComponent<PlayerForcedMovementComponent>(-1);
|
||||
|
||||
auto& systemAddress = entity.GetCharacter()->GetParentUser() ? entity.GetCharacter()->GetParentUser()->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS;
|
||||
entity.AddComponent<CharacterComponent>(-1, entity.GetCharacter(), systemAddress);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user