Class ArchetypeController
Controls the archetype state for a character. Handles archetype assignment, network payload serialization, and event invocation when the archetype changes. The archetype determines which abilities, items, buffs, titles, and attributes a character has access to.
public class ArchetypeController : CharacterBehaviour, IArchetypeController, ICharacterBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourArchetypeController
- Implements
- 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.OnStartServer()NetworkBehaviour.OnStopServer()NetworkBehaviour.OnOwnershipServer(NetworkConnection)NetworkBehaviour.OnSpawnServer(NetworkConnection)NetworkBehaviour.OnDespawnServer(NetworkConnection)NetworkBehaviour.OnStartClient()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
OnArchetypeChangeTriggers
Triggers invoked when the character's archetype changes.
public List<Trigger> OnArchetypeChangeTriggers { get; }
Property Value
PersistenceDirty
Whether the archetype has changed since the database last confirmed it.
public bool PersistenceDirty { get; }
Property Value
Template
The archetype template currently assigned to this character.
public ArchetypeTemplate Template { get; }
Property Value
Version
Persistence version of the character's archetype row. Advanced on every change and by the save snapshot; compared by MarkPersisted(long). Loaded from the row on login.
public long Version { get; set; }
Property Value
Methods
MarkPersisted(long)
Clears the dirty mark if nothing has changed since the confirmed snapshot was taken.
public void MarkPersisted(long persistedVersion)
Parameters
persistedVersionlong
OnStartCharacter()
Called when the character starts on the client. Registers archetype broadcast listeners. Non-owner character instances are disabled and updated through owner-routed observer broadcasts.
public override void OnStartCharacter()
OnStopCharacter()
Called when the character stops on the client. Unregisters archetype broadcast listeners.
public override void OnStopCharacter()
ReadPayload(NetworkConnection, Reader)
Reads the archetype payload from the network. Reads the template ID and assigns the corresponding archetype template from the cache.
public override void ReadPayload(NetworkConnection connection, Reader reader)
Parameters
connectionNetworkConnectionThe network connection.
readerReaderThe network reader containing serialized data.
ResetState(bool)
Resets the archetype controller's state, clearing the current archetype template.
public override void ResetState(bool asServer)
Parameters
asServerboolWhether the reset is performed on the server.
Restore(int, long)
Installs a persisted archetype without events, requirement checks or dirtying — the load path.
public void Restore(int templateID, long version)
Parameters
RestoreArchetype(int)
Installs an archetype this peer was TOLD about — the spawn payload and the observer broadcast — raising nothing.
public void RestoreArchetype(int templateID)
Parameters
templateIDintThe cached ID of the archetype template to install.
Remarks
The counterpart of FactionController.ApplyFactionValue, and it exists for the same
reason: both of those paths run on every peer for every character that comes into
observer range, and SetArchetype(int) ends in
Character.Invoke(onArchetypeChangeTriggers). BaseCharacter.Invoke has no
authority gate and only a minority of action types gate themselves with
EcaAuthority, so a stranger walking past would run that stranger's
archetype-change triggers on the onlooker's machine.
A separate method rather than a skipEvent parameter on SetArchetype(int)
because IArchetypeController declares the two-argument-free signatures, and
an implementation with an extra optional parameter does not satisfy an interface member.
Adding the flag to the interface — matching
IFactionController.SetFaction(int, int, bool) — would be the tidier shape.
SetArchetype(ArchetypeTemplate)
Sets the character's archetype by template reference. Invokes OnArchetypeChanged if the archetype actually changes.
public void SetArchetype(ArchetypeTemplate template)
Parameters
templateArchetypeTemplateThe archetype template to assign.
SetArchetype(int)
Sets the character's archetype by template ID. Looks up the template from the CachedScriptableObject<T> cache and assigns it.
public void SetArchetype(int templateID)
Parameters
templateIDintThe cached ID of the archetype template to assign.
WritePayload(NetworkConnection, Writer)
Writes the archetype payload to the network. Writes the template ID for the currently assigned archetype, or -1 if no archetype is assigned.
public override void WritePayload(NetworkConnection connection, Writer writer)
Parameters
connectionNetworkConnectionThe network connection.
writerWriterThe network writer to serialize data into.
Events
OnArchetypeChanged
Event triggered when the character's archetype changes. Provides the old and new archetype templates. The old template may be null if no archetype was previously assigned.
public event Action<ArchetypeTemplate, ArchetypeTemplate> OnArchetypeChanged