Table of Contents

Class PartySystem

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

Manages party creation, invitations, membership, and updates for the MMO server. Handles party broadcasts, chat commands, and synchronizes party state with the database. Game logic and Broadcasts run synchronously on the main thread. Database operations are async to avoid blocking the main thread. Results from async DB queries that require main-thread state changes or Broadcasts are marshalled via IPartySystemMainThreadQueueData.

[CreateAssetMenu(fileName = "PartySystem", menuName = "FishMMO/Server/SceneServer/Party System", order = 1)]
[RequiresDataContainer(typeof(PartySystemRuntimeData))]
[RequiresDataContainer(typeof(PartyCharacterMappingData))]
[RequiresDataContainer(typeof(PartySystemMainThreadQueueData))]
[RequiresDataContainer(typeof(PartyCombatMeterData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class PartySystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IPartySystem<NetworkConnection>, IServerBehaviour, IServerComponent
Inheritance
Object
ScriptableObject
PartySystem
Implements
IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
IPartySystem<NetworkConnection>
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

PartyCreateAchievementTemplate

[Header("Achievements")]
public AchievementTemplate PartyCreateAchievementTemplate

Field Value

AchievementTemplate

PartyJoinAchievementTemplate

Achievement template awarded when a character joins a party.

public AchievementTemplate PartyJoinAchievementTemplate

Field Value

AchievementTemplate

Properties

MaxPartySize

Maximum number of members allowed in a party.

public int MaxPartySize { get; }

Property Value

int

UpdatePumpRate

The server party update pump rate limit in seconds.

public float UpdatePumpRate { get; }

Property Value

float

Methods

AddPartyCharacterTracker(long, long)

Adds a mapping for the Party to Party Members connected to this Scene Server.

public void AddPartyCharacterTracker(long partyID, long characterID)

Parameters

partyID long
characterID long

CharacterSystem_OnConnect(NetworkConnection, IPlayerCharacter)

Handles character connect event, adding the character to the party tracker and saving party update.

public void CharacterSystem_OnConnect(NetworkConnection conn, IPlayerCharacter character)

Parameters

conn NetworkConnection
character IPlayerCharacter

CharacterSystem_OnDisconnect(NetworkConnection, IPlayerCharacter)

Handles character disconnect event, removing the character from the party tracker and saving party update.

public void CharacterSystem_OnDisconnect(NetworkConnection conn, IPlayerCharacter character)

Parameters

conn NetworkConnection
character IPlayerCharacter

InitializeOnce()

Called once to initialize the party system. Registers chat commands, broadcast handlers, and character events.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

OnDeinitialize()

Called when the system is being destroyed. Unregisters broadcast handlers and character events.

public override void OnDeinitialize()

OnPartyInvite(IPlayerCharacter, ChatBroadcast)

Handles party invite chat commands.

public bool OnPartyInvite(IPlayerCharacter sender, ChatBroadcast msg)

Parameters

sender IPlayerCharacter
msg ChatBroadcast

Returns

bool

OnServerPartyAcceptInviteBroadcastReceived(NetworkConnection, PartyAcceptInviteBroadcast, Channel)

Handles acceptance of a party invitation, validates the invite, adds the character to the party, and broadcasts the update.

public void OnServerPartyAcceptInviteBroadcastReceived(NetworkConnection conn, PartyAcceptInviteBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the accepting character.

msg PartyAcceptInviteBroadcast

PartyAcceptInviteBroadcast message containing acceptance details.

channel Channel

Network channel used for the broadcast.

OnServerPartyChangeRankBroadcastReceived(NetworkConnection, PartyChangeRankBroadcast, Channel)

Handles party rank change broadcast, validates leader and target, and updates ranks in the database. Only party leaders can promote another member to leader.

public void OnServerPartyChangeRankBroadcastReceived(NetworkConnection conn, PartyChangeRankBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the requester.

msg PartyChangeRankBroadcast

PartyChangeRankBroadcast message containing target member ID.

channel Channel

Network channel used for the broadcast.

OnServerPartyCreateBroadcastReceived(NetworkConnection, PartyCreateBroadcast, Channel)

Handles party creation broadcast, validates and creates a new party for the requesting character.

public void OnServerPartyCreateBroadcastReceived(NetworkConnection conn, PartyCreateBroadcast msg, Channel channel)

Parameters

conn NetworkConnection
msg PartyCreateBroadcast
channel Channel

OnServerPartyDeclineInviteBroadcastReceived(NetworkConnection, PartyDeclineInviteBroadcast, Channel)

Handles decline of a party invitation, removes pending invitation for the character.

public void OnServerPartyDeclineInviteBroadcastReceived(NetworkConnection conn, PartyDeclineInviteBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the declining character.

msg PartyDeclineInviteBroadcast

PartyDeclineInviteBroadcast message containing decline details.

channel Channel

Network channel used for the broadcast.

OnServerPartyInviteBroadcastReceived(NetworkConnection, PartyInviteBroadcast, Channel)

Handles party invitation broadcast, validates inviter and target, and sends invitation to the target character. Only party leaders can invite, and invitations are tracked to prevent duplicates.

public void OnServerPartyInviteBroadcastReceived(NetworkConnection conn, PartyInviteBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the inviter.

msg PartyInviteBroadcast

PartyInviteBroadcast message containing inviter and target IDs.

channel Channel

Network channel used for the broadcast.

OnServerPartyLeaveBroadcastReceived(NetworkConnection, PartyLeaveBroadcast, Channel)

Handles party leave broadcast, validates character, transfers leadership if needed, removes member from party, and updates or deletes party as appropriate.

public void OnServerPartyLeaveBroadcastReceived(NetworkConnection conn, PartyLeaveBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the leaving character.

msg PartyLeaveBroadcast

PartyLeaveBroadcast message containing leave details.

channel Channel

Network channel used for the broadcast.

OnServerPartyRemoveBroadcastReceived(NetworkConnection, PartyRemoveBroadcast, Channel)

Handles party member removal broadcast, validates and removes a member from the party in the database. Only party leaders can remove other members.

public void OnServerPartyRemoveBroadcastReceived(NetworkConnection conn, PartyRemoveBroadcast msg, Channel channel)

Parameters

conn NetworkConnection

Network connection of the requester.

msg PartyRemoveBroadcast

PartyRemoveBroadcast message containing member ID to remove.

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

RemoveCharacterFromPartyAsync(long, long, string)

Drops a character out of a party it cannot belong to, with no connection involved.

public Task<bool> RemoveCharacterFromPartyAsync(long characterID, long partyID, string reason)

Parameters

characterID long

Character being removed.

partyID long

Party it is being removed from.

reason string

Why, for the log line.

Returns

Task<bool>

Remarks

Called while a character is loading, before it has been spawned — principally when it has arrived on a world server other than the one its party belongs to. Parties are replicated between scene servers by a pump scoped to a single world server, so a membership that crossed would be updated by pumps that cannot see each other and would never converge; the membership is dropped on arrival instead.

Nothing is broadcast. There is no client yet to tell, and the character will be sent its party state — an absent one — as part of the load it is in the middle of.

RemovePartyCharacterTracker(long, long)

Removes the mapping of Party to Party Members connected to this Scene Server.

public void RemovePartyCharacterTracker(long partyID, long characterID)

Parameters

partyID long
characterID long

TryAddCharacterToPartyAsync(NetworkConnection, long, long, float)

Adds a character to an existing party without an invitation, on behalf of the dungeon finder. Call from an async worker.

public Task<bool> TryAddCharacterToPartyAsync(NetworkConnection conn, long characterID, long partyID, float healthPCT)

Parameters

conn NetworkConnection

The joining character's connection.

characterID long

The joining character.

partyID long

Party that owns the instance being joined.

healthPCT float

Current health fraction, for the party roster.

Returns

Task<bool>

True when membership was persisted; false when it was refused or failed.

Remarks

Joining somebody else's dungeon joins their group. It has to: an instance's leadership, its kick authority, and its very identity are all the owning party's, so a character standing inside one while belonging to nobody would be in a run with no one able to manage them and no way for them to be found by it again.

This is not an invitation bypass. The only caller is the dungeon finder, and it calls this only after establishing that the party has published a joinable instance — which is an explicit, revocable offer by that party's leader. A character who already belongs to a party is refused before reaching here rather than being moved, because silently removing somebody from a group they are in, and possibly lead, is not something a click on a dungeon list should be able to do.

Capacity is enforced against the same MaxPartySize the invitation path uses. A full party's instance simply cannot be joined, which is the correct outcome: there would be nobody to add the joiner to.

TryCreatePartyForInstanceAsync(NetworkConnection, long, long, string, float)

Forms a party of one for a character who is opening a dungeon others may join. Call from an async worker.

public Task<long> TryCreatePartyForInstanceAsync(NetworkConnection conn, long characterID, long worldServerID, string sceneName, float healthPCT)

Parameters

conn NetworkConnection

The character's connection.

characterID long

The character forming the party.

worldServerID long

World server the party will belong to.

sceneName string

Scene name, for the create broadcast's location field.

healthPCT float

Current health fraction, for the party roster.

Returns

Task<long>

The new party ID, or 0 when it could not be created.

Remarks

An instance is owned by a party, and joining one joins that party — so an instance opened by somebody with no party has no group for a joiner to be added to, and could only ever be a solo run. Rather than refusing to let ungrouped players advertise at all, opening a dungeon publicly forms the party the listing implies.

Only reached when the player has explicitly chosen to open the dungeon publicly. A private or solo run creates no party, because none is needed and forming one silently would be a side effect the player did not ask for.