feat(entity): the object's interaction distance, preconditions and world state, as the client

LWOGameObject loads these itself: interactionDistance from its Objects row
(16 without one) and the level's interaction_distance over it,
CheckPrecondition and objectWorldState from the level config, before its
components load theirs. The quickbuild, the pet and the race instancer read
them from the object; the race instancer now uses the Objects row's
distance like the client does, instead of a fixed 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-02 08:44:53 -05:00
parent 0c215de446
commit 6f4fd4054a
10 changed files with 47 additions and 7 deletions

View File

@@ -370,6 +370,18 @@ public:
// Scale will only be communicated to the client when the construction packet is sent
void SetScale(const float scale) { m_Scale = scale; };
// How close a player must be to use the object (LWOGameObject::interactionDistance): the Objects row's, else 16,
// over which the level's interaction_distance goes
float GetInteractionDistance() const { return m_InteractionDistance; }
// The precondition expression for using the object (LWOGameObject::CheckPrecondition), from the level config
const std::u16string& GetCheckPrecondition() const { return m_CheckPrecondition; }
// The client's SetPreconditions message
void SetCheckPrecondition(const std::u16string& precondition) { m_CheckPrecondition = precondition; }
// The object's world state (LWOGameObject::objectWorldState), from the level config's objectWorldState
int32_t GetObjectWorldState() const { return m_ObjectWorldState; }
// The client moves the object with its parent (LWOGameObject::updatesWithParentPosition), sent with the parent;
// the spawn behavior's updatePositionWithParent sets it (live: the Engineer Personal Fortress, LOT 9479)
void SetUpdatesWithParentPosition(const bool value) { m_UpdatesWithParentPosition = value; m_IsParentChildDirty = true; }
@@ -403,6 +415,11 @@ public:
private:
// LWOGameObject::LoadTemplateData (0x00f997c0) and LoadConfigData (0x00f86f60): the object's own data from its
// Objects row and its level config
void LoadTemplateData();
void LoadConfigData();
// ObjectLoader2::DoObjectPreLoad: what the components will be, before any is made
ObjectLoadState DoObjectPreLoad();
// ObjectLoader2::DoObjectComponentLoad: the components in the client's order, then the ones it adds after
@@ -471,6 +488,9 @@ private:
bool m_IsParentChildDirty = true;
bool m_UpdatesWithParentPosition = false;
float m_InteractionDistance = 16.0f;
std::u16string m_CheckPrecondition;
int32_t m_ObjectWorldState = 0;
// When this object was created on this server. Construction sends its age from this, as live did.
std::chrono::steady_clock::time_point m_CreationTime = std::chrono::steady_clock::now();