Skip to main content

Named Replica

Overview

This component manages client-server synchronization of an entity's display name and author identifier. It uses net_string replica variables to propagate changes from the master simulation to clients and listens for dirty events on non-master instances to update local name and author properties.

Dependencies & Tags

  • Replica Variables: Creates two replica string variables: _name and _author_netid.
  • No external component dependencies (e.g., no AddComponent calls).
  • Event Listeners: Registers local listeners for "namedirty" and "authordirty" events only on non-master instances.

Properties

PropertyTypeDefault ValueDescription
_namenet_stringnet_string(inst.GUID, "named._name", "namedirty")Replica variable storing the entity's display name; synchronized across the network.
_author_netidnet_stringnet_string(inst.GUID, "named._author_netid", "authordirty")Replica variable storing the author's NetID as a string; synchronized across the network.

Main Functions

Named:SetName(name, author)

  • Description: Sets the entity's name and author on the master simulation. This triggers dirty events on the master, which propagate the values to clients via replica sync.
  • Parameters:
    • name (string): The display name to assign to the entity. Empty strings are accepted but may trigger fallback naming on clients.
    • author (string): The author's NetID (as a string). Can be empty; clients treat empty values as nil.

Events & Listeners

  • Listens for "namedirty" event (client-side only): Triggers OnNameDirty, which updates inst.name using the value from self._name or falls back to a default string based on inst.prefab.
  • Listens for "authordirty" event (client-side only): Triggers OnAuthorDirty, which updates inst.name_author_netid with the author NetID from self._author_netid, or sets it to nil if the value is empty.