diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs index e21f221..f35f6e2 100644 --- a/Facepunch.Steamworks/SteamUser.cs +++ b/Facepunch.Steamworks/SteamUser.cs @@ -39,6 +39,7 @@ namespace Steamworks Dispatch.Install( x => OnMicroTxnAuthorizationResponse?.Invoke( x.AppID, x.OrderID, x.Authorized != 0 ) ); Dispatch.Install( x => OnGameWebCallback?.Invoke( x.URLUTF8() ) ); Dispatch.Install( x => OnGetAuthSessionTicketResponse?.Invoke( x ) ); + Dispatch.Install( x => OnDurationControl?.Invoke( new DurationControl { _inner = x } ) ); } /// @@ -101,6 +102,13 @@ namespace Steamworks /// public static event Action OnGameWebCallback; + /// + /// Sent for games with enabled anti indulgence / duration control, for enabled users. + /// Lets the game know whether persistent rewards or XP should be granted at normal rate, + /// half rate, or zero rate. + /// + public static event Action OnDurationControl; + @@ -470,5 +478,16 @@ namespace Steamworks } + + /// + /// Get anti indulgence / duration control + /// + public static async Task GetDurationControl() + { + var response = await Internal.GetDurationControl(); + if ( !response.HasValue ) return default; + + return new DurationControl { _inner = response.Value }; + } } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Structs/DurationControl.cs b/Facepunch.Steamworks/Structs/DurationControl.cs new file mode 100644 index 0000000..4161692 --- /dev/null +++ b/Facepunch.Steamworks/Structs/DurationControl.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + + +namespace Steamworks.Data +{ + /// + /// Sent for games with enabled anti indulgence / duration control, for enabled users. + /// Lets the game know whether persistent rewards or XP should be granted at normal rate, half rate, or zero rate. + /// + public struct DurationControl + { + internal DurationControl_t _inner; + + /// + /// appid generating playtime + /// + public AppId Appid => _inner.Appid; + + /// + /// is duration control applicable to user + game combination + /// + public bool Applicable => _inner.Applicable; + + /// + /// playtime since most recent 5 hour gap in playtime, only counting up to regulatory limit of playtime, in seconds + /// + internal TimeSpan PlaytimeInLastFiveHours => TimeSpan.FromSeconds( _inner.CsecsLast5h ); + + /// + /// playtime on current calendar day + /// + internal TimeSpan PlaytimeToday => TimeSpan.FromSeconds( _inner.CsecsLast5h ); + + /// + /// recommended progress + /// + internal DurationControlProgress Progress => _inner.Progress; + } +} \ No newline at end of file diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs index df6701b..6afb829 100644 --- a/Generator/Cleanup.cs +++ b/Generator/Cleanup.cs @@ -130,6 +130,7 @@ public static class Cleanup if ( name == "ConnectionState" ) return "public"; if ( name == "SteamNetworkingAvailability" ) return "public"; if ( name == "SteamDeviceFormFactor" ) return "public"; + if ( name == "DurationControlProgress" ) return "public"; return "internal"; }