Table of Contents

Class ArchetypeController

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

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
Object
Component
Behaviour
MonoBehaviour
NetworkBehaviour
ArchetypeController
Implements
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.OnStartServer()
NetworkBehaviour.OnStopServer()
NetworkBehaviour.OnOwnershipServer(NetworkConnection)
NetworkBehaviour.OnSpawnServer(NetworkConnection)
NetworkBehaviour.OnDespawnServer(NetworkConnection)
NetworkBehaviour.OnStartClient()
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

OnArchetypeChangeTriggers

Triggers invoked when the character's archetype changes.

public List<Trigger> OnArchetypeChangeTriggers { get; }

Property Value

List<Trigger>

PersistenceDirty

Whether the archetype has changed since the database last confirmed it.

public bool PersistenceDirty { get; }

Property Value

bool

Template

The archetype template currently assigned to this character.

public ArchetypeTemplate Template { get; }

Property Value

ArchetypeTemplate

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

long

Methods

MarkPersisted(long)

Clears the dirty mark if nothing has changed since the confirmed snapshot was taken.

public void MarkPersisted(long persistedVersion)

Parameters

persistedVersion long

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

connection NetworkConnection

The network connection.

reader Reader

The 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

asServer bool

Whether 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

templateID int
version long

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

templateID int

The 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

template ArchetypeTemplate

The 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

templateID int

The 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

connection NetworkConnection

The network connection.

writer Writer

The 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

Event Type

Action<ArchetypeTemplate, ArchetypeTemplate>