Skip to content

API Reference

DooDesch edited this page Jul 6, 2026 · 2 revisions

API Reference

Reference Personnel.dll from your mod and declare the optional dependency so load order is right:

[assembly: MelonOptionalDependencies("Personnel")]

Spawn a pack NPC as a real S1API NPC

One tiny subclass per NPC, then construct it - S1API builds the prefab and handles networking, save/load and the mugshot:

public sealed class PaleNpc : Personnel.PersonnelNpc
{
    protected override string DefId => "examples_pale";   // derived id from an installed pack
}

// wherever you populate the world (e.g. after a save is loaded):
var npc = new PaleNpc();
npc.Position = spawnPoint;      // then use S1API as usual: schedules, dialogue, relationships, ...

Rules:

  • DefId must return a compile-time constant. S1API builds the prefab from an uninitialized instance of your type, so the getter cannot rely on constructor-set state.
  • The id is the derived packname_npcname id - the startup log lists every loaded id.
  • If the definition is missing (pack not installed), ConfigurePrefab logs a warning and the NPC falls back to S1API defaults.

Enumerate / look up definitions

foreach (Personnel.Model.NpcDef def in Personnel.API.All)
    MelonLogger.Msg($"{def.Id}: {def.DisplayName} (from {def.Source})");

if (Personnel.API.TryGet("examples_pale", out var pale)) { ... }

Apply just the look (no S1API NPC)

For mods with their own character systems - apply a designed appearance to any avatar:

// Build the vanilla AvatarSettings (registers any custom PNG layers on first use; main thread only):
Il2CppScheduleOne.AvatarFramework.AvatarSettings settings = Personnel.API.BuildAvatarSettings(def);

// Or do both steps in one call:
Personnel.API.ApplyAppearance(avatar, def);   // avatar is an Il2CppScheduleOne.AvatarFramework.Avatar

Configure your own NPC subclass

If you already have an S1API NPC subclass and only want the identity + appearance from a definition, call this inside your ConfigurePrefab:

protected override void ConfigurePrefab(NPCPrefabBuilder builder)
{
    if (Personnel.API.TryGet("examples_pale", out var def))
        Personnel.API.ConfigureFromDef(builder, def);
    // ... your own customer/dealer/schedule configuration
}

Register definitions at runtime

Mods can provide definitions without a pack folder (de-duplicated by Source/Id):

var def = new Personnel.Model.NpcDef { Id = "mymod_bob", DisplayName = "Bob", Source = "MyMod" };
def.Appearance.SkinColor = new Color(0.6f, 0.5f, 0.4f);
Personnel.API.Register(def);

Reload

Personnel.API.OnReloaded += () => { /* re-resolve your defs */ };
Personnel.API.Reload();   // rescans the packs folder; API-registered defs persist

Extensions

Per-consumer manifest blocks arrive raw:

if (def.Extensions.TryGetValue("mymod", out string json))
    var cfg = JsonConvert.DeserializeObject<MyModBlock>(json);

Clone this wiki locally