using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Steamworks.Data; namespace Steamworks { /// /// This API can be used to selectively advertise your multiplayer game session in a Steam chat room group. /// Tell Steam the number of player spots that are available for your party, and a join-game string, and it /// will show a beacon in the selected group and allow that many users to “follow” the beacon to your party. /// Adjust the number of open slots if other players join through alternate matchmaking methods. /// public class SteamParties : SteamClientClass { internal static ISteamParties? Internal => Interface as ISteamParties; internal override bool InitializeInterface( bool server ) { SetInterface( server, new ISteamParties( server ) ); if ( Interface is null || Interface.Self == IntPtr.Zero ) return false; InstallEvents( server ); return true; } internal void InstallEvents( bool server ) { Dispatch.Install( x => OnBeaconLocationsUpdated?.Invoke(), server ); Dispatch.Install( x => OnActiveBeaconsUpdated?.Invoke(), server ); } /// /// Invoked when the list of possible Party beacon locations has changed /// public static event Action? OnBeaconLocationsUpdated; /// /// Invoked when the list of active beacons may have changed /// public static event Action? OnActiveBeaconsUpdated; /// /// Gets the amount of beacons that are active. /// public static int ActiveBeaconCount => (int)(Internal?.GetNumActiveBeacons() ?? 0); /// /// Gets an of active beacons. /// public static IEnumerable ActiveBeacons { get { for ( uint i = 0; i < ActiveBeaconCount; i++ ) { yield return new PartyBeacon { Id = Internal?.GetBeaconByIndex( i ) ?? 0 }; } } } } }