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:
Aaron Kimbrell
2026-10-02 08:11:58 -05:00
parent 3a79286666
commit 260e6cb1b1
52 changed files with 634 additions and 684 deletions

View File

@@ -259,15 +259,104 @@ namespace {
for (size_t i = 0; i < types.size(); i++) order[i] = static_cast<eReplicaComponentType>(types[i]);
return order;
}();
// A component the client makes from its registry entry alone (most LWOxComponent::Allocator functions): ids from
// MinID up make one
template <typename ComponentType, eReplicaComponentType Type, int32_t MinID>
void RegistryAllocator(Entity& entity, ObjectLoadState& state) {
const auto id = state.GetComponentID(Type, -1);
if (id >= MinID) entity.AddComponent<ComponentType>(id);
}
// The allocator for each type DoObjectComponentLoad walks (the client's allocator table); a type with none makes
// nothing
const std::unordered_map<eReplicaComponentType, ComponentAllocator> ComponentAllocators{
{ eReplicaComponentType::POSSESSABLE, &RegistryAllocator<PossessableComponent, eReplicaComponentType::POSSESSABLE, 1> },
{ eReplicaComponentType::MODULE_ASSEMBLY, &RegistryAllocator<ModuleAssemblyComponent, eReplicaComponentType::MODULE_ASSEMBLY, 1> },
{ eReplicaComponentType::CONTROLLABLE_PHYSICS, &ControllablePhysicsComponent::Allocator },
{ eReplicaComponentType::HAVOK_VEHICLE_PHYSICS, &HavokVehiclePhysicsComponent::Allocator },
{ eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, &RegistryAllocator<RigidbodyPhantomPhysicsComponent, eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, 1> },
{ eReplicaComponentType::SIMPLE_PHYSICS, &SimplePhysicsComponent::Allocator },
{ eReplicaComponentType::PHANTOM_PHYSICS, &PhantomPhysicsComponent::Allocator },
{ eReplicaComponentType::DESTROYABLE, &DestroyableComponent::Allocator },
{ eReplicaComponentType::MINIFIG, &RegistryAllocator<MinifigComponent, eReplicaComponentType::MINIFIG, 1> },
{ eReplicaComponentType::CHARACTER, &CharacterComponent::Allocator },
{ eReplicaComponentType::PET, &PetComponent::Allocator },
{ eReplicaComponentType::INVENTORY, &InventoryComponent::Allocator },
{ eReplicaComponentType::PROXIMITY_MONITOR, &RegistryAllocator<ProximityMonitorComponent, eReplicaComponentType::PROXIMITY_MONITOR, 1> },
{ eReplicaComponentType::MOVEMENT_AI, &MovementAIComponent::Allocator },
{ eReplicaComponentType::SCRIPT, &ScriptComponent::Allocator },
{ eReplicaComponentType::SKILL, &SkillComponent::Allocator },
{ eReplicaComponentType::BASE_COMBAT_AI, &BaseCombatAIComponent::Allocator },
{ eReplicaComponentType::ITEM, &ItemComponent::Allocator },
{ eReplicaComponentType::BUILD_BORDER, &RegistryAllocator<BuildBorderComponent, eReplicaComponentType::BUILD_BORDER, 0> },
{ eReplicaComponentType::QUICK_BUILD, &QuickBuildComponent::Allocator },
{ eReplicaComponentType::MISSION_OFFER, &RegistryAllocator<MissionOfferComponent, eReplicaComponentType::MISSION_OFFER, 0> },
{ eReplicaComponentType::VENDOR, &VendorComponent::Allocator },
{ eReplicaComponentType::DONATION_VENDOR, &DonationVendorComponent::Allocator },
{ eReplicaComponentType::ACHIEVEMENT_VENDOR, &AchievementVendorComponent::Allocator },
{ eReplicaComponentType::SHOOTING_GALLERY, &RegistryAllocator<ShootingGalleryComponent, eReplicaComponentType::SHOOTING_GALLERY, 1> },
{ eReplicaComponentType::SCRIPTED_ACTIVITY, &RegistryAllocator<ScriptedActivityComponent, eReplicaComponentType::SCRIPTED_ACTIVITY, 0> },
{ eReplicaComponentType::COLLECTIBLE, &CollectibleComponent::Allocator },
{ eReplicaComponentType::MOVING_PLATFORM, &MovingPlatformComponent::Allocator },
{ eReplicaComponentType::LUP_EXHIBIT, &RegistryAllocator<LUPExhibitComponent, eReplicaComponentType::LUP_EXHIBIT, 0> },
{ eReplicaComponentType::PROPERTY, &RegistryAllocator<PropertyComponent, eReplicaComponentType::PROPERTY, 0> },
{ eReplicaComponentType::MODEL, &ModelComponent::Allocator },
{ eReplicaComponentType::PROPERTY_ENTRANCE, &RegistryAllocator<PropertyEntranceComponent, eReplicaComponentType::PROPERTY_ENTRANCE, 1> },
{ eReplicaComponentType::MULTI_ZONE_ENTRANCE, &RegistryAllocator<MultiZoneEntranceComponent, eReplicaComponentType::MULTI_ZONE_ENTRANCE, 0> }, // always id 0
{ eReplicaComponentType::PROPERTY_MANAGEMENT, &RegistryAllocator<PropertyManagementComponent, eReplicaComponentType::PROPERTY_MANAGEMENT, 0> },
{ eReplicaComponentType::RAIL_ACTIVATOR, &RegistryAllocator<RailActivatorComponent, eReplicaComponentType::RAIL_ACTIVATOR, 1> },
{ eReplicaComponentType::BOUNCER, &RegistryAllocator<BouncerComponent, eReplicaComponentType::BOUNCER, 0> }, // every bouncer's id is 0
{ eReplicaComponentType::SWITCH, &RegistryAllocator<SwitchComponent, eReplicaComponentType::SWITCH, 0> },
{ eReplicaComponentType::MINI_GAME_CONTROL, &RegistryAllocator<MiniGameControlComponent, eReplicaComponentType::MINI_GAME_CONTROL, 0> }, // the zone control object's id is 0
{ eReplicaComponentType::RENDER, &RenderComponent::Allocator },
{ eReplicaComponentType::SOUND_TRIGGER, &SoundTriggerComponent::Allocator },
{ eReplicaComponentType::PROPERTY_VENDOR, &RegistryAllocator<PropertyVendorComponent, eReplicaComponentType::PROPERTY_VENDOR, 0> },
{ eReplicaComponentType::ROCKET_LAUNCH, &RegistryAllocator<RocketLaunchpadControlComponent, eReplicaComponentType::ROCKET_LAUNCH, 1> },
{ eReplicaComponentType::RACING_CONTROL, &RegistryAllocator<RacingControlComponent, eReplicaComponentType::RACING_CONTROL, 1> },
{ eReplicaComponentType::SOUND_REPEATER, &RegistryAllocator<SoundRepeaterComponent, eReplicaComponentType::SOUND_REPEATER, 0> },
{ eReplicaComponentType::SOUND_AMBIENT_2D, &RegistryAllocator<SoundAmbient2DComponent, eReplicaComponentType::SOUND_AMBIENT_2D, 0> },
{ eReplicaComponentType::SOUND_AMBIENT_3D, &RegistryAllocator<SoundAmbient3DComponent, eReplicaComponentType::SOUND_AMBIENT_3D, 0> },
{ eReplicaComponentType::CULLING_PLANE, &RegistryAllocator<CullingPlaneComponent, eReplicaComponentType::CULLING_PLANE, 0> },
{ eReplicaComponentType::PLATFORM_BOUNDARY, &RegistryAllocator<PlatformBoundaryComponent, eReplicaComponentType::PLATFORM_BOUNDARY, 0> },
{ eReplicaComponentType::REBUILD, &RegistryAllocator<ModularBuildComponent, eReplicaComponentType::REBUILD, 0> },
{ eReplicaComponentType::REBUILD_START, &RegistryAllocator<BuildControllerComponent, eReplicaComponentType::REBUILD_START, 0> },
{ eReplicaComponentType::REBUILD_ACTIVATOR, &RegistryAllocator<RebuildActivatorComponent, eReplicaComponentType::REBUILD_ACTIVATOR, 0> },
{ eReplicaComponentType::CHEST, &RegistryAllocator<ChestComponent, eReplicaComponentType::CHEST, 0> },
{ eReplicaComponentType::BLUEPRINT, &RegistryAllocator<BlueprintComponent, eReplicaComponentType::BLUEPRINT, 0> },
{ eReplicaComponentType::MODULE, &RegistryAllocator<ModuleComponent, eReplicaComponentType::MODULE, 0> },
{ eReplicaComponentType::ARCADE, &RegistryAllocator<ArcadeComponent, eReplicaComponentType::ARCADE, 0> },
{ eReplicaComponentType::MODEL_BUILDER, &RegistryAllocator<ModelBuilderComponent, eReplicaComponentType::MODEL_BUILDER, 0> },
{ eReplicaComponentType::SPRINGPAD, &RegistryAllocator<SpringpadComponent, eReplicaComponentType::SPRINGPAD, 0> },
{ eReplicaComponentType::CHANGLING, &RegistryAllocator<ChangelingComponent, eReplicaComponentType::CHANGLING, 0> },
{ eReplicaComponentType::CHOICE_BUILD, &RegistryAllocator<ChoiceBuildComponent, eReplicaComponentType::CHOICE_BUILD, 0> },
{ eReplicaComponentType::PACKAGE, &RegistryAllocator<PackageComponent, eReplicaComponentType::PACKAGE, 0> },
{ eReplicaComponentType::CUSTOM_BUILD_ASSEMBLY, &RegistryAllocator<CustomBuildAssemblyComponent, eReplicaComponentType::CUSTOM_BUILD_ASSEMBLY, 0> },
{ eReplicaComponentType::SHOWCASE_MODEL_HANDLER, &RegistryAllocator<ShowcaseModelHandlerComponent, eReplicaComponentType::SHOWCASE_MODEL_HANDLER, 0> },
{ eReplicaComponentType::GENERIC_ACTIVATOR, &RegistryAllocator<GenericActivatorComponent, eReplicaComponentType::GENERIC_ACTIVATOR, 0> },
{ eReplicaComponentType::PROJECTILE_PHYSICS, &RegistryAllocator<ProjectilePhysicsComponent, eReplicaComponentType::PROJECTILE_PHYSICS, 0> },
{ eReplicaComponentType::VEHICLE_PHYSICS, &RegistryAllocator<VehiclePhysicsComponent, eReplicaComponentType::VEHICLE_PHYSICS, 0> },
{ eReplicaComponentType::PHYSICS_SYSTEM, &RegistryAllocator<PhysicsSystemComponent, eReplicaComponentType::PHYSICS_SYSTEM, 0> },
{ eReplicaComponentType::SPAWNER, &RegistryAllocator<SpawnerComponent, eReplicaComponentType::SPAWNER, 0> },
{ eReplicaComponentType::HF_LIGHT_DIRECTION_GADGET, &RegistryAllocator<HFLightDirectionGadgetComponent, eReplicaComponentType::HF_LIGHT_DIRECTION_GADGET, 0> },
{ eReplicaComponentType::PLAYER_FORCED_MOVEMENT, &PlayerForcedMovementComponent::Allocator },
{ eReplicaComponentType::EXHIBIT, &RegistryAllocator<ExhibitComponent, eReplicaComponentType::EXHIBIT, 0> }, // 1.10.64 makes nothing here (showcases were cut); it sends nothing, so unchanged clients are unaffected
{ eReplicaComponentType::BBB, &BBBComponent::Allocator },
{ eReplicaComponentType::ROCKET_LANDING, &RegistryAllocator<RocketLandingComponent, eReplicaComponentType::ROCKET_LANDING, 0> },
{ eReplicaComponentType::FACTION_TRIGGER, &RegistryAllocator<FactionTriggerComponent, eReplicaComponentType::FACTION_TRIGGER, 0> },
{ eReplicaComponentType::GATE_RUSH_CONTROL, &RegistryAllocator<GateRushComponent, eReplicaComponentType::GATE_RUSH_CONTROL, 0> },
{ eReplicaComponentType::ROLLER, &RegistryAllocator<RollerComponent, eReplicaComponentType::ROLLER, 0> },
{ eReplicaComponentType::PROPERTY_PLAQUE, &RegistryAllocator<PropertyPlaqueComponent, eReplicaComponentType::PROPERTY_PLAQUE, 0> },
};
}
int32_t Entity::ObjectLoadState::GetComponentID(const eReplicaComponentType type, const int32_t defaultValue) const {
int32_t ObjectLoadState::GetComponentID(const eReplicaComponentType type, const int32_t defaultValue) const {
if (whitelist && std::ranges::find(*whitelist, type) == whitelist->end()) return defaultValue;
return CDClientManager::GetTable<CDComponentsRegistryTable>()->GetByIDAndType(lot, type, defaultValue);
}
// ObjectLoader2::DoObjectPreLoad (0x01054d30): what the object's components will be before any is made
Entity::ObjectLoadState Entity::DoObjectPreLoad() {
ObjectLoadState Entity::DoObjectPreLoad() {
ObjectLoadState state;
state.lot = m_TemplateID;
@@ -307,678 +396,25 @@ Entity::ObjectLoadState Entity::DoObjectPreLoad() {
}
// ObjectLoader2::DoObjectComponentLoad (0x0105ebb0): the components in the client's order, then the ones it adds after
void ObjectLoadState::AddProximityAndPathfinding(Entity& entity) {
if (!entity.HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) entity.AddComponent<ProximityMonitorComponent>(-1);
const bool hasMovementPhysics = entity.HasComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS) || entity.HasComponent(eReplicaComponentType::PROJECTILE_PHYSICS)
|| entity.HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) || entity.HasComponent(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS);
if (hasMovementPhysics && !entity.HasComponent(eReplicaComponentType::PATHFINDING)) entity.AddComponent<PathfindingComponent>(-1);
}
void Entity::DoObjectComponentLoad(ObjectLoadState& state) {
/**
* The components in the client's load order (ObjectLoader2::DoObjectComponentLoad 0x0105ebb0 walks
* ComponentOrderVector::Initialize 0x0101f8e0's list): a component that looks at another one finds it made when the
* client's does. Ids a component needs from a later one come from the registry.
* ComponentOrderVector::Initialize 0x0101f8e0's list), each by its type's allocator: a component that looks at
* another one finds it made when the client's does. Ids a component needs from a later one come from the registry.
*/
const auto petComponentID = state.GetComponentID(eReplicaComponentType::PET);
const auto collectibleComponentID = state.GetComponentID(eReplicaComponentType::COLLECTIBLE);
const auto combatAiID = state.GetComponentID(eReplicaComponentType::BASE_COMBAT_AI);
// LWOScriptComponent::Allocator (0x0104d710) and LWOBaseCombatAiComponent::Allocator (0x0104c7b0) add a proximity
// monitor when there is none, and pathfinding control when the object has movement physics (controllable,
// projectile, vehicle or havok vehicle) and none yet
const auto addProximityAndPathfinding = [this]() {
if (!HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) AddComponent<ProximityMonitorComponent>(-1);
const bool hasMovementPhysics = HasComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS) || HasComponent(eReplicaComponentType::PROJECTILE_PHYSICS)
|| HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) || HasComponent(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS);
if (hasMovementPhysics && !HasComponent(eReplicaComponentType::PATHFINDING)) AddComponent<PathfindingComponent>(-1);
};
for (const auto type : ClientComponentLoadOrder) {
if (state.whitelist && std::ranges::find(*state.whitelist, type) == state.whitelist->end()) continue;
switch (type) {
case eReplicaComponentType::POSSESSABLE: {
const auto possessableComponentID = state.GetComponentID(eReplicaComponentType::POSSESSABLE);
if (possessableComponentID > 0) {
AddComponent<PossessableComponent>(possessableComponentID);
}
break;
}
case eReplicaComponentType::MODULE_ASSEMBLY: {
const auto moduleAssemblyID = state.GetComponentID(eReplicaComponentType::MODULE_ASSEMBLY);
if (moduleAssemblyID > 0) {
AddComponent<ModuleAssemblyComponent>(moduleAssemblyID);
}
break;
}
case eReplicaComponentType::CONTROLLABLE_PHYSICS: {
const auto controllablePhysicsComponentID = state.GetComponentID(eReplicaComponentType::CONTROLLABLE_PHYSICS);
if (state.hasModelBehaviors) {
// LWOControllablePhysComponent::Allocator (0x0104e070): left to the model case
if (controllablePhysicsComponentID > 0) state.modelPhysicsComponentID = controllablePhysicsComponentID;
} else if (controllablePhysicsComponentID > 0) {
// The component places it: where the level put an object, where a character's save and the zone put it
AddComponent<ControllablePhysicsComponent>(controllablePhysicsComponentID);
}
break;
}
case eReplicaComponentType::HAVOK_VEHICLE_PHYSICS: {
const auto havokVehiclePhysicsComponentID = state.GetComponentID(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS);
// The client makes simple physics instead for use_simple_physics, and none for objectWorldState 2
if (havokVehiclePhysicsComponentID > 0 && HasVar(u"use_simple_physics")) {
if (!HasComponent(eReplicaComponentType::SIMPLE_PHYSICS)) AddComponent<SimplePhysicsComponent>(havokVehiclePhysicsComponentID);
} else if (havokVehiclePhysicsComponentID > 0 && !(HasVar(u"objectWorldState") && GetVarAs<int32_t>(u"objectWorldState") == 2)) {
auto* havokVehiclePhysicsComponent = AddComponent<HavokVehiclePhysicsComponent>(havokVehiclePhysicsComponentID);
havokVehiclePhysicsComponent->SetPosition(m_DefaultPosition);
havokVehiclePhysicsComponent->SetRotation(m_DefaultRotation);
}
break;
}
case eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS: {
const auto rigidBodyPhantomPhysicsComponentID = state.GetComponentID(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS);
if (rigidBodyPhantomPhysicsComponentID > 0) {
AddComponent<RigidbodyPhantomPhysicsComponent>(rigidBodyPhantomPhysicsComponentID);
}
break;
}
case eReplicaComponentType::SIMPLE_PHYSICS: {
const auto simplePhysicsComponentID = state.GetComponentID(eReplicaComponentType::SIMPLE_PHYSICS);
if (state.hasModelBehaviors) {
// LWOSimplePhysicsComponent::Allocator (0x0104ded0): left to the model case
if (simplePhysicsComponentID > 0) state.modelPhysicsComponentID = simplePhysicsComponentID;
} else if (simplePhysicsComponentID > 0) {
// state.markedAsPhantom makes its simple physics phantom physics (with the simple physics row)
if (state.markedAsPhantom) AddComponent<PhantomPhysicsComponent>(simplePhysicsComponentID)->SetPhysicsEffectActive(false);
else AddComponent<SimplePhysicsComponent>(simplePhysicsComponentID);
}
break;
}
case eReplicaComponentType::PHANTOM_PHYSICS: {
const auto phantomPhysicsComponentID = state.GetComponentID(eReplicaComponentType::PHANTOM_PHYSICS);
if (state.hasModelBehaviors) {
// LWOPhantomPhysicsComponent::Allocator (0x010383b0): left to the model case
if (phantomPhysicsComponentID > 0) state.modelPhysicsComponentID = phantomPhysicsComponentID;
} else if (phantomPhysicsComponentID > 0 && !HasComponent(eReplicaComponentType::PHANTOM_PHYSICS)) {
AddComponent<PhantomPhysicsComponent>(phantomPhysicsComponentID)->SetPhysicsEffectActive(false);
}
break;
}
case eReplicaComponentType::DESTROYABLE: {
/**
* The destroyable component. The client makes one (with a buff component in front of it) for a DESTROYABLE
* registry entry, whose id is the DestructibleComponent row. Collectibles and smashable (is_smashable) objects
* without that entry get one too, with no row.
*/
const auto destroyableComponentID = state.GetComponentID(eReplicaComponentType::DESTROYABLE);
if (destroyableComponentID > 0) {
AddComponent<BuffComponent>(destroyableComponentID);
}
// A collectible's (right after it) and a smashable object's (after the walk) come later, as the client makes them
if (destroyableComponentID > 0) {
// The row, the level config and a character's save, in the client's order
AddComponent<DestroyableComponent>(destroyableComponentID);
}
break;
}
case eReplicaComponentType::MINIFIG: {
const auto minifigID = state.GetComponentID(eReplicaComponentType::MINIFIG);
if (minifigID > 0) AddComponent<MinifigComponent>(minifigID);
break;
}
case eReplicaComponentType::CHARACTER: {
const auto characterID = state.GetComponentID(eReplicaComponentType::CHARACTER);
if (characterID > 0 || m_Character) {
// LWOCharacterComponent::Factory (0x0104db40): possession control, mount control, pet creator, level
// progression and forced movement, then the character, all componentID -1
AddComponent<PossessorComponent>(-1);
AddComponent<MountControlComponent>(-1);
AddComponent<PetCreatorComponent>(-1);
AddComponent<LevelProgressionComponent>(-1);
AddComponent<PlayerForcedMovementComponent>(-1);
auto& systemAddress = m_Character->GetParentUser() ? m_Character->GetParentUser()->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS;
AddComponent<CharacterComponent>(-1, m_Character, systemAddress);
}
break;
}
case eReplicaComponentType::PET: {
// LWOPetComponent::Factory (0x01031240): no pet in an inventory; otherwise pathfinding control first
if (petComponentID > 0 && !GetVar<bool>(u"inInventory")) {
if (!HasComponent(eReplicaComponentType::PATHFINDING)) AddComponent<PathfindingComponent>(-1);
AddComponent<PetComponent>(petComponentID);
}
break;
}
case eReplicaComponentType::INVENTORY: {
const auto inventoryID = state.GetComponentID(eReplicaComponentType::INVENTORY);
if (inventoryID > 0 || m_Character) {
AddComponent<InventoryComponent>(inventoryID);
}
break;
}
case eReplicaComponentType::PROXIMITY_MONITOR: {
const auto proximityMonitorID = state.GetComponentID(eReplicaComponentType::PROXIMITY_MONITOR);
if (proximityMonitorID > 0) AddComponent<ProximityMonitorComponent>(proximityMonitorID);
break;
}
case eReplicaComponentType::MOVEMENT_AI: {
const int movementAIID = state.GetComponentID(eReplicaComponentType::MOVEMENT_AI);
if (movementAIID > 0) {
// Its row and the level's wanderRadius load in the component
AddComponent<MovementAIComponent>(movementAIID, MovementAIInfo{});
} else if (petComponentID > 0 || combatAiID > 0 && BaseCombatAIComponent::TetherSpeedOf(combatAiID) > 0) {
MovementAIInfo moveInfo{
.movementType = "",
.wanderRadius = 16,
.wanderSpeed = 2.5f,
.wanderChance = 0,
.wanderDelayMin = 2,
.wanderDelayMax = 5,
};
AddComponent<MovementAIComponent>(-1, moveInfo);
} else if (state.addsMovementAI) {
// ApplyMovementAiIfNeeded: a scripted object or one with an attached path has one (id 0: no row)
AddComponent<MovementAIComponent>(0, MovementAIInfo{});
}
break;
}
case eReplicaComponentType::SCRIPT: {
// LWOScriptComponent's allocator: a script component for a registry entry, a character, or a custom script in
// the level config; the component picks its script
CDScriptComponentTable* const scriptCompTable = CDClientManager::GetTable<CDScriptComponentTable>();
const int32_t scriptComponentID = state.GetComponentID(eReplicaComponentType::SCRIPT, -1);
const bool hasCustomScript = !GetVarAsString(u"custom_script_server").empty() || !GetVarAsString(u"custom_script_client").empty();
if (scriptComponentID >= 0 || m_Character || hasCustomScript) {
AddComponent<ScriptComponent>(scriptComponentID);
// The client's script allocator adds these only when it makes a script component: a registry script with a
// non-zero id or a custom script in the config it is sent (a character's script is the server's own)
const auto clientCustomScript = [this](const std::u16string& key) { return IsVarSentToClient(key) && !GetVarAsString(key).empty(); };
if (scriptComponentID > 0 || (m_TemplateID != 176 && (clientCustomScript(u"custom_script_server") || clientCustomScript(u"custom_script_client")))) {
addProximityAndPathfinding();
}
}
// ZoneControl script
if (m_TemplateID == 2365) {
const auto& zoneID = Game::zoneManager->GetZoneID();
const CDZoneTable* const zoneData = CDZoneTableTable::Query(zoneID.GetMapID());
if (zoneData != nullptr) {
const int32_t zoneScriptID = zoneData->scriptID;
CDScriptComponent zoneScriptData = scriptCompTable->GetByID(zoneScriptID);
// A server script only: the client has no script component on the zone control object (live sent none)
AddComponent<ScriptComponent>(zoneScriptID, zoneScriptData.script_name, false, false);
}
}
break;
}
case eReplicaComponentType::SKILL: {
const auto skillID = state.GetComponentID(eReplicaComponentType::SKILL, -1);
if (skillID > -1 || m_Character) {
AddComponent<SkillComponent>(skillID);
}
break;
}
case eReplicaComponentType::BASE_COMBAT_AI: {
if (combatAiID > 0) {
addProximityAndPathfinding();
AddComponent<BaseCombatAIComponent>(combatAiID);
}
break;
}
case eReplicaComponentType::ITEM: {
// A pet takes the item (and model) component away (LWOPetComponent::Factory); models keep theirs (live: an
// item block before the model's)
PetComponent* petComponent{};
const auto itemID = state.GetComponentID(eReplicaComponentType::ITEM);
if (itemID > 0 && !TryGetComponent(eReplicaComponentType::PET, petComponent)) {
AddComponent<ItemComponent>(itemID);
}
break;
}
case eReplicaComponentType::BUILD_BORDER: {
const auto buildBorderID = state.GetComponentID(eReplicaComponentType::BUILD_BORDER, -1);
if (buildBorderID > -1) {
AddComponent<BuildBorderComponent>(buildBorderID);
}
break;
}
case eReplicaComponentType::QUICK_BUILD: {
const auto quickBuildComponentID = state.GetComponentID(eReplicaComponentType::QUICK_BUILD);
if (quickBuildComponentID > 0) {
AddComponent<QuickBuildComponent>(quickBuildComponentID);
// A quick build without a destroyable gets one (componentID -1) and is smashable, as the client makes it
// (DoObjectComponentLoad); live: health 1 / 1.0, armor 1 / 0, faction -1, smashable (AG LOT 7804)
if (!HasComponent(eReplicaComponentType::DESTROYABLE)) {
AddComponent<DestroyableComponent>(-1, true);
}
}
break;
}
case eReplicaComponentType::MISSION_OFFER: {
const auto missionOfferComponentID = state.GetComponentID(eReplicaComponentType::MISSION_OFFER, -1);
if (missionOfferComponentID > -1) {
AddComponent<MissionOfferComponent>(missionOfferComponentID);
}
break;
}
case eReplicaComponentType::VENDOR: {
const auto vendorID = state.GetComponentID(eReplicaComponentType::VENDOR);
// The vendor allocators add a proximity monitor first when there is none
if (vendorID > 0) {
if (!HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) AddComponent<ProximityMonitorComponent>(-1);
AddComponent<VendorComponent>(vendorID);
}
break;
}
case eReplicaComponentType::DONATION_VENDOR: {
const auto donationVendorID = state.GetComponentID(eReplicaComponentType::DONATION_VENDOR, -1);
if (donationVendorID > -1) {
if (!HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) AddComponent<ProximityMonitorComponent>(-1);
AddComponent<DonationVendorComponent>(donationVendorID);
}
break;
}
case eReplicaComponentType::ACHIEVEMENT_VENDOR: {
const auto achievementVendorID = state.GetComponentID(eReplicaComponentType::ACHIEVEMENT_VENDOR, -1);
if (achievementVendorID > -1) {
if (!HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) AddComponent<ProximityMonitorComponent>(-1);
AddComponent<AchievementVendorComponent>(achievementVendorID);
}
break;
}
case eReplicaComponentType::SHOOTING_GALLERY: {
// Shooting gallery component
const auto shootingGalleryComponentID = state.GetComponentID(eReplicaComponentType::SHOOTING_GALLERY);
if (shootingGalleryComponentID > 0) {
AddComponent<ShootingGalleryComponent>(shootingGalleryComponentID);
}
break;
}
case eReplicaComponentType::SCRIPTED_ACTIVITY: {
// Scripted activity component
const auto scriptedActivityID = state.GetComponentID(eReplicaComponentType::SCRIPTED_ACTIVITY, -1);
if (scriptedActivityID > -1) {
AddComponent<ScriptedActivityComponent>(scriptedActivityID);
}
break;
}
case eReplicaComponentType::COLLECTIBLE: {
if (collectibleComponentID > 0) {
AddComponent<CollectibleComponent>(collectibleComponentID, GetVarAs<int32_t>(u"collectible_id"));
// The client makes a collectible's destroyable right after it when there is none
if (!HasComponent(eReplicaComponentType::DESTROYABLE)) AddComponent<DestroyableComponent>(-1);
}
break;
}
case eReplicaComponentType::MOVING_PLATFORM: {
const std::string pathName = GetVarAsString(u"attached_path");
const Path* const path = Game::zoneManager->GetZone()->GetPath(pathName);
//Check to see if we have an attached path and add the appropiate component to handle it:
if (path) {
// if we have a moving platform path, then we need a moving platform component
if (path->pathType == PathType::MovingPlatform) {
// The registry component ID picks the subcomponent (a simple mover when it has one), path or not
AddComponent<MovingPlatformComponent>(state.GetComponentID(eReplicaComponentType::MOVING_PLATFORM, -1), pathName);
} else if (path->pathType == PathType::Movement) {
auto* const movementAIcomponent = GetComponent<MovementAIComponent>();
if (movementAIcomponent && combatAiID == 0) {
movementAIcomponent->SetPath(pathName);
} else {
MovementAIInfo moveInfo{
.movementType = "",
.wanderRadius = 16,
.wanderSpeed = 2.5f,
.wanderChance = 0,
.wanderDelayMin = 2,
.wanderDelayMax = 5,
};
AddComponent<MovementAIComponent>(-1, moveInfo);
}
}
} else {
// else we still need to setup moving platform if it has a moving platform comp but no path
const auto movingPlatformComponentID = state.GetComponentID(eReplicaComponentType::MOVING_PLATFORM, -1);
if (movingPlatformComponentID >= 0) {
AddComponent<MovingPlatformComponent>(movingPlatformComponentID, pathName);
}
}
break;
}
case eReplicaComponentType::LUP_EXHIBIT: {
const auto lupExhibitID = state.GetComponentID(eReplicaComponentType::LUP_EXHIBIT, -1);
if (lupExhibitID >= 0) {
AddComponent<LUPExhibitComponent>(lupExhibitID);
}
break;
}
case eReplicaComponentType::PROPERTY: {
const auto propertyID = state.GetComponentID(eReplicaComponentType::PROPERTY, -1);
if (propertyID > -1) {
AddComponent<PropertyComponent>(propertyID);
}
break;
}
case eReplicaComponentType::MODEL: {
const auto modelID = state.GetComponentID(eReplicaComponentType::MODEL, -1);
if (modelID > -1 && !GetComponent<PetComponent>()) {
// ObjectLoader2::LoadModelBehaviorsComponent (0x0104d1f0): a model without physics gets it here (BBB models,
// LOT 14, have none in the registry): simple physics 4247 without behaviors; with behaviors controllable
// (4246) for modelType 0, else simple (4247), unless the registry gave an id. modelType 0 also gets
// pathfinding control.
const bool hasPhysics = HasComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS) || HasComponent(eReplicaComponentType::SIMPLE_PHYSICS)
|| HasComponent(eReplicaComponentType::PROJECTILE_PHYSICS) || HasComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS)
|| HasComponent(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS) || HasComponent(eReplicaComponentType::PHANTOM_PHYSICS)
|| HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) || HasComponent(eReplicaComponentType::PHYSICS_SYSTEM);
const int32_t modelType = HasVar(u"modelType") ? GetVarAs<int32_t>(u"modelType") : -1;
if (!hasPhysics) {
if (!state.hasModelBehaviors) AddComponent<SimplePhysicsComponent>(4247);
else if (modelType == 0) AddComponent<ControllablePhysicsComponent>(state.modelPhysicsComponentID == -1 ? 4246 : state.modelPhysicsComponentID);
else AddComponent<SimplePhysicsComponent>(state.modelPhysicsComponentID == -1 ? 4247 : state.modelPhysicsComponentID);
}
if (modelType == 0 && !HasComponent(eReplicaComponentType::PATHFINDING)) AddComponent<PathfindingComponent>(-1);
AddComponent<ModelComponent>(modelID);
if (!HasComponent(eReplicaComponentType::DESTROYABLE)) {
AddComponent<DestroyableComponent>(-1, true);
}
}
break;
}
case eReplicaComponentType::PROPERTY_ENTRANCE: {
const auto propertyEntranceComponentID = state.GetComponentID(eReplicaComponentType::PROPERTY_ENTRANCE);
if (propertyEntranceComponentID > 0) {
AddComponent<PropertyEntranceComponent>(propertyEntranceComponentID);
}
break;
}
case eReplicaComponentType::MULTI_ZONE_ENTRANCE: {
// if this component exists, then we initialize it. it's value is always 0
const auto multiZoneEntranceID = state.GetComponentID(eReplicaComponentType::MULTI_ZONE_ENTRANCE, -1);
if (multiZoneEntranceID > -1) {
AddComponent<MultiZoneEntranceComponent>(multiZoneEntranceID);
}
break;
}
case eReplicaComponentType::PROPERTY_MANAGEMENT: {
const auto propertyManagementID = state.GetComponentID(eReplicaComponentType::PROPERTY_MANAGEMENT, -1);
if (propertyManagementID > -1) {
AddComponent<PropertyManagementComponent>(propertyManagementID);
}
break;
}
case eReplicaComponentType::RAIL_ACTIVATOR: {
const auto railComponentID = state.GetComponentID(eReplicaComponentType::RAIL_ACTIVATOR);
if (railComponentID > 0) {
AddComponent<RailActivatorComponent>(railComponentID);
}
break;
}
case eReplicaComponentType::BOUNCER: {
const auto bouncerID = state.GetComponentID(eReplicaComponentType::BOUNCER, -1);
if (bouncerID > -1) { // you have to determine it like this because all bouncers have a componentID of 0
AddComponent<BouncerComponent>(bouncerID);
}
break;
}
case eReplicaComponentType::SWITCH: {
const auto switchID = state.GetComponentID(eReplicaComponentType::SWITCH, -1);
if (switchID > -1) {
AddComponent<SwitchComponent>(switchID);
}
break;
}
case eReplicaComponentType::MINI_GAME_CONTROL: {
// The client makes it from the registry (the zone control object's id is 0)
const auto minigameControlID = state.GetComponentID(eReplicaComponentType::MINI_GAME_CONTROL, -1);
if (minigameControlID > -1) {
AddComponent<MiniGameControlComponent>(minigameControlID);
}
break;
}
case eReplicaComponentType::RENDER: {
const auto renderComponentID = state.GetComponentID(eReplicaComponentType::RENDER);
if ((renderComponentID > 0 && m_TemplateID != 2365) || m_Character) {
AddComponent<RenderComponent>(renderComponentID);
}
break;
}
case eReplicaComponentType::SOUND_TRIGGER: {
const auto soundTriggerID = state.GetComponentID(eReplicaComponentType::SOUND_TRIGGER, -1);
const auto racingSoundTriggerID = state.GetComponentID(eReplicaComponentType::RACING_SOUND_TRIGGER, -1);
if (soundTriggerID > -1) {
AddComponent<SoundTriggerComponent>(soundTriggerID);
} else if (racingSoundTriggerID > -1) {
AddComponent<RacingSoundTriggerComponent>(racingSoundTriggerID);
}
break;
}
case eReplicaComponentType::PROPERTY_VENDOR: {
const auto propertyVendorID = state.GetComponentID(eReplicaComponentType::PROPERTY_VENDOR, -1);
if (propertyVendorID > -1) {
AddComponent<PropertyVendorComponent>(propertyVendorID);
}
break;
}
case eReplicaComponentType::ROCKET_LAUNCH: {
const auto rocketID = state.GetComponentID(eReplicaComponentType::ROCKET_LAUNCH);
if ((rocketID > 0)) {
AddComponent<RocketLaunchpadControlComponent>(rocketID);
}
break;
}
case eReplicaComponentType::RACING_CONTROL: {
const auto racingControlID = state.GetComponentID(eReplicaComponentType::RACING_CONTROL);
if (racingControlID > 0) {
AddComponent<RacingControlComponent>(racingControlID);
}
break;
}
case eReplicaComponentType::SOUND_REPEATER: {
// LWOSoundRepeaterComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::SOUND_REPEATER, -1);
if (id > -1) AddComponent<SoundRepeaterComponent>(id);
break;
}
case eReplicaComponentType::SOUND_AMBIENT_2D: {
// LWOSoundAmbient2DComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::SOUND_AMBIENT_2D, -1);
if (id > -1) AddComponent<SoundAmbient2DComponent>(id);
break;
}
case eReplicaComponentType::SOUND_AMBIENT_3D: {
// LWOSoundAmbient3DComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::SOUND_AMBIENT_3D, -1);
if (id > -1) AddComponent<SoundAmbient3DComponent>(id);
break;
}
case eReplicaComponentType::CULLING_PLANE: {
// LoadCullingPlaneComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::CULLING_PLANE, -1);
if (id > -1) AddComponent<CullingPlaneComponent>(id);
break;
}
case eReplicaComponentType::PLATFORM_BOUNDARY: {
// LWOPlatformBoundaryComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::PLATFORM_BOUNDARY, -1);
if (id > -1) AddComponent<PlatformBoundaryComponent>(id);
break;
}
case eReplicaComponentType::REBUILD: {
// LWOModularBuildComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::REBUILD, -1);
if (id > -1) AddComponent<ModularBuildComponent>(id);
break;
}
case eReplicaComponentType::REBUILD_START: {
// LWOBuildControllerComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::REBUILD_START, -1);
if (id > -1) AddComponent<BuildControllerComponent>(id);
break;
}
case eReplicaComponentType::REBUILD_ACTIVATOR: {
// LWORebuildActivatorComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::REBUILD_ACTIVATOR, -1);
if (id > -1) AddComponent<RebuildActivatorComponent>(id);
break;
}
case eReplicaComponentType::CHEST: {
// LWOChestComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::CHEST, -1);
if (id > -1) AddComponent<ChestComponent>(id);
break;
}
case eReplicaComponentType::BLUEPRINT: {
// LWOBlueprintComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::BLUEPRINT, -1);
if (id > -1) AddComponent<BlueprintComponent>(id);
break;
}
case eReplicaComponentType::MODULE: {
// LWOModuleComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::MODULE, -1);
if (id > -1) AddComponent<ModuleComponent>(id);
break;
}
case eReplicaComponentType::ARCADE: {
// LWOArcadeComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::ARCADE, -1);
if (id > -1) AddComponent<ArcadeComponent>(id);
break;
}
case eReplicaComponentType::MODEL_BUILDER: {
// LWOModelBuilderComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::MODEL_BUILDER, -1);
if (id > -1) AddComponent<ModelBuilderComponent>(id);
break;
}
case eReplicaComponentType::SPRINGPAD: {
// LWOSpringpadComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::SPRINGPAD, -1);
if (id > -1) AddComponent<SpringpadComponent>(id);
break;
}
case eReplicaComponentType::CHANGLING: {
// LWOChangelingComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::CHANGLING, -1);
if (id > -1) AddComponent<ChangelingComponent>(id);
break;
}
case eReplicaComponentType::CHOICE_BUILD: {
// LWOChoiceBuildComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::CHOICE_BUILD, -1);
if (id > -1) AddComponent<ChoiceBuildComponent>(id);
break;
}
case eReplicaComponentType::PACKAGE: {
// LWOPackageComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::PACKAGE, -1);
if (id > -1) AddComponent<PackageComponent>(id);
break;
}
case eReplicaComponentType::CUSTOM_BUILD_ASSEMBLY: {
// LWOCustomBuildAssemblyComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::CUSTOM_BUILD_ASSEMBLY, -1);
if (id > -1) AddComponent<CustomBuildAssemblyComponent>(id);
break;
}
case eReplicaComponentType::SHOWCASE_MODEL_HANDLER: {
// LWOShowcaseModelHandlerComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::SHOWCASE_MODEL_HANDLER, -1);
if (id > -1) AddComponent<ShowcaseModelHandlerComponent>(id);
break;
}
case eReplicaComponentType::GENERIC_ACTIVATOR: {
// LWOGenericActivatorComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::GENERIC_ACTIVATOR, -1);
if (id > -1) AddComponent<GenericActivatorComponent>(id);
break;
}
case eReplicaComponentType::PROJECTILE_PHYSICS: {
// LWOProjectilePhysicsComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::PROJECTILE_PHYSICS, -1);
if (id > -1) AddComponent<ProjectilePhysicsComponent>(id);
break;
}
case eReplicaComponentType::VEHICLE_PHYSICS: {
// LWOVehiclePhysicsComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::VEHICLE_PHYSICS, -1);
if (id > -1) AddComponent<VehiclePhysicsComponent>(id);
break;
}
case eReplicaComponentType::PHYSICS_SYSTEM: {
// The client's physics system component: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::PHYSICS_SYSTEM, -1);
if (id > -1) AddComponent<PhysicsSystemComponent>(id);
break;
}
case eReplicaComponentType::SPAWNER: {
// A spawner object's spawner component, from the registry as the client makes it
const auto id = state.GetComponentID(eReplicaComponentType::SPAWNER, -1);
if (id > -1) AddComponent<SpawnerComponent>(id);
break;
}
case eReplicaComponentType::HF_LIGHT_DIRECTION_GADGET: {
// The client makes it from the registry (an editor object)
const auto id = state.GetComponentID(eReplicaComponentType::HF_LIGHT_DIRECTION_GADGET, -1);
if (id > -1) AddComponent<HFLightDirectionGadgetComponent>(id);
break;
}
case eReplicaComponentType::PLAYER_FORCED_MOVEMENT: {
// From the registry, as the client makes it (a character got one with its character component)
const auto id = state.GetComponentID(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, -1);
if (id > -1 && !HasComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT)) AddComponent<PlayerForcedMovementComponent>(id);
break;
}
case eReplicaComponentType::EXHIBIT: {
// 1.10.64's loader has this case but makes nothing (dead code; showcases were cut); DLU makes the exhibit,
// which sends nothing in a construction, so unchanged clients are unaffected
const auto id = state.GetComponentID(eReplicaComponentType::EXHIBIT, -1);
if (id > -1) AddComponent<ExhibitComponent>(id);
break;
}
case eReplicaComponentType::BBB: {
// DoObjectPreLoad gives a character (LOT 1) one with id 0; any other object the registry's
const auto id = m_TemplateID == 1 ? 0 : state.GetComponentID(eReplicaComponentType::BBB, -1);
if (id > -1) AddComponent<BBBComponent>(id);
break;
}
case eReplicaComponentType::ROCKET_LANDING: {
// LWORocketAnimationControlComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::ROCKET_LANDING, -1);
if (id > -1) AddComponent<RocketLandingComponent>(id);
break;
}
case eReplicaComponentType::FACTION_TRIGGER: {
// LWOFactionTriggerComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::FACTION_TRIGGER, -1);
if (id > -1) AddComponent<FactionTriggerComponent>(id);
break;
}
case eReplicaComponentType::GATE_RUSH_CONTROL: {
// LWOGateRushComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::GATE_RUSH_CONTROL, -1);
if (id > -1) AddComponent<GateRushComponent>(id);
break;
}
case eReplicaComponentType::ROLLER: {
// LWORollerComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::ROLLER, -1);
if (id > -1) AddComponent<RollerComponent>(id);
break;
}
case eReplicaComponentType::PROPERTY_PLAQUE: {
// LoadPropertyPlaqueComponent: the client makes it from the registry
const auto id = state.GetComponentID(eReplicaComponentType::PROPERTY_PLAQUE, -1);
if (id > -1) AddComponent<PropertyPlaqueComponent>(id);
break;
}
default:
break;
}
const auto allocator = ComponentAllocators.find(type);
if (allocator != ComponentAllocators.end()) allocator->second(*this, state);
}
/**
* Added after the walk, as the client does (DoObjectComponentLoad): the ghost of a character (LWOGhostComponent's
* allocator 0x0101c010 makes one for characters with physics; level and plain spawned objects get none), then the

View File

@@ -16,6 +16,7 @@
#include "eKillType.h"
#include "Observable.h"
#include "Profiler.h"
#include "ObjectLoadState.h"
namespace GameMessages {
struct GameMsg;
@@ -397,24 +398,6 @@ public:
static Observable<Entity*, const PositionUpdate&> OnPlayerPositionUpdate;
private:
/**
* The client's ObjectLoadState (ObjectLoader2): the object's components as its registry gives them, after the
* pre-load rules and the component whitelist, and what the component walk has found so far
*/
struct ObjectLoadState {
LOT lot{};
// The config's componentWhitelist (ApplyComponentWhitelist): only these registry components, when set
const std::initializer_list<eReplicaComponentType>* whitelist = nullptr;
bool hasModelBehaviors = false;
bool markedAsPhantom = false;
// ApplyMovementAiIfNeeded: movement AI for a scripted object or one with an attached path
bool addsMovementAI = false;
// A model with behaviors' physics id, which the physics cases leave to the model case
int32_t modelPhysicsComponentID = -1;
// The registry's id for type, defaultValue when it has none or the whitelist drops it
int32_t GetComponentID(eReplicaComponentType type, int32_t defaultValue = 0) const;
};
// ObjectLoader2::DoObjectPreLoad: what the components will be, before any is made
ObjectLoadState DoObjectPreLoad();

40
dGame/ObjectLoadState.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef OBJECTLOADSTATE_H
#define OBJECTLOADSTATE_H
#include <cstdint>
#include <initializer_list>
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
class Entity;
/**
* The client's ObjectLoadState (ObjectLoader2): the object's components as its registry gives them, after the
* pre-load rules and the component whitelist, and what the component walk has found so far. Each component type's
* Allocator reads it.
*/
struct ObjectLoadState {
LOT lot{};
// The config's componentWhitelist (ApplyComponentWhitelist): only these registry components, when set
const std::initializer_list<eReplicaComponentType>* whitelist = nullptr;
bool hasModelBehaviors = false;
bool markedAsPhantom = false;
// ApplyMovementAiIfNeeded: movement AI for a scripted object or one with an attached path
bool addsMovementAI = false;
// A model with behaviors' physics id, which the physics cases leave to the model case
int32_t modelPhysicsComponentID = -1;
// The registry's id for type, defaultValue when it has none or the whitelist drops it
int32_t GetComponentID(eReplicaComponentType type, int32_t defaultValue = 0) const;
// LWOScriptComponent::Allocator (0x0104d710) and LWOBaseCombatAiComponent::Allocator (0x0104c7b0): a proximity
// monitor when there is none, and pathfinding control when the object has movement physics (controllable,
// projectile, vehicle or havok vehicle) and none yet
static void AddProximityAndPathfinding(Entity& entity);
};
// An allocator for a component type: makes the object's component(s) of that type (the client's LWOxComponent::Allocator)
using ComponentAllocator = void (*)(Entity& entity, ObjectLoadState& state);
#endif //!OBJECTLOADSTATE_H

View File

@@ -32,6 +32,7 @@
#include "StringifiedEnum.h"
#include "Amf3.h"
#include "EconomyLedger.h"
#include "ObjectLoadState.h"
QuickBuildComponent::QuickBuildComponent(Entity* const entity, const int32_t componentID) : ActivityComponent{ entity, componentID } {
RegisterMsg(&QuickBuildComponent::OnRequestUse);
@@ -779,3 +780,16 @@ bool QuickBuildComponent::OnGetObjectReportInfo(GameMessages::GetObjectReportInf
quickbuild.PushDebug<AMFStringValue>("Builder", "LWOOBJID") = std::to_string(m_Builder);
return true;
}
void QuickBuildComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto quickBuildComponentID = state.GetComponentID(eReplicaComponentType::QUICK_BUILD);
if (quickBuildComponentID > 0) {
entity.AddComponent<QuickBuildComponent>(quickBuildComponentID);
// A quick build without a destroyable gets one (componentID -1) and is smashable, as the client makes it
// (DoObjectComponentLoad); live: health 1 / 1.0, armor 1 / 0, faction -1, smashable (AG LOT 7804)
if (!entity.HasComponent(eReplicaComponentType::DESTROYABLE)) {
entity.AddComponent<DestroyableComponent>(-1, true);
}
}
}

View File

@@ -13,6 +13,8 @@
#include "eReplicaComponentType.h"
#include "eQuickBuildState.h"
struct ObjectLoadState;
class Entity;
enum class eQuickBuildFailReason : uint32_t;
@@ -25,6 +27,9 @@ class QuickBuildComponent final : public ActivityComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
QuickBuildComponent(Entity* const entity, const int32_t componentID);
void LoadDataFromTemplate() override;

View File

@@ -0,0 +1,9 @@
#include "BBBComponent.h"
#include "Entity.h"
#include "ObjectLoadState.h"
void BBBComponent::Allocator(Entity& entity, ObjectLoadState& state) {
// DoObjectPreLoad gives a character (LOT 1) one with id 0; any other object the registry's
const auto id = entity.GetLOT() == 1 ? 0 : state.GetComponentID(eReplicaComponentType::BBB, -1);
if (id > -1) entity.AddComponent<BBBComponent>(id);
}

View File

@@ -6,6 +6,8 @@
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
/**
* The BBB component (76), as the client's LWOBBBComponent: DoObjectPreLoad gives every character one (and the registry
* any object listing it). It sends whether there is a metadata source item, then the item's ID.
@@ -14,6 +16,9 @@ class BBBComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BBB;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
BBBComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
// LWOBBBComponent::Deserialize 0x00bd6690

View File

@@ -31,6 +31,7 @@
#include "dNavMesh.h"
#include "Amf3.h"
#include "dpCollisionFilter.h"
#include "ObjectLoadState.h"
namespace {
// The collision groups of players and enemies in PhysicsComponent
@@ -984,3 +985,10 @@ bool BaseCombatAIComponent::MsgGetObjectReportInfo(GameMessages::GetObjectReport
return true;
}
void BaseCombatAIComponent::Allocator(Entity& entity, ObjectLoadState& state) {
if (state.GetComponentID(eReplicaComponentType::BASE_COMBAT_AI) > 0) {
ObjectLoadState::AddProximityAndPathfinding(entity);
entity.AddComponent<BaseCombatAIComponent>(state.GetComponentID(eReplicaComponentType::BASE_COMBAT_AI));
}
}

View File

@@ -13,6 +13,8 @@
#include <vector>
#include <map>
struct ObjectLoadState;
class MovementAIComponent;
class Entity;
@@ -51,6 +53,9 @@ class BaseCombatAIComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BASE_COMBAT_AI;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
BaseCombatAIComponent(Entity* parentEntity, int32_t componentID);
void LoadDataFromTemplate() override;

View File

@@ -48,6 +48,8 @@ set(DGAME_DCOMPONENTS_SOURCES
"TriggerComponent.cpp"
"Physics/HavokVehiclePhysicsComponent.cpp"
"Vendor/BaseVendorComponent.cpp"
"Vendor/VendorComponent.cpp"
"BBBComponent.cpp"
"ScriptComponent.cpp"
)

View File

@@ -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);
}
}

View File

@@ -17,6 +17,8 @@
#include <optional>
#include <chrono>
struct ObjectLoadState;
enum class eGameActivity : uint32_t;
class Item;
@@ -45,6 +47,9 @@ class CharacterComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CHARACTER;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
CharacterComponent(Entity* parent, const int32_t componentID, Character* character, const SystemAddress& systemAddress);
~CharacterComponent() override;

View File

@@ -1,4 +1,6 @@
#include "PlayerForcedMovementComponent.h"
#include "Entity.h"
#include "ObjectLoadState.h"
PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
m_Parent = parent;
@@ -14,3 +16,9 @@ void PlayerForcedMovementComponent::Serialize(RakNet::BitStream& outBitStream, b
}
m_DirtyInfo = false;
}
void PlayerForcedMovementComponent::Allocator(Entity& entity, ObjectLoadState& state) {
// From the registry, as the client makes it (a character got one with its character component)
const auto id = state.GetComponentID(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, -1);
if (id > -1 && !entity.HasComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT)) entity.AddComponent<PlayerForcedMovementComponent>(id);
}

View File

@@ -4,6 +4,8 @@
#include "Component.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
/**
* Component that handles player forced movement
*
@@ -12,6 +14,9 @@ class PlayerForcedMovementComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PLAYER_FORCED_MOVEMENT;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
/**
* Constructor for this component
* @param parent parent that contains this component

View File

@@ -7,6 +7,9 @@
#include "CDCollectibleComponentTable.h"
#include "CDMissionsTable.h"
#include "eMissionState.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "DestroyableComponent.h"
CollectibleComponent::CollectibleComponent(Entity* parentEntity, const int32_t componentID, const int32_t collectibleId) :
Component(parentEntity, componentID), m_CollectibleId(collectibleId) {
@@ -66,3 +69,11 @@ bool CollectibleComponent::MsgGetObjectReportInfo(GameMessages::GetObjectReportI
cmptType.PushDebug<AMFBoolValue>("Has been collected") = collected;
return true;
}
void CollectibleComponent::Allocator(Entity& entity, ObjectLoadState& state) {
if (state.GetComponentID(eReplicaComponentType::COLLECTIBLE) > 0) {
entity.AddComponent<CollectibleComponent>(state.GetComponentID(eReplicaComponentType::COLLECTIBLE), entity.GetVarAs<int32_t>(u"collectible_id"));
// The client makes a collectible's destroyable right after it when there is none
if (!entity.HasComponent(eReplicaComponentType::DESTROYABLE)) entity.AddComponent<DestroyableComponent>(-1);
}
}

View File

@@ -4,9 +4,14 @@
#include "Component.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class CollectibleComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::COLLECTIBLE;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
CollectibleComponent(Entity* parentEntity, const int32_t componentID, const int32_t collectibleId);
void LoadDataFromTemplate() override;

View File

@@ -50,6 +50,8 @@
#include "CDComponentsRegistryTable.h"
#include "InventoryMessages.h"
#include "Entity.h"
#include "ObjectLoadState.h"
Implementation<bool, const Entity*> DestroyableComponent::IsEnemyImplentation;
Implementation<bool, const Entity*> DestroyableComponent::IsFriendImplentation;
@@ -1406,3 +1408,21 @@ void DestroyableComponent::Resurrect(Entity& entityRef) {
resurrect.bRezImmediately = false;
resurrect.Send(UNASSIGNED_SYSTEM_ADDRESS);
}
void DestroyableComponent::Allocator(Entity& entity, ObjectLoadState& state) {
/**
* The destroyable component. The client makes one (with a buff component in front of it) for a DESTROYABLE
* registry entry, whose id is the DestructibleComponent row. Collectibles and smashable (is_smashable) objects
* without that entry get one too, with no row.
*/
const auto destroyableComponentID = state.GetComponentID(eReplicaComponentType::DESTROYABLE);
if (destroyableComponentID > 0) {
entity.AddComponent<BuffComponent>(destroyableComponentID);
}
// A collectible's (right after it) and a smashable object's (after the walk) come later, as the client makes them
if (destroyableComponentID > 0) {
// The row, the level config and a character's save, in the client's order
entity.AddComponent<DestroyableComponent>(destroyableComponentID);
}
}

View File

@@ -10,6 +10,8 @@
#include "eReplicaComponentType.h"
#include "Implementation.h"
struct ObjectLoadState;
namespace GameMessages {
struct GetObjectReportInfo;
struct SetFaction;
@@ -44,6 +46,9 @@ class DestroyableComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
// smashableDefaults: a destroyable the loader adds to a model or quickbuild, with live's defaults and no row
DestroyableComponent(Entity* parentEntity, const int32_t componentID, const bool smashableDefaults = false);
~DestroyableComponent() override;

View File

@@ -60,6 +60,7 @@
#include "Amf3.h"
#include <ranges>
#include "ObjectLoadState.h"
namespace {
// The equipped-item entry for a player's item. Live wrote its bound state and its inventory; DLU keeps proxies in
@@ -2460,3 +2461,10 @@ bool InventoryComponent::CheckDeletionRestriction(const LWOOBJID itemId, const i
return true;
}
}
void InventoryComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto inventoryID = state.GetComponentID(eReplicaComponentType::INVENTORY);
if (inventoryID > 0 || entity.GetCharacter()) {
entity.AddComponent<InventoryComponent>(inventoryID);
}
}

View File

@@ -25,6 +25,8 @@
#include "Loot.h"
#include "LootMetrics.h"
struct ObjectLoadState;
class Entity;
class ItemSet;
@@ -99,6 +101,9 @@ public:
static constexpr uint32_t MaximumGroupCount = 50;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::INVENTORY;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
InventoryComponent(Entity* parent, const int32_t componentID);
void LoadDataFromTemplate() override;

View File

@@ -1,4 +1,7 @@
#include "ItemComponent.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "PetComponent.h"
void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
// Live wrote the user-generated-content info on every construction: the model's userModelID (a brick built model,
@@ -10,3 +13,13 @@ void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstructi
outBitStream.Write0(); // ug_description
}
}
void ItemComponent::Allocator(Entity& entity, ObjectLoadState& state) {
// A pet takes the item (and model) component away (LWOPetComponent::Factory); models keep theirs (live: an
// item block before the model's)
PetComponent* petComponent{};
const auto itemID = state.GetComponentID(eReplicaComponentType::ITEM);
if (itemID > 0 && !entity.TryGetComponent(eReplicaComponentType::PET, petComponent)) {
entity.AddComponent<ItemComponent>(itemID);
}
}

View File

@@ -4,10 +4,15 @@
#include "Component.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class ItemComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ITEM;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
ItemComponent(Entity* entity, const int32_t componentID) : Component(entity, componentID) {}
void Serialize(RakNet::BitStream& bitStream, bool isConstruction) override;

View File

@@ -18,6 +18,11 @@
#include "Database.h"
#include "DluAssert.h"
#include "ObjectMessages.h"
#include "ObjectLoadState.h"
#include "PetComponent.h"
#include "ControllablePhysicsComponent.h"
#include "DestroyableComponent.h"
#include "PathfindingComponent.h"
ModelComponent::ModelComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
m_OriginalPosition = m_Parent->GetDefaultPosition();
@@ -375,3 +380,28 @@ bool ModelComponent::OnGetObjectReportInfo(GameMessages::GetObjectReportInfo& re
return true;
}
void ModelComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto modelID = state.GetComponentID(eReplicaComponentType::MODEL, -1);
if (modelID > -1 && !entity.GetComponent<PetComponent>()) {
// ObjectLoader2::LoadModelBehaviorsComponent (0x0104d1f0): a model without physics gets it here (BBB models,
// LOT 14, have none in the registry): simple physics 4247 without behaviors; with behaviors controllable
// (4246) for modelType 0, else simple (4247), unless the registry gave an id. modelType 0 also gets
// pathfinding control.
const bool hasPhysics = entity.HasComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS) || entity.HasComponent(eReplicaComponentType::SIMPLE_PHYSICS)
|| entity.HasComponent(eReplicaComponentType::PROJECTILE_PHYSICS) || entity.HasComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS)
|| entity.HasComponent(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS) || entity.HasComponent(eReplicaComponentType::PHANTOM_PHYSICS)
|| entity.HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) || entity.HasComponent(eReplicaComponentType::PHYSICS_SYSTEM);
const int32_t modelType = entity.HasVar(u"modelType") ? entity.GetVarAs<int32_t>(u"modelType") : -1;
if (!hasPhysics) {
if (!state.hasModelBehaviors) entity.AddComponent<SimplePhysicsComponent>(4247);
else if (modelType == 0) entity.AddComponent<ControllablePhysicsComponent>(state.modelPhysicsComponentID == -1 ? 4246 : state.modelPhysicsComponentID);
else entity.AddComponent<SimplePhysicsComponent>(state.modelPhysicsComponentID == -1 ? 4247 : state.modelPhysicsComponentID);
}
if (modelType == 0 && !entity.HasComponent(eReplicaComponentType::PATHFINDING)) entity.AddComponent<PathfindingComponent>(-1);
entity.AddComponent<ModelComponent>(modelID);
if (!entity.HasComponent(eReplicaComponentType::DESTROYABLE)) {
entity.AddComponent<DestroyableComponent>(-1, true);
}
}
}

View File

@@ -16,6 +16,8 @@
#include "StripUiPosition.h"
#include "ObjectMessages.h"
struct ObjectLoadState;
class AddMessage;
class AMFArrayValue;
class BehaviorMessageBase;
@@ -29,6 +31,9 @@ class ModelComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MODEL;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
ModelComponent(Entity* parent, const int32_t componentID);
void LoadConfigData() override;

View File

@@ -28,6 +28,8 @@
#include "GeneralUtils.h"
#include "RenderComponent.h"
#include "InventoryComponent.h"
#include "Entity.h"
#include "ObjectLoadState.h"
namespace {
/**
@@ -732,3 +734,25 @@ float MovementAIComponent::GetGroundHeight(const NiPoint3& point) const {
if (dpWorld::IsLoaded()) return dpWorld::GetNavMesh()->GetHeightAtPoint(point);
return m_KnockbackStartHeight;
}
void MovementAIComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const int movementAIID = state.GetComponentID(eReplicaComponentType::MOVEMENT_AI);
if (movementAIID > 0) {
// Its row and the level's wanderRadius load in the component
entity.AddComponent<MovementAIComponent>(movementAIID, MovementAIInfo{});
} else if (state.GetComponentID(eReplicaComponentType::PET) > 0 || state.GetComponentID(eReplicaComponentType::BASE_COMBAT_AI) > 0 && BaseCombatAIComponent::TetherSpeedOf(state.GetComponentID(eReplicaComponentType::BASE_COMBAT_AI)) > 0) {
MovementAIInfo moveInfo{
.movementType = "",
.wanderRadius = 16,
.wanderSpeed = 2.5f,
.wanderChance = 0,
.wanderDelayMin = 2,
.wanderDelayMax = 5,
};
entity.AddComponent<MovementAIComponent>(-1, moveInfo);
} else if (state.addsMovementAI) {
// ApplyMovementAiIfNeeded: a scripted object or one with an attached path has one (id 0: no row)
entity.AddComponent<MovementAIComponent>(0, MovementAIInfo{});
}
}

View File

@@ -19,6 +19,8 @@
#include <optional>
#include <vector>
struct ObjectLoadState;
class ControllablePhysicsComponent;
class BaseCombatAIComponent;
@@ -64,6 +66,9 @@ class MovementAIComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
MovementAIComponent(Entity* parentEntity, const int32_t componentID, MovementAIInfo info);
void LoadDataFromTemplate() override;

View File

@@ -17,6 +17,9 @@
#include "MovementMessages.h"
#include <glm/gtc/quaternion.hpp>
#include "Entity.h"
#include "ObjectLoadState.h"
#include "MovementAIComponent.h"
void PlatformSubComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
outBitStream.Write<bool>(true);
@@ -598,3 +601,39 @@ void MovingPlatformComponent::FireArrivalHooks(const uint32_t index, const bool
if (atDesiredWaypoint) script->OnArrivedAtDesiredWaypoint(m_Parent, index);
if (atLastWaypoint) script->OnPlatformAtLastWaypoint(m_Parent);
}
void MovingPlatformComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const std::string pathName = entity.GetVarAsString(u"attached_path");
const Path* const path = Game::zoneManager->GetZone()->GetPath(pathName);
//Check to see if we have an attached path and add the appropiate component to handle it:
if (path) {
// if we have a moving platform path, then we need a moving platform component
if (path->pathType == PathType::MovingPlatform) {
// The registry component ID picks the subcomponent (a simple mover when it has one), path or not
entity.AddComponent<MovingPlatformComponent>(state.GetComponentID(eReplicaComponentType::MOVING_PLATFORM, -1), pathName);
} else if (path->pathType == PathType::Movement) {
auto* const movementAIcomponent = entity.GetComponent<MovementAIComponent>();
if (movementAIcomponent && state.GetComponentID(eReplicaComponentType::BASE_COMBAT_AI) == 0) {
movementAIcomponent->SetPath(pathName);
} else {
MovementAIInfo moveInfo{
.movementType = "",
.wanderRadius = 16,
.wanderSpeed = 2.5f,
.wanderChance = 0,
.wanderDelayMin = 2,
.wanderDelayMax = 5,
};
entity.AddComponent<MovementAIComponent>(-1, moveInfo);
}
}
} else {
// else we still need to setup moving platform if it has a moving platform comp but no path
const auto movingPlatformComponentID = state.GetComponentID(eReplicaComponentType::MOVING_PLATFORM, -1);
if (movingPlatformComponentID >= 0) {
entity.AddComponent<MovingPlatformComponent>(movingPlatformComponentID, pathName);
}
}
}

View File

@@ -20,6 +20,8 @@
#include "eMovementPlatformState.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class Path;
namespace GameMessages { struct PlatformResync; }
@@ -171,6 +173,9 @@ class MovingPlatformComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MOVING_PLATFORM;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
MovingPlatformComponent(Entity* parent, const int32_t componentID, const std::string& pathName);
void LoadDataFromTemplate() override;

View File

@@ -43,6 +43,9 @@
#include "dNavMesh.h"
#include "eGameActivity.h"
#include "eStateChangeType.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "PathfindingComponent.h"
std::unordered_map<LWOOBJID, LWOOBJID> PetComponent::currentActivities{};
std::unordered_map<LWOOBJID, LWOOBJID> PetComponent::activePets{};
@@ -1452,3 +1455,11 @@ void PetComponent::ApplyNameModeration(const bool approved) {
}
Game::entityManager->SerializeEntity(m_Parent);
}
void PetComponent::Allocator(Entity& entity, ObjectLoadState& state) {
// LWOPetComponent::Factory (0x01031240): no pet in an inventory; otherwise pathfinding control first
if (state.GetComponentID(eReplicaComponentType::PET) > 0 && !entity.GetVar<bool>(u"inInventory")) {
if (!entity.HasComponent(eReplicaComponentType::PATHFINDING)) entity.AddComponent<PathfindingComponent>(-1);
entity.AddComponent<PetComponent>(state.GetComponentID(eReplicaComponentType::PET));
}
}

View File

@@ -10,6 +10,8 @@
#include "CDPetComponentTable.h"
#include "eHelpType.h"
struct ObjectLoadState;
/**
* Represents an entity that is a pet. This pet can be tamed and consequently follows the tamer around, allowing it
* to dig for treasure and activate pet bouncers.
@@ -19,6 +21,9 @@ class PetComponent final : public Component
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PET;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
// Bits of the serialized pet status. State number N is bit 1 << (N - 1) (the client's StateNumToIndex,
// 0x00bd19b0); the meanings are what the live server sent (2014 packet captures) and what the client does with them.

View File

@@ -19,6 +19,7 @@
#include "eStateChangeType.h"
#include "StringifiedEnum.h"
#include "Amf3.h"
#include "ObjectLoadState.h"
ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity, const int32_t componentID) : PhysicsComponent(entity, componentID) {
RegisterMsg(&ControllablePhysicsComponent::OnGetObjectReportInfo);
@@ -460,3 +461,14 @@ bool ControllablePhysicsComponent::OnGetObjectReportInfo(GameMessages::GetObject
immunity.PushDebug<AMFBoolValue>("Immune to Stun Jump") = m_ImmuneToStunJumpCount != 0;
return true;
}
void ControllablePhysicsComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto controllablePhysicsComponentID = state.GetComponentID(eReplicaComponentType::CONTROLLABLE_PHYSICS);
if (state.hasModelBehaviors) {
// LWOControllablePhysComponent::Allocator (0x0104e070): left to the model case
if (controllablePhysicsComponentID > 0) state.modelPhysicsComponentID = controllablePhysicsComponentID;
} else if (controllablePhysicsComponentID > 0) {
// The component places it: where the level put an object, where a character's save and the zone put it
entity.AddComponent<ControllablePhysicsComponent>(controllablePhysicsComponentID);
}
}

View File

@@ -10,6 +10,8 @@
#include "dpCollisionChecks.h"
#include "eBubbleType.h"
struct ObjectLoadState;
namespace tinyxml2 {
class XMLDocument;
}
@@ -25,6 +27,9 @@ class ControllablePhysicsComponent : public PhysicsComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CONTROLLABLE_PHYSICS;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
ControllablePhysicsComponent(Entity* entity, const int32_t componentID);
void LoadConfigData() override;

View File

@@ -1,6 +1,9 @@
#include "HavokVehiclePhysicsComponent.h"
#include "EntityManager.h"
#include "Amf3.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "SimplePhysicsComponent.h"
HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent, const int32_t componentID) : PhysicsComponent(parent, componentID) {
RegisterMsg(&HavokVehiclePhysicsComponent::OnGetObjectReportInfo);
@@ -125,3 +128,15 @@ bool HavokVehiclePhysicsComponent::OnGetObjectReportInfo(GameMessages::GetObject
remoteInputInfo.PushDebug<AMFBoolValue>("Is Modified") = m_RemoteInputInfo.m_IsModified;
return true;
}
void HavokVehiclePhysicsComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto havokVehiclePhysicsComponentID = state.GetComponentID(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS);
// The client makes simple physics instead for use_simple_physics, and none for objectWorldState 2
if (havokVehiclePhysicsComponentID > 0 && entity.HasVar(u"use_simple_physics")) {
if (!entity.HasComponent(eReplicaComponentType::SIMPLE_PHYSICS)) entity.AddComponent<SimplePhysicsComponent>(havokVehiclePhysicsComponentID);
} else if (havokVehiclePhysicsComponentID > 0 && !(entity.HasVar(u"objectWorldState") && entity.GetVarAs<int32_t>(u"objectWorldState") == 2)) {
auto* havokVehiclePhysicsComponent = entity.AddComponent<HavokVehiclePhysicsComponent>(havokVehiclePhysicsComponentID);
havokVehiclePhysicsComponent->SetPosition(entity.GetDefaultPosition());
havokVehiclePhysicsComponent->SetRotation(entity.GetDefaultRotation());
}
}

View File

@@ -6,6 +6,8 @@
#include "eReplicaComponentType.h"
#include "PositionUpdate.h"
struct ObjectLoadState;
/**
* Physics component for vehicles.
*/
@@ -13,6 +15,9 @@ class HavokVehiclePhysicsComponent : public PhysicsComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::HAVOK_VEHICLE_PHYSICS;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
HavokVehiclePhysicsComponent(Entity* parentEntity, const int32_t componentID);
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;

View File

@@ -28,6 +28,7 @@
#include "dpEntity.h"
#include "dpShapeBox.h"
#include "dpShapeSphere.h"
#include "ObjectLoadState.h"
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent, const int32_t componentID) : PhysicsComponent(parent, componentID) {
RegisterMsg(&PhantomPhysicsComponent::OnGetObjectReportInfo);
@@ -293,3 +294,13 @@ bool PhantomPhysicsComponent::OnGetObjectReportInfo(GameMessages::GetObjectRepor
return true;
}
void PhantomPhysicsComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto phantomPhysicsComponentID = state.GetComponentID(eReplicaComponentType::PHANTOM_PHYSICS);
if (state.hasModelBehaviors) {
// LWOPhantomPhysicsComponent::Allocator (0x010383b0): left to the model case
if (phantomPhysicsComponentID > 0) state.modelPhysicsComponentID = phantomPhysicsComponentID;
} else if (phantomPhysicsComponentID > 0 && !entity.HasComponent(eReplicaComponentType::PHANTOM_PHYSICS)) {
entity.AddComponent<PhantomPhysicsComponent>(phantomPhysicsComponentID)->SetPhysicsEffectActive(false);
}
}

View File

@@ -12,6 +12,8 @@
#include "eReplicaComponentType.h"
#include "PhysicsComponent.h"
struct ObjectLoadState;
class Entity;
class dpEntity;
enum class ePhysicsEffectType : uint32_t ;
@@ -27,6 +29,9 @@ class PhantomPhysicsComponent final : public PhysicsComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
PhantomPhysicsComponent(Entity* parent, const int32_t componentID);
void LoadConfigData() override;

View File

@@ -14,6 +14,8 @@
#include "Entity.h"
#include "StringifiedEnum.h"
#include "Amf3.h"
#include "ObjectLoadState.h"
#include "PhantomPhysicsComponent.h"
SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, const int32_t componentID) : PhysicsComponent(parent, componentID) {
RegisterMsg(&SimplePhysicsComponent::OnGetObjectReportInfo);
@@ -97,3 +99,15 @@ bool SimplePhysicsComponent::OnGetObjectReportInfo(GameMessages::GetObjectReport
info.PushDebug<AMFStringValue>("Climbable Type") = StringifiedEnum::ToString(m_ClimbableType).data();
return true;
}
void SimplePhysicsComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto simplePhysicsComponentID = state.GetComponentID(eReplicaComponentType::SIMPLE_PHYSICS);
if (state.hasModelBehaviors) {
// LWOSimplePhysicsComponent::Allocator (0x0104ded0): left to the model case
if (simplePhysicsComponentID > 0) state.modelPhysicsComponentID = simplePhysicsComponentID;
} else if (simplePhysicsComponentID > 0) {
// state.markedAsPhantom makes its simple physics phantom physics (with the simple physics row)
if (state.markedAsPhantom) entity.AddComponent<PhantomPhysicsComponent>(simplePhysicsComponentID)->SetPhysicsEffectActive(false);
else entity.AddComponent<SimplePhysicsComponent>(simplePhysicsComponentID);
}
}

View File

@@ -13,6 +13,8 @@
#include "PhysicsComponent.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class Entity;
enum class eClimbableType : int32_t {
@@ -30,6 +32,9 @@ class SimplePhysicsComponent : public PhysicsComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
// Havok motion types the client reads as the physics motion state
static constexpr uint32_t MOTION_TYPE_DYNAMIC = 1;
static constexpr uint32_t MOTION_TYPE_KEYFRAMED = 4;

View File

@@ -14,6 +14,7 @@
#include "Game.h"
#include "Logger.h"
#include "CDAnimationsTable.h"
#include "ObjectLoadState.h"
std::unordered_map<int32_t, float> RenderComponent::m_DurationCache{};
@@ -194,3 +195,10 @@ float RenderComponent::DoAnimation(Entity* self, const std::string& animation, b
if (returnlength == 0.0f) LOG("WARNING: Unable to find animation %s for lot %i in any group.", animation.c_str(), self->GetLOT());
return returnlength;
}
void RenderComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto renderComponentID = state.GetComponentID(eReplicaComponentType::RENDER);
if ((renderComponentID > 0 && entity.GetLOT() != 2365) || entity.GetCharacter()) {
entity.AddComponent<RenderComponent>(renderComponentID);
}
}

View File

@@ -10,6 +10,8 @@
#include "Component.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class Entity;
/**
@@ -63,6 +65,9 @@ class RenderComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RENDER;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
RenderComponent(Entity* const parentEntity, const int32_t componentID);
void LoadDataFromTemplate() override;

View File

@@ -11,6 +11,9 @@
#include "Amf3.h"
#include <ranges>
#include "ObjectLoadState.h"
#include "dZoneManager.h"
#include "CDZoneTableTable.h"
ScriptComponent::ScriptComponent(Entity* parent, const int32_t componentID, const std::string& scriptName, bool serialized, bool client) : Component(parent, componentID) {
m_Serialized = serialized;
@@ -109,3 +112,33 @@ bool ScriptComponent::OnGetObjectReportInfo(GameMessages::GetObjectReportInfo& r
return true;
}
void ScriptComponent::Allocator(Entity& entity, ObjectLoadState& state) {
// LWOScriptComponent's allocator: a script component for a registry entry, a character, or a custom script in
// the level config; the component picks its script
CDScriptComponentTable* const scriptCompTable = CDClientManager::GetTable<CDScriptComponentTable>();
const int32_t scriptComponentID = state.GetComponentID(eReplicaComponentType::SCRIPT, -1);
const bool hasCustomScript = !entity.GetVarAsString(u"custom_script_server").empty() || !entity.GetVarAsString(u"custom_script_client").empty();
if (scriptComponentID >= 0 || entity.GetCharacter() || hasCustomScript) {
entity.AddComponent<ScriptComponent>(scriptComponentID);
// The client's script allocator adds these only when it makes a script component: a registry script with a
// non-zero id or a custom script in the config it is sent (a character's script is the server's own)
const auto clientCustomScript = [&entity](const std::u16string& key) { return entity.IsVarSentToClient(key) && !entity.GetVarAsString(key).empty(); };
if (scriptComponentID > 0 || (entity.GetLOT() != 176 && (clientCustomScript(u"custom_script_server") || clientCustomScript(u"custom_script_client")))) {
ObjectLoadState::AddProximityAndPathfinding(entity);
}
}
// ZoneControl script
if (entity.GetLOT() == 2365) {
const auto& zoneID = Game::zoneManager->GetZoneID();
const CDZoneTable* const zoneData = CDZoneTableTable::Query(zoneID.GetMapID());
if (zoneData != nullptr) {
const int32_t zoneScriptID = zoneData->scriptID;
CDScriptComponent zoneScriptData = scriptCompTable->GetByID(zoneScriptID);
// A server script only: the client has no script component on the zone control object (live sent none)
entity.AddComponent<ScriptComponent>(zoneScriptID, zoneScriptData.script_name, false, false);
}
}
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class Entity;
/**
@@ -24,6 +26,9 @@ class ScriptComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
ScriptComponent(Entity* parent, const int32_t componentID, const std::string& scriptName, bool serialized, bool client = false);
// One the object's registry or level config gives (LWOScriptComponent's allocator): its script comes from the

View File

@@ -26,6 +26,8 @@
#include "CDSkillBehaviorTable.h"
#include "ServiceType.h"
#include "MessageType/Client.h"
#include "Entity.h"
#include "ObjectLoadState.h"
ProjectileSyncEntry::ProjectileSyncEntry() {
}
@@ -565,3 +567,10 @@ void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialU
uint32_t SkillComponent::GetUniqueSkillId() {
return ++this->m_skillUid;
}
void SkillComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto skillID = state.GetComponentID(eReplicaComponentType::SKILL, -1);
if (skillID > -1 || entity.GetCharacter()) {
entity.AddComponent<SkillComponent>(skillID);
}
}

View File

@@ -15,6 +15,8 @@
#include "Logger.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
struct ProjectileSyncEntry {
LWOOBJID id = LWOOBJID_EMPTY;
@@ -63,6 +65,9 @@ class SkillComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SKILL;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
explicit SkillComponent(Entity* parent, const int32_t componentID);
~SkillComponent() override;

View File

@@ -1,6 +1,9 @@
#include "SoundTriggerComponent.h"
#include "Game.h"
#include "Logger.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "RacingSoundTriggerComponent.h"
void MusicCue::Serialize(RakNet::BitStream& outBitStream){
outBitStream.Write<uint8_t>(name.size());
@@ -115,3 +118,13 @@ void SoundTriggerComponent::DeactivateMusicCue(const std::string& name) {
Game::entityManager->SerializeEntity(m_Parent);
}
}
void SoundTriggerComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto soundTriggerID = state.GetComponentID(eReplicaComponentType::SOUND_TRIGGER, -1);
const auto racingSoundTriggerID = state.GetComponentID(eReplicaComponentType::RACING_SOUND_TRIGGER, -1);
if (soundTriggerID > -1) {
entity.AddComponent<SoundTriggerComponent>(soundTriggerID);
} else if (racingSoundTriggerID > -1) {
entity.AddComponent<RacingSoundTriggerComponent>(racingSoundTriggerID);
}
}

View File

@@ -6,6 +6,8 @@
#include "Component.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
struct MusicCue {
std::string name;
uint32_t result;
@@ -60,6 +62,9 @@ struct MixerProgram {
class SoundTriggerComponent : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
explicit SoundTriggerComponent(Entity* parent, const int32_t componentID);
void LoadConfigData() override;

View File

@@ -8,6 +8,9 @@
#include "CheatDetection.h"
#include "UserManager.h"
#include "CDMissionsTable.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "ProximityMonitorComponent.h"
AchievementVendorComponent::AchievementVendorComponent(Entity* parent, const int32_t componentID) : BaseVendorComponent(parent, componentID) {
}
@@ -83,3 +86,11 @@ void AchievementVendorComponent::RefreshInventory(bool isCreation) {
SetHasStandardCostItems(true);
Game::entityManager->SerializeEntity(m_Parent);
}
void AchievementVendorComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto achievementVendorID = state.GetComponentID(eReplicaComponentType::ACHIEVEMENT_VENDOR, -1);
if (achievementVendorID > -1) {
if (!entity.HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) entity.AddComponent<ProximityMonitorComponent>(-1);
entity.AddComponent<AchievementVendorComponent>(achievementVendorID);
}
}

View File

@@ -6,11 +6,16 @@
#include <set>
#include <map>
struct ObjectLoadState;
class Entity;
class AchievementVendorComponent final : public BaseVendorComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
AchievementVendorComponent(Entity* parent, const int32_t componentID);
void LoadDataFromTemplate() override;

View File

@@ -13,6 +13,9 @@
#include "MissionComponent.h"
#include "User.h"
#include "UserManager.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "ProximityMonitorComponent.h"
DonationVendorComponent::DonationVendorComponent(Entity* parent, const int32_t componentID) : BaseVendorComponent(parent, componentID) {
}
@@ -108,3 +111,11 @@ void DonationVendorComponent::ConfirmDonation(Entity& player) {
}
characterComponent->SetCurrentInteracting(LWOOBJID_EMPTY);
}
void DonationVendorComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto donationVendorID = state.GetComponentID(eReplicaComponentType::DONATION_VENDOR, -1);
if (donationVendorID > -1) {
if (!entity.HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) entity.AddComponent<ProximityMonitorComponent>(-1);
entity.AddComponent<DonationVendorComponent>(donationVendorID);
}
}

View File

@@ -4,11 +4,16 @@
#include "BaseVendorComponent.h"
#include "eReplicaComponentType.h"
struct ObjectLoadState;
class Entity;
class DonationVendorComponent final : public BaseVendorComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
DonationVendorComponent(Entity* parent, const int32_t componentID);
void LoadConfigData() override;

View File

@@ -0,0 +1,13 @@
#include "VendorComponent.h"
#include "Entity.h"
#include "ObjectLoadState.h"
#include "ProximityMonitorComponent.h"
void VendorComponent::Allocator(Entity& entity, ObjectLoadState& state) {
const auto vendorID = state.GetComponentID(eReplicaComponentType::VENDOR);
// The vendor allocators add a proximity monitor first when there is none
if (vendorID > 0) {
if (!entity.HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) entity.AddComponent<ProximityMonitorComponent>(-1);
entity.AddComponent<VendorComponent>(vendorID);
}
}

View File

@@ -3,6 +3,8 @@
#include "BaseVendorComponent.h"
struct ObjectLoadState;
/**
* A vendor (16), as the client's LWOVendorComponent: a BaseVendorComponent.
*/
@@ -10,6 +12,9 @@ class VendorComponent final : public BaseVendorComponent {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR;
// The client's allocator for this type (ObjectLoader2::DoObjectComponentLoad calls it in load order)
static void Allocator(Entity& entity, ObjectLoadState& state);
VendorComponent(Entity* parent, const int32_t componentID) : BaseVendorComponent(parent, componentID) {}
};