UIParty - jimdroberts/FishMMO GitHub Wiki

Description

UI control for party management: displays party members, updates health and rank display, and handles party actions such as create, leave, and invite. Subscribes to IPartyController events to keep the UI in sync with server state.


API Access

Fields

  • public RectTransform PartyMemberParent

    Parent transform used to host instantiated UIPartyMember entries.

  • public UIPartyMember PartyMemberPrefab

    Prefab used to create party member UI entries.

  • public Dictionary<long, UIPartyMember> Members

    Mapping of character ID -> instantiated UIPartyMember entries.

Methods

  • public override void OnDestroying()

    Cleans up and destroys all member UI elements when the UI is destroyed.

  • public override void OnPostSetCharacter()

    Subscribes to IPartyController events: party created, receive invite, add/remove member, validate members, leave party.

  • public override void OnPreUnsetCharacter()

    Unsubscribes from IPartyController events before the character is unset.

  • public void PartyController_OnReceivePartyInvite(long inviterCharacterID)

    Shows a dialog prompting the player to accept or decline a party invite; broadcasts accept/decline messages accordingly.

  • public void PartyController_OnValidatePartyMembers(HashSet newMembers)

    Removes any local UI members that are no longer present in the provided set.

  • public void OnPartyCreated(string location)

    Instantiates the local player as a party member in the UI and sets initial health and rank display.

  • public void OnLeaveParty()

    Removes and destroys all party member UI entries.

  • public void OnPartyAddMember(long characterID, PartyRank rank, float healthPCT)

    Adds or updates a party member entry, resolves the member's name asynchronously and updates rank/health display.

  • public void OnPartyRemoveMember(long characterID)

    Removes the party member entry for the specified character ID.

  • public void OnButtonCreateParty()

    Broadcasts a PartyCreateBroadcast to request party creation if the player isn't already in a party.

  • public void OnButtonLeaveParty()

    Opens a confirmation dialog and broadcasts a PartyLeaveBroadcast when confirmed.

  • public void OnButtonInviteToParty()

    Invites the targeted player or prompts for a name to invite; sends PartyInviteBroadcast with the target character ID.


Basic Usage

Setup

  1. Attach UIParty to a UI GameObject and assign PartyMemberParent to a RectTransform container.
  2. Assign PartyMemberPrefab to a prefab that exposes Name, Rank, and Health UI elements.
  3. Ensure the player's IPartyController is available so the component can subscribe to party events.

Example

var uiParty = GetComponent<UIParty>();
uiParty.PartyMemberPrefab = partyMemberPrefab;
uiParty.PartyMemberParent = partyMemberListParent;
// The UI will update as party events are received from the server.

Best Practices

  • Use layout components for PartyMemberParent to keep entries ordered and sized correctly.
  • Avoid heavy logic in name-resolution callbacks; update only relevant UI fields.
  • Clear event subscriptions on pre-unset to prevent duplicate handlers when changing characters.
  • Pool UIPartyMember entries if party UI is opened/closed often to reduce allocations.
  • Ensure IPartyController server-side validation prevents unauthorized invites or rank changes.
⚠️ **GitHub.com Fallback** ⚠️