mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +03:00
Added Duration Control
This commit is contained in:
parent
f495d18ece
commit
fc74049123
@ -39,6 +39,7 @@ namespace Steamworks
|
||||
Dispatch.Install<MicroTxnAuthorizationResponse_t>( x => OnMicroTxnAuthorizationResponse?.Invoke( x.AppID, x.OrderID, x.Authorized != 0 ) );
|
||||
Dispatch.Install<GameWebCallback_t>( x => OnGameWebCallback?.Invoke( x.URLUTF8() ) );
|
||||
Dispatch.Install<GetAuthSessionTicketResponse_t>( x => OnGetAuthSessionTicketResponse?.Invoke( x ) );
|
||||
Dispatch.Install<DurationControl_t>( x => OnDurationControl?.Invoke( new DurationControl { _inner = x } ) );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -101,6 +102,13 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public static event Action<string> OnGameWebCallback;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public static event Action<DurationControl> OnDurationControl;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -470,5 +478,16 @@ namespace Steamworks
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get anti indulgence / duration control
|
||||
/// </summary>
|
||||
public static async Task<DurationControl> GetDurationControl()
|
||||
{
|
||||
var response = await Internal.GetDurationControl();
|
||||
if ( !response.HasValue ) return default;
|
||||
|
||||
return new DurationControl { _inner = response.Value };
|
||||
}
|
||||
}
|
||||
}
|
42
Facepunch.Steamworks/Structs/DurationControl.cs
Normal file
42
Facepunch.Steamworks/Structs/DurationControl.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public struct DurationControl
|
||||
{
|
||||
internal DurationControl_t _inner;
|
||||
|
||||
/// <summary>
|
||||
/// appid generating playtime
|
||||
/// </summary>
|
||||
public AppId Appid => _inner.Appid;
|
||||
|
||||
/// <summary>
|
||||
/// is duration control applicable to user + game combination
|
||||
/// </summary>
|
||||
public bool Applicable => _inner.Applicable;
|
||||
|
||||
/// <summary>
|
||||
/// playtime since most recent 5 hour gap in playtime, only counting up to regulatory limit of playtime, in seconds
|
||||
/// </summary>
|
||||
internal TimeSpan PlaytimeInLastFiveHours => TimeSpan.FromSeconds( _inner.CsecsLast5h );
|
||||
|
||||
/// <summary>
|
||||
/// playtime on current calendar day
|
||||
/// </summary>
|
||||
internal TimeSpan PlaytimeToday => TimeSpan.FromSeconds( _inner.CsecsLast5h );
|
||||
|
||||
/// <summary>
|
||||
/// recommended progress
|
||||
/// </summary>
|
||||
internal DurationControlProgress Progress => _inner.Progress;
|
||||
}
|
||||
}
|
@ -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";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user