Skip to main content

GlobalGameData

The main saveable state container for a play session — difficulty, badges, visited scenes, last heal/player location, step count, and the persistent state of add-on systems (followers, Secret Base, player gym, tower runs). It is a ScriptableObject asset injected via Zenject, and it serializes itself to disk through its savable mirror, SavableGlobalGameData.

global game data

The live object and the saved shape are different types on purpose: a field can move without breaking saves that are already on disk.

Namespace: OpenMon.MCE.Player

Some fields are save-preview only

Money, DexNumber and RosterPreview on GlobalGameData exist only for the save-slot preview UI — they are snapshotted at save time. The live values live elsewhere: money on the player's Bag, the actual party on Roster (PlayerCharacter.PlayerRoster). Read those for gameplay, not the preview fields here.

Definition​

[CreateAssetMenu(menuName = "MCE/Player/GlobalGameData", fileName = "GlobalGameData")]
public class GlobalGameData : GameVariableHolder
{
// Versioning (written on save)
public string LastSaveDate;
public string LastGameVersion;
public string LastMCEVersion;
public string LastMCEAssetsVersion;

// Options
public GameDifficulty GameDifficulty;
public CatchDifficulty CatchDifficulty;

// General
public bool HasDex;
public SceneLocation LastHealLocation;
public uint StepsTaken;
public SerializableDictionary<Region, List<Badge>> ObtainedBadges;
public List<SceneInfoAsset> VisitedScenes;
public Ball LastUsedBall;

// Player location
public SceneLocation LastPlayerLocation;
public bool WasPlayerOnBridgeOnLastLocation;

// Save-preview only
public uint DexNumber;
public uint Money;
public List<MonsterPreview> RosterPreview;

// Add-on system state (null-tolerant for old saves)
public FollowerSaveData FollowerData;
public SecretBaseData SecretBase;
public SceneLocation SecretBaseReturn;
public PlayerGymData PlayerGym;
public List<string> EarnedGymBadges;
public TowerRunState TowerRun;

public void AddBadge(Badge badge, Region region);
public bool HasBadge(Badge badge, Region region);
public List<Badge> GetBadges(Region region);
public int GetTotalNumberOfBadges();
public float GetCatchDifficultyMultiplier();

public override string SaveToText(ISerializer<string> serializer, PlayerCharacter playerCharacter);
public override IEnumerator LoadFromText(ISerializer<string> serializer, string data,
MCESettings mceSettings, MonsterDatabaseInstance monsterDatabase);
public override IEnumerator ResetSave();
}

Fields & Properties​

GameDifficulty​

The play-through difficulty.

Type: GameDifficulty

CatchDifficulty​

The capture difficulty. Feeds GetCatchDifficultyMultiplier().

Type: CatchDifficulty

HasDex​

Whether the player has obtained the Dex.

Type: bool

LastHealLocation​

The last place the player healed — the respawn point after a loss.

Type: SceneLocation

LastPlayerLocation​

The player's last known location, written on save.

Type: SceneLocation

WasPlayerOnBridgeOnLastLocation​

Whether the player was standing over a bridge at their last location (restored on load).

Type: bool

StepsTaken​

Total steps the player has walked (drives egg hatching, roaming, etc.).

Type: uint

ObtainedBadges​

Badges earned, keyed by Region. Manipulate through AddBadge / HasBadge / GetBadges rather than mutating directly.

Type: SerializableDictionary<Region, List<Badge>>

VisitedScenes​

Scenes the player has visited (a cosmetic "have I been here" breadcrumb).

Type: List<SceneInfoAsset>

LastUsedBall​

The last ball the player threw (used to preselect it in battle).

Type: Ball

Money​

Save-preview money snapshot (not the live wallet — see the note above).

Type: uint

DexNumber​

Save-preview count of caught species (preview only).

Type: uint

RosterPreview​

Save-preview snapshot of the party (species/form/gender/egg), one MonsterPreview per slot. Built at save time from the live roster.

Type: List<MonsterPreview>

FollowerData​

Persistent state of the active overworld follower.

Type: FollowerSaveData (OpenMon.MCE.Characters.Followers)

SecretBase​

Persistent state of the player's Secret Base (placed decor). Null-tolerant for old saves.

Type: SecretBaseData (OpenMon.MCE.World.SecretBase)

SecretBaseReturn​

The overworld location the player left when entering their Secret Base interior, so the interior exit warp returns them exactly where they came from. A null/empty Scene means "no pending return" and the exit falls back to LastHealLocation.

Type: SceneLocation

PlayerGym​

The player's own custom gym: decorated interior room, leader-team slots, custom badge and dialogs. Null-tolerant for old saves.

Type: PlayerGymData (OpenMon.MCE.World.Gym)

EarnedGymBadges​

Opaque ids of the custom gym badges this player earned by defeating other players' gyms (award-once, deduped). Distinct from ObtainedBadges, which holds authored region gym-leader Badge assets.

Type: List<string>

TowerRun​

Persistent state of an in-progress battle-tower run.

Type: TowerRunState (OpenMon.MCE.Battle.Tower)

Methods​

AddBadge(Badge badge, Region region)​

Add a badge to a region (creating the region's list if needed).

HasBadge(Badge badge, Region region)​

Whether the player owns a specific badge in a region.

Returns: bool.

GetBadges(Region region)​

All badges the player owns in a region (empty list if none).

Returns: List<Badge>.

GetTotalNumberOfBadges()​

Total badge count across all regions.

Returns: int.

GetCatchDifficultyMultiplier()​

The capture-rate multiplier for the current CatchDifficulty (Guaranteed → -1, Easy → 1.5, Normal → 1, Hard → 0.5).

Returns: float.

SaveToText(ISerializer<string> serializer, PlayerCharacter playerCharacter)​

Snapshot the live player state (location, money, dex number, roster preview), stamp the versions, and serialize into a SavableGlobalGameData string.

Returns: string.

LoadFromText(ISerializer<string> serializer, string data, MCESettings mceSettings, MonsterDatabaseInstance monsterDatabase)​

Coroutine that deserializes a SavableGlobalGameData and applies it back onto this asset (running save migrations first).

Returns: IEnumerator.

ResetSave()​

Coroutine that resets to a fresh new-game state (Normal difficulties, no dex, initial heal location, cleared badges/scenes, reset add-on systems).

Returns: IEnumerator.

SavableGlobalGameData​

The serialization-friendly mirror of GlobalGameData. Reference-type Unity objects (scenes, badges, balls, species) are stored by name so saves stay stable across runtimes, and a SaveFormatVersion stamp drives migrations on load.

[Serializable]
public class SavableGlobalGameData
{
public int SaveFormatVersion;

public string LastSaveDate;
public string LastGameVersion;
public string LastMCEVersion;
public string LastMCEAssetsVersion;

public GameDifficulty GameDifficulty;
public bool HasDex;
public SavableSceneLocation LastHealLocation;
public SavableSceneLocation LastPlayerLocation;
public uint StepsTaken;
public List<ObjectPair<string, string>> ObtainedBadges; // (region name, badge name)
public List<string> VisitedScenes; // scene names
public string LastUsedBallName; // canonical id
public uint DexNumber;
public uint Money;
public List<SavableMonsterPreview> RosterPreview;
public GameVariables GameVariables;
public FollowerSaveData FollowerData;
public SecretBaseData SecretBase;
public SavableSceneLocation SecretBaseReturn;
public PlayerGymData PlayerGym;
public List<string> EarnedGymBadges;
public TowerRunState TowerRun;

public SavableGlobalGameData(GlobalGameData globalGameData);
public void LoadGlobalGameData(GlobalGameData globalGameData,
MonsterDatabaseInstance monsterDatabase,
WorldDatabase worldDatabase);
}

SaveFormatVersion​

The savegame format version stamped when the save was written. On load, LoadGlobalGameData compares it against the current version and runs pending migrations before applying the data. Saves older than the stamp deserialize this as 0.

Type: int

LoadGlobalGameData(GlobalGameData globalGameData, MonsterDatabaseInstance monsterDatabase, WorldDatabase worldDatabase)​

Resolve every name back to its live asset and apply the data onto a GlobalGameData. Cosmetic references (badges, visited scenes) are tolerant — a removed/renamed asset drops that one entry instead of failing the whole load.

Usage Example​

using OpenMon.MCE.Player;
using OpenMon.MCE.Badges;
using OpenMon.MCE.World;
using Zenject;

public class BadgeCounter : MonoBehaviour
{
[Inject] private GlobalGameData gameData;

private void Start()
{
Debug.Log($"Steps walked : {gameData.StepsTaken}");
Debug.Log($"Total badges : {gameData.GetTotalNumberOfBadges()}");
Debug.Log($"Has Dex : {gameData.HasDex}");
Debug.Log($"Catch mult. : {gameData.GetCatchDifficultyMultiplier()}");
}
}