Class SceneObjectNamer
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
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourSceneObjectNamer
- Inherited Members
-
NetworkBehaviour.IsSpawnedNetworkBehaviour.ComponentIndexNetworkBehaviour.NetworkObjectNetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURSNetworkBehaviour.UNSET_NETWORKBEHAVIOUR_IDNetworkBehaviour.ToString()NetworkBehaviour.Reset()NetworkBehaviour.OnValidate()NetworkBehaviour.IsBehaviourReconcilingNetworkBehaviour.ClearReplicateCache()NetworkBehaviour.CreateReconcile()NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)NetworkBehaviour.OnStartServerCalledNetworkBehaviour.OnStartClientCalledNetworkBehaviour.OnStartNetwork()NetworkBehaviour.OnStopNetwork()NetworkBehaviour.OnStopServer()NetworkBehaviour.OnOwnershipServer(NetworkConnection)NetworkBehaviour.OnSpawnServer(NetworkConnection)NetworkBehaviour.OnDespawnServer(NetworkConnection)NetworkBehaviour.OnStopClient()NetworkBehaviour.OnOwnershipClient(NetworkConnection)NetworkBehaviour.ClearBuffedRpcs()NetworkBehaviour.ExcludeOwnerFromUnbufferedObserversRpcsNetworkBehaviour.IsClientOnlyNetworkBehaviour.IsServerOnlyNetworkBehaviour.IsHostNetworkBehaviour.IsClientNetworkBehaviour.IsServerNetworkBehaviour.IsDeinitializingNetworkBehaviour.NetworkManagerNetworkBehaviour.ServerManagerNetworkBehaviour.ClientManagerNetworkBehaviour.ObserverManagerNetworkBehaviour.TransportManagerNetworkBehaviour.TimeManagerNetworkBehaviour.SceneManagerNetworkBehaviour.PredictionManagerNetworkBehaviour.RollbackManagerNetworkBehaviour.NetworkObserverNetworkBehaviour.IsClientInitializedNetworkBehaviour.IsClientStartedNetworkBehaviour.IsClientOnlyInitializedNetworkBehaviour.IsClientOnlyStartedNetworkBehaviour.IsServerInitializedNetworkBehaviour.IsServerStartedNetworkBehaviour.IsServerOnlyInitializedNetworkBehaviour.IsServerOnlyStartedNetworkBehaviour.IsHostInitializedNetworkBehaviour.IsHostStartedNetworkBehaviour.IsOfflineNetworkBehaviour.IsNetworkedNetworkBehaviour.GetIsNetworked()NetworkBehaviour.IsManagerReconcilingNetworkBehaviour.ObserversNetworkBehaviour.IsOwnerNetworkBehaviour.IsControllerNetworkBehaviour.HasAuthorityNetworkBehaviour.OwnerNetworkBehaviour.OwnerIdNetworkBehaviour.ObjectIdNetworkBehaviour.LocalConnectionNetworkBehaviour.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.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.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.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.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.nameObject.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
GeneratedName
The generated name, or null while the authored name stands.
public string GeneratedName { get; }
Property Value
NameSeed
The seed the name was generated from, or zero when none was.
public int NameSeed { get; }
Property Value
SelectedGender
The gender behind this object's generated name.
public CharacterGender SelectedGender { get; }
Property Value
Settings
The authored naming settings.
public SceneObjectNamingSettings Settings { get; }
Property Value
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
connectionNetworkConnectionNetwork connection.
readerReaderNetwork 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
asServerboolTrue 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
connectionNetworkConnectionNetwork connection.
writerWriterNetwork writer for payload.