Class AchievementPlatformGatewayRegistry
Registration point for a game-supplied IAchievementPlatformGateway.
Inherited Members
Namespace: Serenity.Achievements.Infrastructure.Platforms
Assembly: Serenity.UnityAchievements.Infrastructure.dll
Syntax
public static class AchievementPlatformGatewayRegistry
Remarks
Trophies on a licensed console are driven through a platform SDK whose headers cannot ship
inside Serenity. Without this seam the only way to reach that SDK would be editing
UnityAchievementInstaller directly, and the next package update would overwrite the edit. A
factory registered here is consulted before the platform definition assets, so a licensee
owns their gateway in their own assembly and keeps it across updates.
Register before the achievements module installs — a [RuntimeInitializeOnLoadMethod] with
RuntimeInitializeLoadType.BeforeSceneLoad is the usual place. Registering later has no effect
on an already-installed module.
Two SetFactory overloads, because a gateway that only pushes unlocks outward needs
nothing from Serenity, while one that reads the storefront account back needs the achievements
this project declares — a storefront names them by its own identifier and cannot map them
back on its own. Take the AchievementPlatformGatewayContext overload for the
second kind; the parameterless one stays for the first.
Structural copy of AdaptiveTriggerBackendRegistry, which solves the same problem for
adaptive triggers; the shape is deliberately identical so a licensee who has met one has met both.
Properties
HasFactory
Declaration
public static bool HasFactory { get; }
Property Value
| Type | Description |
|---|---|
| bool | True when a factory has been registered, whether or not it produces a usable gateway. |
Methods
ClearFactory()
Clears any registered factory, restoring the definition-asset selection.
Declaration
public static void ClearFactory()
SetFactory(Func<IAchievementPlatformGateway>)
Registers the factory consulted before the platform definition assets.
Declaration
public static void SetFactory(Func<IAchievementPlatformGateway> factory)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IAchievementPlatformGateway> | factory | Creates the gateway. Pass null to clear a previous registration. |
Remarks
For a gateway that only pushes unlocks outward. One that reads the account back wants the overload carrying an AchievementPlatformGatewayContext.
SetFactory(Func<AchievementPlatformGatewayContext, IAchievementPlatformGateway>)
Registers the factory consulted before the platform definition assets.
Declaration
public static void SetFactory(Func<AchievementPlatformGatewayContext, IAchievementPlatformGateway> factory)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<AchievementPlatformGatewayContext, IAchievementPlatformGateway> | factory | Creates the gateway from the achievements this project declares and the log service. Pass null to clear a previous registration. |
TryCreate(AchievementPlatformGatewayContext, out IAchievementPlatformGateway)
Creates the registered gateway, if any.
Declaration
public static bool TryCreate(AchievementPlatformGatewayContext context, out IAchievementPlatformGateway gateway)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementPlatformGatewayContext | context | What the gateway is built from. May be |
| IAchievementPlatformGateway | gateway | The created gateway, or null when none is available. |
Returns
| Type | Description |
|---|---|
| bool | True when a registered factory produced a usable gateway. |
Remarks
A factory that throws or returns null is reported and treated as absent rather than propagated: a broken override degrades to the configured platform assets instead of failing the whole achievements install.