Table of Contents

Class PlayerCharacter

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Represents a player-controlled character in the game world, with inventory, abilities, and networked state. Implements IPlayerCharacter and extends BaseCharacter with player-specific logic, hotkeys, and event-driven behaviour.

Coupling note: This class uses 19 UnityEngine.RequireComponent attributes, creating strong coupling between PlayerCharacter and its component dependencies. All required components are tightly bound to this class and cannot be removed/replaced without modifying this declaration block. If a more modular composition approach is desired in the future (e.g., optional components registered at runtime), this set of RequireComponent attributes would need to be refactored into a dynamic registration system.

[RequireComponent(typeof(CharacterAttributeController))]
[RequireComponent(typeof(TargetController))]
[RequireComponent(typeof(CooldownController))]
[RequireComponent(typeof(InventoryController))]
[RequireComponent(typeof(EquipmentController))]
[RequireComponent(typeof(BankController))]
[RequireComponent(typeof(AbilityController))]
[RequireComponent(typeof(AchievementController))]
[RequireComponent(typeof(BuffController))]
[RequireComponent(typeof(QuestController))]
[RequireComponent(typeof(CharacterDamageController))]
[RequireComponent(typeof(GuildController))]
[RequireComponent(typeof(PartyController))]
[RequireComponent(typeof(FriendController))]
[RequireComponent(typeof(FactionController))]
[RequireComponent(typeof(CharacterPredictionController))]
[RequireComponent(typeof(BodyVisibilityManager))]
[RequireComponent(typeof(CharacterAppearanceManager))]
[RequireComponent(typeof(EquipmentVisualController))]
[RequireComponent(typeof(CharacterAnimationController))]
public class PlayerCharacter : BaseCharacter, IPlayerCharacter, ICharacter
Inheritance
Object
Component
Behaviour
MonoBehaviour
NetworkBehaviour
PlayerCharacter
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.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

Properties

AccessLevel

The access level of the character (e.g., player, admin).

public AccessLevel AccessLevel { get; set; }

Property Value

AccessLevel

Account

The account name associated with this character.

public string Account { get; set; }

Property Value

string

BindPosition

The position in the bind scene for respawn.

public Vector3 BindPosition { get; set; }

Property Value

Vector3

BindScene

The name of the bind scene for respawn.

public string BindScene { get; set; }

Property Value

string

CharacterController

The KCC controller for character movement logic.

public KCCController CharacterController { get; }

Property Value

KCCController

CharacterName

The character's real name. Use this for referencing by name.

public string CharacterName { get; set; }

Property Value

string

CharacterNameLower

The lowercase version of the character's name, for case-insensitive operations.

public string CharacterNameLower { get; set; }

Property Value

string

ChatTokenLastRefillTicks

UTC ticks of the last token bucket refill.

public long ChatTokenLastRefillTicks { get; set; }

Property Value

long

ChatTokens

Current number of chat tokens available in the token bucket (double for precision on long-uptime servers). Server-side anti-spam: consumed per message, refilled at a configurable rate.

public double ChatTokens { get; set; }

Property Value

double

EquipmentViewCamera

Gets or sets the equipment view camera.

public Camera EquipmentViewCamera { get; set; }

Property Value

Camera

Hotkeys

The list of hotkey data for the character.

public List<HotkeyData> Hotkeys { get; set; }

Property Value

List<HotkeyData>

InstanceID

The instance ID for instanced content.

public long InstanceID { get; set; }

Property Value

long

InstancePosition

The position in the instance scene.

public Vector3 InstancePosition { get; set; }

Property Value

Vector3

InstanceRotation

The rotation in the instance scene.

public Quaternion InstanceRotation { get; set; }

Property Value

Quaternion

InstanceSceneHandle

Identity of the instance scene the character is inside — the scenes.id of its row. See SceneHandle.

public long InstanceSceneHandle { get; set; }

Property Value

long

InstanceSceneName

The name of the instance scene.

public string InstanceSceneName { get; set; }

Property Value

string

IsChatTokensFull

Indicates whether ChatTokens is in its initial "filled to capacity" state (no refill applied yet). Used instead of double.MaxValue as a sentinel to avoid overflow to Infinity on first add.

public bool IsChatTokensFull { get; set; }

Property Value

bool

IsTeleporting

Whether the character is currently teleporting (true if TeleporterName is set).

public override bool IsTeleporting { get; }

Property Value

bool

KCCPlayer

The KCC player component for input and control.

public KCCPlayer KCCPlayer { get; }

Property Value

KCCPlayer

LastChatMessage

The last chat message sent by the character.

public string LastChatMessage { get; set; }

Property Value

string

LastWorldPosition

Where the character stood in the open world before entering an instance, and where it is put back when it leaves one.

public Vector3 LastWorldPosition { get; set; }

Property Value

Vector3

Remarks

The character row carries two positions — the open-world one and the instance one — but a spawned character has only one transform, so while it is inside an instance the transform describes the instance and something has to remember the other. Without this, every save taken inside a dungeon overwrote the open-world position with dungeon coordinates, and a character released from a dead instance was placed at those coordinates in the open world: through terrain, or outside the playable bounds entirely, until the out-of-bounds sweep noticed and relocated them.

LastWorldRotation

Rotation to restore alongside LastWorldPosition.

public Quaternion LastWorldRotation { get; set; }

Property Value

Quaternion

ModelIndex

The model index for the character's race.

public int ModelIndex { get; set; }

Property Value

int

Motor

The kinematic character motor for movement.

public KinematicCharacterMotor Motor { get; }

Property Value

KinematicCharacterMotor

NextChatMessageTicks

The next UTC ticks when the character can send a chat message.

public long NextChatMessageTicks { get; set; }

Property Value

long

NextInteractTime

The next UTC time the character can interact.

public DateTime NextInteractTime { get; set; }

Property Value

DateTime

RaceID

The Race Template ID for the character object.

public int RaceID { get; set; }

Property Value

int

RaceName

The name of the character's race.

public string RaceName { get; set; }

Property Value

string

SceneHandle

Identity of the scene instance the character belongs to: the scenes.id of the row describing it.

public long SceneHandle { get; set; }

Property Value

long

Remarks

This used to hold the hosting scene server's local scene-manager handle, which is only meaningful inside that one process. Two scene servers running the same build routinely allocate identical handles, so the value could not tell one server's instance from another's: the world server's routing map collided between them, and a scene server accepted a character routed to a different server's instance whenever the handle and scene name happened to match. The row ID is unique by construction.

SceneName

The name of the current scene.

public string SceneName { get; set; }

Property Value

string

TeleporterName

The name of the teleporter the character is currently using.

public string TeleporterName { get; set; }

Property Value

string

TimeCreated

The UTC time when the character was created.

public DateTime TimeCreated { get; set; }

Property Value

DateTime

Version

The current version of the character data, used for optimistic concurrency control when saving/loading from the database.

public long Version { get; set; }

Property Value

long

WorldServerID

The world server ID this character belongs to.

public long WorldServerID { get; set; }

Property Value

long

Methods

IsInInstance()

Returns true if the character is in an instance and the instance scene name is set.

public bool IsInInstance()

Returns

bool

IsLoaded()

Returns true if the character is currently loaded in the scene and active.

public bool IsLoaded()

Returns

bool

OnAwake()

Initializes the player character and its hotkeys. Sets up KCC movement components and resets chat/interact timers.

public override void OnAwake()

OnOwnershipClient(NetworkConnection)

Called on the client after gaining or losing ownership.

public override void OnOwnershipClient(NetworkConnection prevOwner)

Parameters

prevOwner NetworkConnection

Previous owner of this object.

OnStartClient()

Called on the client after initializing this object.

public override void OnStartClient()

OnStopClient()

Called when the client stops. Invokes OnStopLocalClient and stops all character behaviours for the local player.

public override void OnStopClient()

ReadPayload(NetworkConnection, Reader)

Reads the character's payload from the network connection and updates core properties. Invokes OnReadPayload event and instantiates the race model on the client.

public override void ReadPayload(NetworkConnection connection, Reader reader)

Parameters

connection NetworkConnection

The network connection to read from.

reader Reader

The reader containing serialized data.

ResetHotkeys()

Resets the hotkeys to the default configuration. Initializes each hotkey slot.

public void ResetHotkeys()

ResetState(bool)

Resets the character's state, including teleportation, chat/interact timers, instance data, and hotkeys. This is called when the character is despawned or removed from the world.

public override void ResetState(bool asServer)

Parameters

asServer bool

True if called on the server, false if on the client.

SetGuildName(string)

Sets the character's guild name label (client only). Updates the label text if available.

public void SetGuildName(string guildName)

Parameters

guildName string

The name of the guild to set.

Teleport(string)

Teleports the character to the specified teleporter name and invokes the teleport event.

public void Teleport(string teleporterName)

Parameters

teleporterName string

The name of the teleporter to use.

WritePayload(NetworkConnection, Writer)

Writes the character's payload to the network connection for serialization.

public override void WritePayload(NetworkConnection connection, Writer writer)

Parameters

connection NetworkConnection

The network connection to write to.

writer Writer

The writer to serialize data into.