Class XboxAchievementGateway
Reference template for mirroring unlocks to an Xbox player's achievement list through the Microsoft GDK. Reports itself unavailable and writes nothing.
Implements
Inherited Members
Namespace: Serenity.Achievements.Infrastructure.Platforms.Gateways
Assembly: Serenity.UnityAchievements.Infrastructure.dll
Syntax
public sealed class XboxAchievementGateway : InertAchievementPlatformGateway, IAchievementPlatformGateway
Remarks
The GDK and its Xbox Live libraries are distributed under a Microsoft developer agreement
and cannot ship inside Serenity, so this type deliberately stays inert: it keeps the platform
branch readable and records the call sequence a licensee needs, nothing more. Structural twin
of Ps5SdkAdaptiveTriggerBackend, which solves the same problem for adaptive triggers.
To write real achievements, implement IAchievementPlatformGateway in your own
assembly — where you may reference the GDK — and register it through
SetFactory(Func<IAchievementPlatformGateway>). The registry is consulted before
the platform definition assets, so no Serenity source needs editing and the override survives
a package update.
What such an implementation has to do, and the knowledge this template exists to preserve:
- Hold the
XblContextHandlefor the signed-in user and that user's XUID. Both come from the GDK's user model (XUserAddAsyncthenXblContextCreateHandle), which is the project's own sign-in flow, not the achievement gateway's. - Unlock and progress are the SAME call:
XblAchievementsUpdateAchievementAsync(xblContext, xuid, achievementId, percentComplete), whereachievementIdisAchievementPlatformMapping.XboxAchievementIdand 100 means unlocked. Serenity's numerator/target become a percentage on the way out. - Read the account back with
XblAchievementsGetAchievementsForTitleIdAsync, filtering toXblAchievementsUnlockedFilter, then map each returned id back to anAchievementIdthrough the project's own mapping. - There is no clear: Xbox achievements are permanent on a retail account, and the title's sandbox is the only place a developer account can be reset. Answer false rather than pretending.
- The service configuration id and title id from
UnityXboxAchievementPlatformDefinitionmust match the ones baked into the MicrosoftGame.config the build ships, or every call fails authentication.
Constructors
XboxAchievementGateway(AchievementPlatformGatewayContext)
Initializes the Xbox template gateway.
Declaration
public XboxAchievementGateway(AchievementPlatformGatewayContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementPlatformGatewayContext | context | The gateway context. Only its log service is read while inert. |