Preparing search index...

    Provides classes and helper functions used for storing data in RealtimeStores.

    Type Parameters

    Index

    Constructors

    Properties

    currentOrPendingValue: StorageTypeToPrimitive[TStorageType] = null

    The most recently changed local value, whether that's current or pending. In most cases when you want a very up-to-date local value, this is what you want to read from.

    currentValue: StorageTypeToPrimitive[TStorageType] = null

    The current value that we believe to be synced across the network. In most simple cases, this is what you want to read from.

    equalsCheck: (
        a: StorageTypeToPrimitive[TStorageType],
        b: StorageTypeToPrimitive[TStorageType],
    ) => boolean = ...

    The function used to check for a change in the property value. It should return true if two values are equal, or reasonably close to equal.

    getterFunc: () => StorageTypeToPrimitive[TStorageType] = null

    If defined, this function is called to automatically update the property value each frame.

    key: string

    Key used to identify and store the property. This key matches defines how the property is accessed in a RealtimeStore. It can also be used to identify the property in a StoragePropertySet.

    markedDirty: boolean = false

    Can be used to manually mark the property dirty and skip equals check

    needToSendUpdate: boolean = false

    If true, we have a value change that needs to be sent at the next opportunity.

    onAnyChange: EventWrapper<
        [
            StorageTypeToPrimitive[TStorageType],
            StorageTypeToPrimitive[TStorageType],
            RealtimeStoreUpdateInfo,
        ],
    > = ...

    Event triggered when the currentValue is changed by any user (either local or remote).

    onLocalChange: EventWrapper<
        [
            StorageTypeToPrimitive[TStorageType],
            StorageTypeToPrimitive[TStorageType],
        ],
    > = ...

    Event triggered when the currentValue is changed by the local user.

    onPendingValueChange: EventWrapper<
        [
            StorageTypeToPrimitive[TStorageType],
            StorageTypeToPrimitive[TStorageType],
        ],
    > = ...

    Event triggered when the pending value changes.

    onRemoteChange: EventWrapper<
        [
            StorageTypeToPrimitive[TStorageType],
            StorageTypeToPrimitive[TStorageType],
            RealtimeStoreUpdateInfo,
        ],
    > = ...

    Event triggered when the currentValue is changed by a remote user.

    pendingValue: StorageTypeToPrimitive[TStorageType] = null

    The local value that can potentially be sent to the network at the next available chance. It may be the same as currentValue, but may not be.

    propertyType: TStorageType

    used - by the property.

    sendsPerSecondLimit: number = -1

    If greater than or equal to zero, this limits how often the property sends updates to the network about its value changing. This is useful to avoid rate limiting when a value updates very frequently, for example if a position is changing every frame. When using this feature, currentValue will only be updated when the value is actually sent to the network. To get the most recent local version of a value, you can always check currentOrPendingValue.

    setterFunc: (val: StorageTypeToPrimitive[TStorageType]) => void = null

    If defined, this function is called to automatically apply the property value.

    Methods

    • Returns void

    • Creates an automatically updated boolean property based on getter and setter functions.

      Parameters

      • key: string

        Key to identify the property

      • getterFunc: () => boolean

        Function that returns the current local value for the property

      • setterFunc: (val: boolean) => void

        Function that applies incoming new values for the property

      Returns StorageProperty<bool>

      Newly created StorageProperty

    • Creates an automatically updated float property based on getter and setter functions.

      Parameters

      • key: string

        Key to identify the property

      • getterFunc: () => number

        Function that returns the current local value for the property

      • setterFunc: (val: number) => void

        Function that applies incoming new values for the property

      • OptionalsmoothingOptions: SnapshotBufferOptions<float> | SnapshotBufferOptionsObj<float>

        Options for automatically applied smoothing

      Returns StorageProperty<float>

      Newly created StorageProperty

    • Creates an automatically updated int property based on getter and setter functions.

      Parameters

      • key: string

        Key to identify the property

      • getterFunc: () => number

        Function that returns the current local value for the property

      • setterFunc: (val: number) => void

        Function that applies incoming new values for the property

      Returns StorageProperty<int>

      Newly created StorageProperty

    • Creates an automatically updated string property based on getter and setter functions.

      Parameters

      • key: string

        Key to identify the property

      • getterFunc: () => string

        Function that returns the current local value for the property

      • setterFunc: (val: string) => void

        Function that applies incoming new values for the property

      Returns StorageProperty<string>

      Newly created StorageProperty

    • Returns boolean

      True if the value was changed

    • Returns true if we are allowed to send updated values to the network based on the sendsPerSecondLimit and timestamp.

      Parameters

      • timestamp: number

        Time in seconds

      Returns boolean

      True if we are allowed to send updated values to the network

    • Helper function that reads a value from a store, given a key and StorageType | StorageType

      Type Parameters

      • T

      Parameters

      Returns T

      Value - found (or default value if none found)

    • Returns boolean

      True if the property has a snapshot buffer and is currently smoothing

    • Creates a simple boolean property that should be updated manually.

      Parameters

      • key: string

        Key to identify the property

      • OptionalstartingValue: boolean

        Optional starting value to assign to the property

      Returns StorageProperty<bool>

      Newly created StorageProperty

    • Creates a simple integer property that should be updated manually.

      Parameters

      • key: string

        Key to identify the property

      • OptionalstartingValue: number

        Optional starting value to assign to the property

      Returns StorageProperty<int>

      Newly created StorageProperty

    • Creates a simple string property that should be updated manually.

      Parameters

      • key: string

        Key to identify the property

      • OptionalstartingValue: string

        Optional starting value to assign to the property

      Returns StorageProperty<string>

      Newly created StorageProperty

    • Parameters

      • store: GeneralDataStore

        Store to write value to

      • OptionaltimeStamp: number

        Time in seconds

      Returns void

    • Sets the pending value to newValue. This value will be sent to the network at the end of the frame, as soon as it's allowed to do so (we have permission to modify the SyncEntity, and sendsPerSecondLimit hasn't been reached).

      Parameters

      Returns void