Table of Contents

Class FriendSystem

Namespace
FishMMO.Server.Implementation.World.SceneServer
Assembly
FishMMO.Server.dll

Manages player friend lists, including adding and removing friends with validation and database persistence. Game logic and Broadcasts run synchronously on the main thread. Database operations are fire-and-forget async to avoid blocking the main thread. Results from async DB queries that require main-thread Broadcasts are marshalled via IFriendSystemMainThreadQueueData.

[CreateAssetMenu(fileName = "FriendSystem", menuName = "FishMMO/Server/SceneServer/Friend System", order = 1)]
[RequiresDataContainer(typeof(FriendSystemMainThreadQueueData))]
[RequiresDataContainer(typeof(FriendSystemRuntimeData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class FriendSystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IFriendSystem, IServerBehaviour, IServerComponent
Inheritance
Object
ScriptableObject
FriendSystem
Implements
IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
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.ToString()
Object.name
Object.hideFlags

Fields

FriendAddAchievementTemplate

Achievement to increment when a player adds a friend.

[Header("Achievements")]
public AchievementTemplate FriendAddAchievementTemplate

Field Value

AchievementTemplate

Properties

MaxFriends

Maximum number of friends allowed per character.

public int MaxFriends { get; }

Property Value

int

Methods

InitializeOnce()

Initializes the friend system, registering broadcast handlers for friend add and remove requests.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

OnDeinitialize()

Cleans up the friend system, unregistering broadcast handlers.

public override void OnDeinitialize()

OnServerFriendAddNewBroadcastReceived(NetworkConnection, FriendAddNewBroadcast, Channel)

Handles broadcast to add a new friend for a player character. Validates character, friend count, and prevents self-friending. Fires an async task that verifies the friend character exists, persists the friendship, and marshals the in-memory update + Broadcast back to the main thread.

public void OnServerFriendAddNewBroadcastReceived(NetworkConnection conn, FriendAddNewBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the requesting client.

msg FriendAddNewBroadcast

FriendAddNewBroadcast message containing friend data.

channel Channel

Network channel used for the broadcast.

OnServerFriendRemoveBroadcastReceived(NetworkConnection, FriendRemoveBroadcast, Channel)

Handles broadcast to remove a friend for a player character. Validates character, removes friend from in-memory state and broadcasts immediately, then fires an async task to persist the removal to the database.

public void OnServerFriendRemoveBroadcastReceived(NetworkConnection conn, FriendRemoveBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the requesting client.

msg FriendRemoveBroadcast

FriendRemoveBroadcast message containing friend removal data.

channel Channel

Network channel used for the broadcast.

OnUpdate(float)

Drains the main-thread queue each frame.

protected override void OnUpdate(float deltaTime)

Parameters

deltaTime float