Table of Contents

Class Pet

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Represents a pet NPC, including owner, abilities, orders, and network payload logic.

public class Pet : NPC, ICharacter, ISpawnable, ILootableCorpse, IInteractable, ISceneObject
Inheritance
Object
Component
Behaviour
MonoBehaviour
NetworkBehaviour
Pet
Implements
Inherited Members
NetworkBehaviour.IsSpawned
NetworkBehaviour.ComponentIndex
NetworkBehaviour.NetworkObject
NetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURS
NetworkBehaviour.UNSET_NETWORKBEHAVIOUR_ID
NetworkBehaviour.ToString()
NetworkBehaviour.Reset()
NetworkBehaviour.IsBehaviourReconciling
NetworkBehaviour.ClearReplicateCache()
NetworkBehaviour.CreateReconcile()
NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)
NetworkBehaviour.OnStartServerCalled
NetworkBehaviour.OnStartClientCalled
NetworkBehaviour.OnStartNetwork()
NetworkBehaviour.OnStopNetwork()
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
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

Action<long, Pet>

PetAbilityTemplate

The template defining this pet's abilities and behavior.

public PetAbilityTemplate PetAbilityTemplate

Field Value

PetAbilityTemplate

PetOwner

The character that owns this pet.

public ICharacter PetOwner

Field Value

ICharacter

Properties

MovementOrder

Whether the pet is heeling or holding position.

public PetMovementOrder MovementOrder { get; set; }

Property Value

PetMovementOrder

PersistedAttributes

Attribute values restored from the database, applied at spawn.

public List<PetPersistedAttribute> PersistedAttributes { get; set; }

Property Value

List<PetPersistedAttribute>

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

List<PetPersistedBuff>

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

List<int>

Stance

How willing this pet is to start a fight on its own.

public PetStance Stance { get; set; }

Property Value

PetStance

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

abilities List<int>

List of ability template IDs to learn.

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

connection NetworkConnection

The network connection.

reader Reader

The network reader.

ResetState(bool)

Resets the pet's state, clearing owner, orders, and abilities.

public override void ResetState(bool asServer)

Parameters

asServer bool

Whether 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

connection NetworkConnection

The network connection.

writer Writer

The network writer.