ConfigurationReplicator

Updated 2 years ago

Xan.ROR2VoidPlayerCharacterCommon.AdvancedConfigs.Networked.ConfigurationReplicator

This class is responsible for dispatching networked updates to configuration values. Most of its members are internal, and it does not need to be explicitly used by the API user in most cases as it is automatic.

Public Methods

static ConfigurationReplicator CreateReplicator(string modId, Type configurationType)

Constructs a new instance of ConfigurationReplicator for the provided mod ID, using the provided type as the class storing instances of ReplicatedConfigEntry. This raises an exception in the following cases:

  • ArgumentNullException - If modId or configurationType is null.
  • ArgumentException - If modId is null, empty, or whitespace, or if configurationType is not a class, or if configurationType is not (effectively) sealed (sealed class or static class), or if configurationType is generic.
  • InvalidOperationException - If, during collection of the replicated fields, a member decorated with [ReplicatedConfiguration] is not an instance of ReplicatedConfigEntryBase or IReplicatedConfigContainer.

bool TrySendChanges(SettingChangedEventArgs e)

Attempts to send the changes made to the provided configuration entry (denoted by e) across the network. This does nothing if the network server is not active (meaning this player is in multiplayer and is not the host). It will attempt to send only the config value in e, but may send all configs if the registry of what options need to replicate is malformed, in which case a warning will be raised and the implementer should ensure everything in their code is correct.