Table of Contents

Class ConfigKeySessionShare<TKey, TShared>

Namespace
MonkeyLoader.Resonite.Configuration
Assembly
MonkeyLoader.Resonite.Integration.dll

Represents the functionality for an IDefiningConfigKey<T>, which makes its local value available as a (converted) shared resource in Resonite FrooxEngine.Worlds.
Optionally allows writing back changes from the FrooxEngine.World to the config item.

public class ConfigKeySessionShare<TKey, TShared> : IConfigKeySessionShare<TKey, TShared>, IConfigKeyComponent<IDefiningConfigKey<TKey>>, IComponent<IDefiningConfigKey<TKey>>, IConfigKeySessionShare

Type Parameters

TKey

The type of the config item's value.

TShared

The type of the resource shared in Resonite FrooxEngine.Worlds. Must be a valid generic parameter for FrooxEngine.ValueField<T> components.

Inheritance
ConfigKeySessionShare<TKey, TShared>
Implements
IConfigKeySessionShare<TKey, TShared>
Derived
Inherited Members

Constructors

ConfigKeySessionShare(Converter<TKey?, TShared?>, Converter<TShared?, TKey?>, TKey?, bool)

Creates a new IConfigKeySessionShare<T> component, which makes its config key's local value available as a shared resource in Resonite sessions.
Optionally allows writing back changes from the session to the config item.

public ConfigKeySessionShare(Converter<TKey?, TShared?> convertToShared, Converter<TShared?, TKey?> convertToKey, TKey? defaultValue = default, bool allowWriteBack = false)

Parameters

convertToShared Converter<TKey, TShared>

Converts the config item's value to the shared resource's.

convertToKey Converter<TShared, TKey>

Converts the shared resource's value to the config item's.

defaultValue TKey

The default value for the shared config item for users that don't have it themselves.
Gets converted to TShared using convertToShared.

allowWriteBack bool

Whether to allow writing back changes from the session to the config item.

Exceptions

InvalidOperationException

When TShared is an invalid generic argument for FrooxEngine.ValueField<T> components.

Properties

AllowWriteBack

Gets or sets whether to allow writing back changes from the session to the config item.

public bool AllowWriteBack { get; set; }

Property Value

bool

ConfigKey

Gets the shared config item.

public IDefiningConfigKey<TKey> ConfigKey { get; }

Property Value

IDefiningConfigKey<TKey>

DefaultValue

Gets or sets the default value for the shared config item for users that don't have it themselves.

public TShared? DefaultValue { get; set; }

Property Value

TShared

KeyType

Gets the Type of the shared config item's value.

public Type KeyType { get; }

Property Value

Type

SharedId

Gets the key used in FrooxEngine.Worlds to identify the FrooxEngine.ValueField<T> that stores the shared value.

public string SharedId { get; }

Property Value

string

SharedType

Gets the Type of the shared value.

public Type SharedType { get; }

Property Value

Type

VariableName

Gets the full name of the dynamic variable that is linked to the shared value.

public string VariableName { get; }

Property Value

string

Methods

ConvertToKey(TShared?)

Converts the given value from the shared resource's type to the config item's.

public TKey? ConvertToKey(TShared? sharedValue)

Parameters

sharedValue TShared

The value suitable for the shared resource to be converted.

Returns

TKey

The value converted to the config item's type.

Remarks

May throw when the provided input isn't compatible.

ConvertToShared(TKey?)

Converts the given value from the config item's type to the shared resource's.

public TShared? ConvertToShared(TKey? keyValue)

Parameters

keyValue TKey

The value suitable for the config item to be converted.

Returns

TShared

The value converted to the shared resource's type.

Remarks

May throw when the provided input isn't compatible.

Drive(IField<TShared>, bool)

Creates a FrooxEngine.ValueCopy<T> on the given field's parent FrooxEngine.Slot, which drives it from the shared value.

public ValueCopy<TShared> Drive(IField<TShared> field, bool writeBack = false)

Parameters

field IField<TShared>

The field to drive with the shared value.

writeBack bool

Whether to allow changes to the driven field and propagate them back to the shared value.
AllowWriteBack must be true when enabling this.

Returns

ValueCopy<TShared>

The created FrooxEngine.ValueCopy<T> component.

Exceptions

InvalidOperationException

When writeBack is true and AllowWriteBack isn't.

DriveFromVariable(IField<TShared>)

Creates a FrooxEngine.DynamicValueVariableDriver<T> on the given field's parent FrooxEngine.Slot, which drives it from the shared value.
The driver's DefaultValue is set to the shared value's DefaultValue.

public DynamicValueVariableDriver<TShared> DriveFromVariable(IField<TShared> field)

Parameters

field IField<TShared>

The field to drive with the shared value.

Returns

DynamicValueVariableDriver<TShared>

The created FrooxEngine.DynamicValueVariableDriver<T> component.

GetSharedConfigSlot(World)

Gets this shared config item's FrooxEngine.Slot under the SharedConfig slot.

public Slot GetSharedConfigSlot(World world)

Parameters

world World

The FrooxEngine.World to get the FrooxEngine.Slot for.

Returns

Slot

This shared config item's SharedConfig slot for the given world.

GetSharingUsers(World)

Gets a sequence of users who have defined overrides for the shared value.

public IEnumerable<User> GetSharingUsers(World world)

Parameters

world World

The world to get the sharing users for.

Returns

IEnumerable<User>

The users who have defined overrides.

SetupOverride(World)

Ensures that the shared value field and overrides for this config item exist in the given FrooxEngine.World.

public void SetupOverride(World world)

Parameters

world World

The world to set up the override for.

ShutdownOverride(World)

Removes the connection between this config item and the given FrooxEngine.World's shared value field.

public void ShutdownOverride(World world)

Parameters

world World

The world to remove the connection from.