Skip to content

Batch-register addon content safely

✅ Source verified 🧰 Creator helper

Registering twenty pieces of addon content one by one creates repetitive code and makes partial failure easy to miss.

Political World’s creator API provides batch helpers for:

RegisterIdeologies(...)
RegisterGovernments(...)
RegisterActions(...)
RegisterRarePoliticalEvents(...)

The inspected source returns:

public sealed class BatchRegistrationResult
{
public int Requested;
public int Registered;
public List<string> FailedIds;
public bool AllSucceeded { get; }
}
var result = PoliticalWorldAPI.RegisterIdeologies(
AddonId,
new[]
{
ideologyA,
ideologyB,
ideologyC
}
);
if (!result.AllSucceeded)
{
foreach (string failedId in result.FailedIds)
{
LogWarning("Failed ideology: " + failedId);
}
}

The helper does not turn one failed item into an exception that discards every earlier success.

For every definition:

Requested++
try registration
success → Registered++
failure → FailedIds.Add(id)

A thrown registration exception is treated as failure for that item.

A creator needs to distinguish:

requested 20
registered 19
failed 1

from:

register everything returned false

The first contains enough information for useful diagnostics.

The inspected helper does not roll back already-registered content when a later definition fails.

Therefore:

AllSucceeded == false

can still mean several definitions successfully entered the registry.

If your addon requires all-or-nothing semantics, pre-validate the whole set or implement explicit rollback logic using supported APIs where possible.

A failed content ID is much easier to investigate than an array index:

YourName.MyAddon.technocracy

instead of:

item 17

Stable IDs make logs searchable by humans and AI.

Bulk creator APIs should report structured partial results.

Useful fields are:

  • attempted/requested count;
  • successful count;
  • failed stable IDs;
  • optionally diagnostic codes/reasons.

This makes large content packs much easier to maintain.