Class CharacterPart
A module's piece of a character, added when the character wakes rather than authored on its prefab, so removing the module removes the piece and leaves every prefab whole (no missing script, no gap in FishNet's behaviour list).
public abstract class CharacterPart : MonoBehaviour, ICharacterBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourCharacterPart
- Implements
- Inherited Members
-
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.MemberwiseClone()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.ToString()Object.nameObject.hideFlags
Remarks
Declared with [assembly: CharacterPart(typeof(MyPart), typeof(IPlayerCharacter))]: every character that is
(or derives from, or implements) the second type gets one, on every peer, in BaseCharacter.Awake before the
character's behaviours are initialised, so it is found by TryGet<T>(out T) like any behaviour.
It is not a NetworkBehaviour: it talks over broadcasts, and its spawn-time state rides the character's own spawn payload (WritePayload(NetworkConnection, Writer), framed by part, so a reader skips a part it does not have). The character forwards its lifecycle: OnStartServer(), OnStopServer(), ResetState(bool) (pooling), and OnStartCharacter()/OnStopCharacter() on the client as for every behaviour.
Properties
Character
The character this part belongs to.
public ICharacter Character { get; }
Property Value
ClientManager
protected ClientManager ClientManager { get; }
Property Value
- ClientManager
Host
The character's network behaviour, whose network state the part reads.
protected BaseCharacter Host { get; }
Property Value
Initialized
True if this behaviour has been initialized for its character.
public bool Initialized { get; }
Property Value
IsClientInitialized
protected bool IsClientInitialized { get; }
Property Value
IsOwner
protected bool IsOwner { get; }
Property Value
IsServerInitialized
protected bool IsServerInitialized { get; }
Property Value
IsServerStarted
protected bool IsServerStarted { get; }
Property Value
IsSpawned
protected bool IsSpawned { get; }
Property Value
NetworkObject
protected NetworkObject NetworkObject { get; }
Property Value
- NetworkObject
PayloadId
Stable id of this part's block in the spawn payload; 0 (the default) for a part with no spawn state. Derive it
from something that never changes, such as CharacterParts.IdOf("travel.waypoints").
public virtual uint PayloadId { get; }
Property Value
PlayerCharacter
The character as a player, or null.
public IPlayerCharacter PlayerCharacter { get; }
Property Value
ServerManager
protected ServerManager ServerManager { get; }
Property Value
- ServerManager
TimeManager
protected TimeManager TimeManager { get; }
Property Value
- TimeManager
Methods
InitializeOnce()
Called once, when the character initialises its behaviours.
public virtual void InitializeOnce()
InitializeOnce(ICharacter)
Initializes the behaviour with the specified character. Called once per behaviour instance.
public void InitializeOnce(ICharacter character)
Parameters
characterICharacterThe character to initialize for.
OnDestroying()
public virtual void OnDestroying()
OnStartCharacter()
Client: the character started (players: after the payload; see PlayerCharacter).
public virtual void OnStartCharacter()
OnStartServer()
Server: the character started on the server.
public virtual void OnStartServer()
OnStopCharacter()
Client: the character is stopping.
public virtual void OnStopCharacter()
OnStopServer()
Server: the character is stopping on the server.
public virtual void OnStopServer()
ReadPayload(NetworkConnection, Reader)
Client: reads what WritePayload(NetworkConnection, Writer) wrote (the character seeks past the block afterwards).
public virtual void ReadPayload(NetworkConnection conn, Reader reader)
Parameters
connNetworkConnectionreaderReader
ResetState(bool)
The character is being reset for reuse from the pool.
public virtual void ResetState(bool asServer)
Parameters
asServerbool
WritePayload(NetworkConnection, Writer)
Server: this part's spawn state for conn (its block is framed by the character).
public virtual void WritePayload(NetworkConnection conn, Writer writer)
Parameters
connNetworkConnectionwriterWriter