Class Pet
Represents a pet NPC, including owner, abilities, orders, and network payload logic.
public class Pet : NPC, ICharacter, ISpawnable, ILootableCorpse, IInteractable, ISceneObject
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourPet
- Implements
- Inherited Members
-
NetworkBehaviour.IsSpawnedNetworkBehaviour.ComponentIndexNetworkBehaviour.NetworkObjectNetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURSNetworkBehaviour.UNSET_NETWORKBEHAVIOUR_IDNetworkBehaviour.ToString()NetworkBehaviour.Reset()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.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
- Extension Methods
Fields
OnReadID
Event triggered when a pet's owner ID is read from the network payload.
public static Action<long, Pet> OnReadID
Field Value
PetAbilityTemplate
The template defining this pet's abilities and behavior.
public PetAbilityTemplate PetAbilityTemplate
Field Value
PetOwner
The character that owns this pet.
public ICharacter PetOwner
Field Value
Properties
MovementOrder
Whether the pet is heeling or holding position.
public PetMovementOrder MovementOrder { get; set; }
Property Value
PersistedAttributes
Attribute values restored from the database, applied at spawn.
public List<PetPersistedAttribute> PersistedAttributes { get; set; }
Property Value
Remarks
Staged rather than applied directly for the same reason PetAbilityIDs is:
the pet system fills this in before ServerManager.Spawn, and the values can only
be written once OnStartServer() has built the attribute controller and
rolled the prefab's own bonuses over it. See FishMMO.Shared.Pet.ApplyPersistedState().
PersistedBuffs
Buffs restored from the database, applied at spawn.
public List<PetPersistedBuff> PersistedBuffs { get; set; }
Property Value
PetAbilityIDs
The list of ability template IDs that this pet has learned. The name avoids shadowing Abilities (List<AbilityTemplate>).
public List<int> PetAbilityIDs { get; set; }
Property Value
Stance
How willing this pet is to start a fight on its own.
public PetStance Stance { get; set; }
Property Value
Remarks
Server-authoritative. Clients learn it from the spawn payload and from PetStanceBroadcast; they never set it locally, so a modified client cannot put its pet into a stance the server disagrees with.
Methods
CaptureKnownAbilities()
Records the abilities the pet currently knows into PetAbilityIDs so they survive a despawn / re-summon cycle.
public void CaptureKnownAbilities()
Remarks
Called by the pet system before persisting. Without it, abilities granted at summon time from the PetAbilityTemplate were never written to the database and a re-logged pet came back empty.
Despawn()
Returns the pet to the pool immediately, skipping the corpse decay timer.
public override void Despawn()
Remarks
A pet's lifetime is tied to its owner rather than to an ObjectSpawner, so it skips the corpse timer and despawns through the network manager directly. ReturnToPool() routes through the spawner, which a pet does not have, so the previous implementation called it and silently did nothing.
A genuine override, not the new it used to be. Method hiding only applies
when the caller's static type is Pet; anything holding the pet as an
NPC or an ISpawnable — which is how the spawner and several
death paths see it — would silently get the NPC corpse behaviour instead, leaving the
pet parked in the world as an immortal, AI-disabled corpse that nothing ever collects.
LearnAbilities(List<int>)
Records the ability template IDs this pet should know.
public void LearnAbilities(List<int> abilities)
Parameters
Remarks
Only records them. Call LearnPersistedAbilities() to actually teach them to the ability controller — which is the step that was missing entirely: pet ability IDs were loaded from the database, held on this list, and saved back out without ever reaching an IAbilityController, so every pet spawned with an empty spellbook and could never attack.
LearnPersistedAbilities()
Teaches every template ID in PetAbilityIDs to the pet's ability controller, skipping any it already knows.
public void LearnPersistedAbilities()
Remarks
Server-only in effect: the controller is populated authoritatively and replicated, the same way NPC teaches its inspector-configured list.
OnAwake()
Called when the pet is awakened. Initializes the abilities list.
public override void OnAwake()
OnStartServer()
Server spawn. Runs after OnStartServer() has taught the prefab's own ability list, and adds anything restored from the database on top.
public override void OnStartServer()
Remarks
This is the last point at which restored state can be written and still reach clients
in the spawn payload. FishNet invokes the start callbacks during
SpawnWithoutChecks and only writes each observer's payload afterwards, in the
observer rebuild — so anything applied here is serialised, and anything applied after
ServerManager.Spawn returns is not.
ReadPayload(NetworkConnection, Reader)
Reads the pet's payload from the network, including owner ID and current orders.
public override void ReadPayload(NetworkConnection connection, Reader reader)
Parameters
connectionNetworkConnectionThe network connection.
readerReaderThe network reader.
ResetState(bool)
Resets the pet's state, clearing owner, orders, and abilities.
public override void ResetState(bool asServer)
Parameters
asServerboolWhether the reset is performed on the server.
WritePayload(NetworkConnection, Writer)
Writes the pet's payload to the network, including owner ID and current orders.
public override void WritePayload(NetworkConnection connection, Writer writer)
Parameters
connectionNetworkConnectionThe network connection.
writerWriterThe network writer.