Table of Contents

Class SceneObjectNamer

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Gives a scene object a generated name — a character, city, dungeon, point of interest or legendary item name — from the name generator, using the object's race and the settings authored on the prefab.

The server rolls a seed and a gender and ships those (4 + 1 bytes); every peer then regenerates the same name from the same templates, so the name itself never crosses the wire. The race comes from the object's IFactionController unless the settings override it, which is how one prefab names itself correctly at any spawner.

public class SceneObjectNamer : NetworkBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
NetworkBehaviour
SceneObjectNamer
Inherited Members
NetworkBehaviour.IsSpawned
NetworkBehaviour.ComponentIndex
NetworkBehaviour.NetworkObject
NetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURS
NetworkBehaviour.UNSET_NETWORKBEHAVIOUR_ID
NetworkBehaviour.ToString()
NetworkBehaviour.Reset()
NetworkBehaviour.OnValidate()
NetworkBehaviour.IsBehaviourReconciling
NetworkBehaviour.ClearReplicateCache()
NetworkBehaviour.CreateReconcile()
NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)
NetworkBehaviour.OnStartServerCalled
NetworkBehaviour.OnStartClientCalled
NetworkBehaviour.OnStartNetwork()
NetworkBehaviour.OnStopNetwork()
NetworkBehaviour.OnStopServer()
NetworkBehaviour.OnOwnershipServer(NetworkConnection)
NetworkBehaviour.OnSpawnServer(NetworkConnection)
NetworkBehaviour.OnDespawnServer(NetworkConnection)
NetworkBehaviour.OnStopClient()
NetworkBehaviour.OnOwnershipClient(NetworkConnection)
NetworkBehaviour.ClearBuffedRpcs()
NetworkBehaviour.ExcludeOwnerFromUnbufferedObserversRpcs
NetworkBehaviour.IsClientOnly
NetworkBehaviour.IsServerOnly
NetworkBehaviour.IsHost
NetworkBehaviour.IsClient
NetworkBehaviour.IsServer
NetworkBehaviour.IsDeinitializing
NetworkBehaviour.NetworkManager
NetworkBehaviour.ServerManager
NetworkBehaviour.ClientManager
NetworkBehaviour.ObserverManager
NetworkBehaviour.TransportManager
NetworkBehaviour.TimeManager
NetworkBehaviour.SceneManager
NetworkBehaviour.PredictionManager
NetworkBehaviour.RollbackManager
NetworkBehaviour.NetworkObserver
NetworkBehaviour.IsClientInitialized
NetworkBehaviour.IsClientStarted
NetworkBehaviour.IsClientOnlyInitialized
NetworkBehaviour.IsClientOnlyStarted
NetworkBehaviour.IsServerInitialized
NetworkBehaviour.IsServerStarted
NetworkBehaviour.IsServerOnlyInitialized
NetworkBehaviour.IsServerOnlyStarted
NetworkBehaviour.IsHostInitialized
NetworkBehaviour.IsHostStarted
NetworkBehaviour.IsOffline
NetworkBehaviour.IsNetworked
NetworkBehaviour.GetIsNetworked()
NetworkBehaviour.IsManagerReconciling
NetworkBehaviour.Observers
NetworkBehaviour.IsOwner
NetworkBehaviour.IsController
NetworkBehaviour.HasAuthority
NetworkBehaviour.Owner
NetworkBehaviour.OwnerId
NetworkBehaviour.ObjectId
NetworkBehaviour.LocalConnection
NetworkBehaviour.OwnerMatches(NetworkConnection)
NetworkBehaviour.Despawn(GameObject, DespawnType?)
NetworkBehaviour.Despawn(NetworkObject, DespawnType?)
NetworkBehaviour.Despawn(DespawnType?)
NetworkBehaviour.Spawn(GameObject, NetworkConnection, Scene)
NetworkBehaviour.Spawn(NetworkObject, NetworkConnection, Scene)
NetworkBehaviour.RemoveOwnership()
NetworkBehaviour.GiveOwnership(NetworkConnection)
NetworkBehaviour.GetInstance<T>()
NetworkBehaviour.TryRegisterInstance<T>(T)
NetworkBehaviour.UnregisterInstance<T>()
NetworkBehaviour.CanLog(LoggingType)
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.name
Object.hideFlags

Properties

DisplayName

The name this object currently shows: the generated one when there is one, else the authored one.

public string DisplayName { get; }

Property Value

string

GeneratedName

The generated name, or null while the authored name stands.

public string GeneratedName { get; }

Property Value

string

NameSeed

The seed the name was generated from, or zero when none was.

public int NameSeed { get; }

Property Value

int

SelectedGender

The gender behind this object's generated name.

public CharacterGender SelectedGender { get; }

Property Value

CharacterGender

Settings

The authored naming settings.

public SceneObjectNamingSettings Settings { get; }

Property Value

SceneObjectNamingSettings

Methods

EnsureGeneratedGender()

Ensures the seed and gender have been rolled and returns the gender. Server only; on a client the gender arrives in the payload.

public CharacterGender EnsureGeneratedGender()

Returns

CharacterGender

The selected generated name gender.

OnStartClient()

Applies the name received in the payload.

public override void OnStartClient()

Remarks

Not done in ReadPayload(NetworkConnection, Reader): this behaviour precedes FactionController in every NPC prefab's component order, so when its payload is read the faction has not yet read the race a spawner may have overridden. By the time start callbacks run every behaviour's payload has been read and the race is correct.

OnStartServer()

Rolls the seed and gender, then applies the name. Runs on every spawn including pool reuse.

public override void OnStartServer()

ReadPayload(NetworkConnection, Reader)

Reads the seed and gender, and for a biome-driven mode the biome and climate variant. The length follows only from the authored settings, identical on both peers, so the behaviours after this one in the payload stay aligned whatever the values are.

public override void ReadPayload(NetworkConnection connection, Reader reader)

Parameters

connection NetworkConnection

Network connection.

reader Reader

Network reader for payload.

ResetState(bool)

Forgets the generated name so the next occupant of this pool slot draws its own.

public override void ResetState(bool asServer)

Parameters

asServer bool

True if called on the server.

Remarks

FishMMO.Shared.SceneObjectNamer.nameGenerated is a once-only latch and FishMMO.Shared.SceneObjectNamer.GenerateNameIfNeeded() returns early on it, so without this every NPC that ever came out of a given pool slot would wear the name the first occupant drew — on the server, in the spawn payload, and therefore on every client's name label too.

The GameObject name is put back rather than left alone: a prefab whose settings cannot produce a name makes FishMMO.Shared.SceneObjectNamer.ApplyGeneratedName() keep the current name, and the previous occupant's name would then survive as this object's identity.

WritePayload(NetworkConnection, Writer)

Writes the seed and gender (five bytes), plus the biome ID and variant (five more) when the mode names from a biome — so a client never has to agree with the server about a biome map or the weather to reproduce the name.

Both 32-bit values are written UNPACKED, which is what makes those counts true. A seed is full entropy by construction and BiomeRegistry.IDOf returns the same deterministic hash every other template id uses, so neither is ever small: FishNet's signed-packed form zigzags them past 2^28 and spends five bytes on each, making the block six and six. This is paid per NPC spawn per observer, the highest object count in the game.

public override void WritePayload(NetworkConnection connection, Writer writer)

Parameters

connection NetworkConnection

Network connection.

writer Writer

Network writer for payload.