refactor(entity): load an object in the client's two steps

Entity::Initialize now runs DoObjectPreLoad (what the components will be:
the player's own components, markedAsPhantom, model behaviors, the
component whitelist) and DoObjectComponentLoad (the walk in the client's
order and what the client adds after it), as ObjectLoader2 does, with an
ObjectLoadState that answers the registry through the whitelist. Same
components and bytes for every LOT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-01 16:52:15 -05:00
parent 432f4f6ff9
commit 477dd9f3e3
2 changed files with 735 additions and 697 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -396,6 +396,28 @@ 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;
// 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();
// ObjectLoader2::DoObjectComponentLoad: the components in the client's order, then the ones it adds after
void DoObjectComponentLoad(ObjectLoadState& state);
/**
* Get the LDF data.