Object API

Overview

Networked object types representing replicated entities.
All classes live in the FusionCore namespace.

Header: Types.h

Object (Base Class)

Abstract base class for all networked objects.
Owns the replicated word buffer, dirty shadow, per-object string heap, EMA traffic stats and engine-binding metadata.

Public Constants

Constant Value Description
ExtraTailWords sizeof(ObjectTail) / 4 (18) Words reserved for the ObjectTail at the end of the buffer. The dynamic-owner cooldown is no longer a static constant on Object; configure it at runtime with Client::SetDynamicOwnerCooldown(seconds).

Constructor

C++

explicit Object(FusionCore::Client *client);

Public Fields

Field Type Description
Id ObjectId Unique network identifier ({Origin, Map, Counter}).
Type TypeRef Type descriptor (hash + word count).
Engine void * Opaque pointer to the engine-side object.
EngineBlob Data Engine-specific binary spawn payload (replaces the older Header field).
EngineFlags uint32_t Engine-specific bitflags (replaces the older ObjectSpecialFlags enum).
EngineHash uint64_t Engine-specific hash (used for sub-object identification — widened from 32 bits in older SDKs).
Words BufferT<Word> Current replicated state buffer (user words + ObjectTail + required-object IDs).
Shadow BufferT<Word> Previous-tick state for dirty detection.

Public Methods

Method Signature Description
Root virtual ObjectRoot *Root() = 0 Returns the root object (self for roots, parent's root for children).
GetStringHeap const NetworkedStringHeap &GetStringHeap() const / NetworkedStringHeap &GetStringHeap() Access this object's per-object string heap (lazy-allocated).
GetHasValidData bool GetHasValidData() const Returns true if the object has been marked as carrying valid replicated data.
SetHasValidData void SetHasValidData() Mark the object as having valid replicated data.
SetSendUpdates void SetSendUpdates(bool sendUpdates) Enable or disable outgoing state updates for this object.
SendHeader bool SendHeader() const Returns true if the next outgoing packet should re-send the spawn header (no remote ack yet).
GetObjectType ObjectType GetObjectType() const Returns the runtime ObjectType tag (Base, Child, Root).
GetSendFlags uint8_t GetSendFlags() const Returns the OBJECT_SENDFLAG_* bitset for the next outgoing packet.
GetRemoteTickSent Tick GetRemoteTickSent() const Last tick this object was sent remotely.
GetRemoteTickAcked Tick GetRemoteTickAcked() const Last tick the remote acknowledged.
GetSendReport EMAReport GetSendReport() const Returns EMA statistics for bytes sent by this object. Replaces the older GetBytesSendLastTick per-frame counter.
GetRecvReport EMAReport GetRecvReport() const Returns EMA statistics for bytes received by this object. Replaces the older GetBytesReceivedLastTick per-frame counter.
AddString StringHandle AddString(const PhotonCommon::CharType *str) Allocate and replicate a string in this object's string heap.
ResolveString const PhotonCommon::CharType *ResolveString(const StringHandle &handle, StringMessage &OutStatus) Look up a string by handle. Sets OutStatus to indicate validity.
FreeString StringHandle FreeString(const StringHandle &handle) Free a string from the heap. Returns an invalidated handle.
IsValidStringHandle bool IsValidStringHandle(const StringHandle &handle) Returns true if the handle points to a live entry.
GetStringLength uint32_t GetStringLength(const StringHandle &handle) Returns the byte length of the string referenced by the handle.
LogStringData void LogStringData(const StringHandle &handle) Dump debug info about a string handle to the log.

The older Status field (with OBJECT_STATUS_NEW/PENDING/CREATED constants) and SpecialFlags field have been removed. Use ObjectRoot::IsReady() and ObjectRoot::GetHasReceivedState() for lifecycle queries; pass engineFlags to Client::Create* calls if you need to stash bitflags per object.

ObjectRoot

Final class inheriting from Object.
Represents a top-level networked entity. Owns sub-objects, ownership state, replicated time, prediction state and the input queue used by ObjectOwnerModes::PlayerPredicted.

Public Methods

Method Signature Description
Root ObjectRoot *Root() override Returns this.
GetSubObjects const std::vector<ObjectId> &GetSubObjects() const Returns all child sub-object IDs.
GetMap Map GetMap() const Returns Id.Map — the map this object belongs to. Replaces the older public Scene field.
GetOwner PlayerId GetOwner() const Returns the current owner.
GetOwnerMode ObjectOwnerModes GetOwnerMode() const Returns the ownership model for this object.
GetTime double GetTime() const Returns the last received server time for this object.
IsReady bool IsReady() const Returns true once all required sub-objects have been resolved and the object is usable. Replaces the older Status == OBJECT_STATUS_CREATED check.
GetHasReceivedState bool GetHasReceivedState() const Returns true once at least one state packet has been applied to this object.
GetPluginVersion int32_t GetPluginVersion() const Returns the server-plugin version the object was last touched by.
GetClientVersion int32_t GetClientVersion() const Returns the client-side version counter for this object.
GetCombinedSendReport EMAReport GetCombinedSendReport() const Returns combined EMA send statistics for the root and all sub-objects.
GetCombinedRecvReport EMAReport GetCombinedRecvReport() const Returns combined EMA receive statistics for the root and all sub-objects.
QueueInput void QueueInput(float dt, Data payload) Append an input frame to this object's prediction queue (used in SimulationMode::Authority with PlayerPredicted ownership).
ExecuteInputs void ExecuteInputs(float dt) Apply queued inputs for this frame.
GetInputQueueCount uint32_t GetInputQueueCount() const Returns how many inputs are currently queued.
GetInputQueueDeltaTime float GetInputQueueDeltaTime() const Returns the cumulative dt across the queued inputs.
GetInputTime double GetInputTime() const Returns the input time stored in the object's tail.
IsRequired bool IsRequired(ObjectId id) const Returns true if id is in the required objects list.
RequiredObjects std::span<ObjectId> RequiredObjects() const Returns a span over the required objects array (stored in the tail). The span size doubles as the count.

Static Methods

Method Signature Description
Is static bool Is(const Object *obj) Returns true if the object is an ObjectRoot.
Cast static ObjectRoot *Cast(Object *obj) Safe downcast from Object*. Returns nullptr if not a root.
Cast static const ObjectRoot *Cast(const Object *obj) Const overload of the safe downcast.

ObjectChild

Final class inheriting from Object.
Represents a sub-object attached to a root. The older public Parent field and TargetObjectHash field are no longer exposed; Parent is encapsulated and accessed via ObjectChild::GetParent(obj). The hash is supplied at creation time as the engineHash parameter on Client::CreateSubObject and stored in the base class's EngineHash field.

Public Methods

Method Signature Description
Root ObjectRoot *Root() override Returns the parent root object via the client.

Static Methods

Method Signature Description
GetParent static ObjectId GetParent(const Object *obj) Returns the parent ObjectId if obj is a child, otherwise ObjectId(0).
Is static bool Is(const Object *obj) Returns true if the object is an ObjectChild.
Cast static ObjectChild *Cast(Object *obj) Safe downcast from Object*. Returns nullptr if not a child.
Cast static const ObjectChild *Cast(const Object *obj) Const overload of the safe downcast.

ObjectTail

Packed struct appended after the user word buffer of every object.
Stored inline in the Words buffer, immediately followed by RequiredObjectsCount ObjectIds.

C++

#pragma pack(push, 4)
struct ObjectTail {
    uint32_t Reserved[8];
    int32_t  RequiredObjectsCount;
    uint64_t InterestKey;
    int32_t  Destroyed;
    int32_t  RoomSendRate;
    PlayerId PredictingPlayer;
    uint32_t RejectedSequence;
    uint32_t InputSequence;
    uint32_t InputTime;
    int32_t  Dummy;
};
#pragma pack(pop)

static_assert(sizeof(ObjectTail) == 72);
Field Offset Size Description
Reserved[8] 0 32 Eight reserved 32-bit words for forward-compatibility.
RequiredObjectsCount 32 4 Number of ObjectIds following the tail in the word buffer.
InterestKey 36 8 The interest key assigned to this object. See Interest Area.
Destroyed 44 4 Non-zero when the object has been destroyed.
RoomSendRate 48 4 Server-authoritative ticks between sends (0 = default). Renamed from the older SendRate.
PredictingPlayer 52 2 PlayerId of the player currently predicting this object.
RejectedSequence 56 4 Most recent input sequence the server rejected (drives OnPredictionReset).
InputSequence 60 4 Latest input sequence applied to the object.
InputTime 64 4 Synchronized server time at which the latest input was sampled.
Dummy 68 4 Trailing padding for alignment.

Object::ExtraTailWords = sizeof(ObjectTail) / 4 = 18 is the constant to add when sizing the Words buffer for a new object.

ObjectPacketEnvelope

Tracks which objects were included in a single outgoing packet.
Used for delivery and loss callbacks.

C++

class ObjectPacketEnvelope {
public:
    std::vector<std::tuple<ObjectId, Tick>> ObjectUpdates{};
};
Field Type Description
ObjectUpdates vector<tuple<ObjectId, Tick>> List of (ObjectId, Tick) pairs for each object update included in the packet.
Back to top