Skip to content

Game.Achievements.GdkAchievementsMapping

Assembly:
Assembly-CSharp (default game assembly for runtime types)
Namespace: Game.Achievements

Type:
class

Base:
GdkAchievementsMapper

Summary:
GdkAchievementsMapping is a concrete mapper that links the game's internal Achievements enum values to numeric achievement IDs used by the Microsoft GDK achievement system. It is decorated with [Preserve] to avoid code stripping and populates the GDK mapping via calls to the inherited Map(...) method in the constructor. This mapping is used when reporting or synchronizing achievement progress with the GDK/Xbox services.


Fields

  • This class declares no instance or static fields.
    This class only performs mapping logic inside the constructor and relies on the base class (GdkAchievementsMapper) to store mappings.

Properties

  • This class declares no additional properties.
    Any mapping storage or accessors are provided by the base GdkAchievementsMapper.

Constructors

  • public GdkAchievementsMapping()
    Initializes the mapper and registers all achievement mappings between the game's Achievements enum and the numeric IDs expected by the Microsoft GDK. Each call to Map associates one enum member with an integer ID. Example mappings registered by this constructor include:
  • Achievements.MyFirstCity -> 1
  • Achievements.TheInspector -> 2
  • Achievements.HappytobeofService -> 3
  • Achievements.RoyalFlush -> 4
  • ... (continues for all entries defined in the constructor)
  • Achievements.Pierfect -> 45
  • Achievements.Cartography -> 39

Remarks: - IDs are the external GDK achievement identifiers; they must match the IDs configured in your GDK/Xbox developer dashboard. - Adjust or extend mappings here if you add or renumber achievements in the GDK configuration.

Methods

  • This class does not declare additional methods.
    It uses the inherited Map(AchievementEnum, int) method from GdkAchievementsMapper inside the constructor to register mappings. There are no overrides or other methods implemented in this class.

Usage Example

using UnityEngine.Scripting;
using Colossal.PSI.MicrosoftGdk;

namespace Game.Achievements;

[Preserve]
public class GdkAchievementsMapping : GdkAchievementsMapper
{
    public GdkAchievementsMapping()
    {
        // Map internal Achievement enum values to GDK numeric IDs
        Map(Achievements.MyFirstCity, 1);
        Map(Achievements.TheInspector, 2);
        Map(Achievements.HappytobeofService, 3);
        // ... additional mappings ...
        Map(Achievements.Pierfect, 45);
        Map(Achievements.Cartography, 39);
    }
}

Additional notes: - Keep the [Preserve] attribute on the class to prevent the linker/IL2CPP from stripping it, as the mapping may be discovered or instantiated via reflection by the GDK integration. - Ensure numeric IDs match the GDK configuration. If the GDK IDs change, update this mapper accordingly. - If you extend achievements in-game, add corresponding Map(...) calls here so they are reported correctly to the Microsoft GDK.