Skip to main content

Roster

A roster of up to 6 MonsterInstance monsters that can be used in battle. This is the type returned by IPlayerData.PlayerRoster, so it is your entry point for reading and mutating the player's party.

roster

The lead is not a flag: it is slot 0. Swapping is what changes who fights first.

Namespace: OpenMon.MCE.Monster

Concrete data type, not an SDK interface

Roster is a concrete ScriptableObject (SavableObject), not an OpenMon.MCE.SDK interface. The members below are the main surface most buyers use; the class has additional members (template management, save/load serialization, virus spread, random population). See the source code (Source tier) for the complete API.

Definition​

[CreateAssetMenu(menuName = "MCE/Roster", fileName = "Roster")]
public class Roster : SavableObject, IEnumerable
{
public event Action OnRosterUpdated;

public MonsterInstance[] RosterData = new MonsterInstance[6];
public MCESettings Settings;
public MonsterDatabaseInstance Database;

public int RosterSize { get; }
public int NumberThatCanBattle { get; }

public MonsterInstance this[int index] { get; set; }
public IEnumerator GetEnumerator();
public bool IsMonsterNull(int index);

public void AddMonster(MonsterEntry species, Form form, byte level, /* ...many optional overrides... */);
public int AddMonster(MonsterInstance monster);
public void RemoveMonster(int index);
public void RemoveMonster(MonsterInstance monster);
public void Exchange(int firstIndex, int secondIndex);
public MonsterInstance ReplaceMonsterAt(int index, MonsterInstance newMonster);

public void CompletelyHeal();
public bool AnyHasMove(Move move);
public void CopyFrom(Roster other);
}

Events​

OnRosterUpdated​

Fired whenever the roster is modified (monster added, removed, swapped, replaced, etc.).

Signature: event Action OnRosterUpdated

Fields & Properties​

RosterData​

The backing array of monster instances. Always length 6; empty slots hold a null entry.

Type: MonsterInstance[]

Prefer the indexer and RosterSize

For everyday reads, use the roster[i] indexer and RosterSize rather than iterating RosterData directly — trailing slots may be null or null-entries.

Settings​

Reference to the MCE settings.

Type: MCESettings

Database​

Reference to the monster database.

Type: MonsterDatabaseInstance

RosterSize​

Get the size of this roster — the number of filled leading slots (stops at the first null entry).

Type: int (read-only, 0–6)

NumberThatCanBattle​

Get the number of monsters that can currently battle (not a null entry and CanBattle == true).

Type: int (read-only)

Methods​

this[int index]​

Quick access to a monster instance by slot.

ParameterTypeDescription
indexintIndex of that monster instance (0–5)

Type: MonsterInstance (get/set)

GetEnumerator()​

Quick access to the data enumerator (implements IEnumerable, so you can foreach a roster).

Returns: IEnumerator over RosterData.

IsMonsterNull(int index)​

Checks if a monster slot is null (either an actual null or a null entry).

ParameterTypeDescription
indexintIndex to check

Returns: bool — true if it is null.

AddMonster(species, form, level, ...)​

Add a monster to the roster, building the MonsterInstance for you. Only species, form and level are needed; the rest have defaults (random nature/ability, no nickname, default origin, etc.).

ParameterTypeDescription
speciesMonsterEntrySpecies of this monster
formFormForm of this monster (invalid form falls back to the default)
levelbyteLevel of this monster
(many optional)nature, ability, gender, IVs/EVs, moves, nickname, trainer, ball, ribbons, held item, isEgg, and more

AddMonster(MonsterInstance monster)​

Add an already-built monster to the roster.

ParameterTypeDescription
monsterMonsterInstanceMonster to add

Returns: int — the index it was added at, or -1 if all slots are already filled.

RemoveMonster(int index)​

Remove the monster at the given slot, then compact the party so there are no gaps.

ParameterTypeDescription
indexintIndex to remove

RemoveMonster(MonsterInstance monster)​

Remove a specific monster instance from the roster.

ParameterTypeDescription
monsterMonsterInstanceMonster to remove

Exchange(int firstIndex, int secondIndex)​

Exchange two monsters in the roster (swap their slots).

ParameterTypeDescription
firstIndexintFirst index to exchange
secondIndexintSecond index to exchange

ReplaceMonsterAt(int index, MonsterInstance newMonster)​

Replace the monster at the given index with another.

ParameterTypeDescription
indexintIndex to replace
newMonsterMonsterInstanceMonster to place there

Returns: MonsterInstance — the monster that was replaced.

CompletelyHeal()​

Completely heal every monster in the roster (HP, PP and status).

AnyHasMove(Move move)​

Does any monster in this roster know a given move? (Useful for field/HM-style move checks.)

ParameterTypeDescription
moveMoveMove to check

Returns: bool — true if any member knows it.

CopyFrom(Roster other)​

Clone another roster's monsters into this one.

ParameterTypeDescription
otherRosterRoster to copy from

Usage Example​

using OpenMon.MCE.SDK;
using OpenMon.MCE.Monster;
using Zenject;

public class PartyManager : MonoBehaviour
{
[Inject] private IMonsterCaptureEngine engine;

private void Start()
{
Roster roster = engine.Player.PlayerRoster;

// React to any party change.
roster.OnRosterUpdated += () =>
Debug.Log($"Party changed — size {roster.RosterSize}, "
+ $"{roster.NumberThatCanBattle} able to battle");

// Iterate the current party.
foreach (MonsterInstance monster in roster)
{
if (monster is { IsNullEntry: false })
Debug.Log($"- {monster.Species.name} (Lv {monster.StatData.Level})");
}

// Swap the lead with the second slot.
if (roster.RosterSize >= 2)
roster.Exchange(0, 1);

// Heal the whole party after a rough battle.
roster.CompletelyHeal();
}
}