Level content ​

A level content addon adds things map makers build levels with: new foods with their own crates, new cooking stations, recipes, movement types, chef animations and the instructions a level shows before its round. The level editor shows them in its palette and recipe builder, and a level that uses them lists the addon. Players install it themselves, from Discover or from the level's description; a level doesn't play until its addons are installed.

csharp
using Swofty.Overcooked2;
using Swofty.Overcooked2.Content;

namespace Dumplings
{
    public sealed class Dumplings : IAddon
    {
        public void Load(AddonContext ctx)
        {
            Content.Ingredient("dumpling")
                .Name("Dumpling")
                .Icon("icons/dumpling.png")
                .Model("models/dumpling.obj", "textures/dumpling.png")
                .Crate()
                .Preps("steamed");

            Content.Station("steamer")
                .Name("Steamer")
                .On(StationBase.Hob)
                .Prep("steamed", "Steamed")
                .Time(5f)
                .Accepts("dumpling");

            Content.Recipe("dumpling-plate")
                .Name("Dumpling Plate")
                .Part("dumpling", "steamed")
                .Part("Lettuce", "chopped")
                .Score(30);

            Content.Movement("ice").Name("Icy Floor").Surface("#bfe8ff").Grip(0.2f);

            Content.Animation("wave").Name("Wave").Wiggle(0f, 1.2f, 20f, 3).Emote(1);
        }
    }
}
json
{
  "id": "yourname.dumplings",
  "name": "Dumplings",
  "version": "1.0.0",
  "icon": "icon.png",
  "level_content": true,
  "compat": { "game": "overcooked_2", "std": ">=0.3.0" },
  "assemblies": ["Dumplings.dll"]
}

"level_content": true gives the addon a Level content badge in the launcher. Start from templates/overcooked-2-content-addon, which is this addon with its art. Taco Stand is a full example with every kind. Rat Run's two addons are a full level built on the kitchen API, rigs and scenery, and so are those of Clockwork Bakery, Molten Forge and Sky Galley. Their source, and older examples such as Haunted Larder and Carousel Cafe, are in games/overcooked_2/examples/.

BuilderMakesPage
Content.Ingredient(id)a food, its crate and its prepared formsFoods and stations
Content.Station(id)a cooking type: a station with its own prepFoods and stations
Content.Recipe(id)an orderRecipes
Content.Movement(id)a level-wide handling, a floor surface or a pickupMovement
Content.Animation(id)a chef animation on serve, level start or end, or an emoteAnimations
Content.Prop(id)scenery or a marker the editor placesKitchen and props
Content.Instructions(id)the popup before a level's round, with picturesInstructions

Ids and names ​

text
yourname.dumplings/dumpling      <addon id>/<local id>
  • Local ids are a-z, 0-9, ., _ and -, at most 64 characters, once per addon.
  • Levels store content ids. Never rename or remove one that levels use; add new content instead.
  • A name without / in a builder (Part("dumpling"), Accepts("dumpling"), OnServe("taco")) is the addon's own local id first, then a built-in name (any case), else an error. Another addon's content takes its full id.
  • File paths are relative to the addon folder, without ...

When content is published ​

Content an addon registers is published when its Load returns. Each item is checked first; one bad item fails the addon, with every problem listed in the Addons dialog and core.log, and none of its content is published:

text
yourname.dumplings: content: yourname.dumplings/steamer: the model models/steamer.obj is not in the addon folder;
yourname.dumplings/dumpling-plate: uses the prep yourname.dumplings/boiled, which no station of this addon gives

Register content only from Load; anywhere else throws InvalidOperationException.

Each item gets a Number: before the first kitchen loads, addons are sorted by id and numbered in registration order, so every player with the same addons gets the same numbers. An addon installed while the game runs is loaded at once (the launcher sends load_addons); its content is appended after the rest and is in the next kitchen that loads.

Reading content ​

csharp
public static IList<ContentItem> All { get; }
public static ContentItem Find(string id);
public static event Action<ContentItem> Registered;
  • All: every published item, in Number order.
  • Find: an item by full id, or null.
  • Registered: raised for each item as it is published, also for hot-loaded addons.
csharp
public sealed class ContentItem
{
    public string Id { get; }              // "swofty.taco-stand/tortilla"
    public string LocalId { get; }         // "tortilla"
    public string Addon { get; }           // "swofty.taco-stand"
    public string AddonVersion { get; }
    public string Name { get; }
    public string Category { get; }        // the palette section, the addon's name by default
    public ContentKind Kind { get; }       // Ingredient, Station, Recipe, Movement, Surface, Pickup, Animation, Prop, Instructions
    public bool Placeable { get; }         // the editor can place it: a crate, station, surface, pickup or prop
    public int Number { get; }
    public Texture2D Icon { get; }
    public string IconPath { get; }
    public string AddonDirectory { get; }
    public ContentDefinition Definition { get; }
}

Definition is an IngredientDefinition, StationDefinition, RecipeSpec, MovementDefinition, AnimationDefinition, PropDefinition or InstructionsDefinition, read-only once published.

Chefs ​

csharp
public static IList<GameObject> Chefs { get; }
public static int ChefIndex(GameObject chefOrChild);
public static void PlayAnimation(string id, int chef = -1);
public static void PlayAnimation(string id, GameObject chef);
public static void ApplyMovement(string id, int chef = -1);
  • Chefs: the chefs in the kitchen, in the order the chef numbers use. Empty outside a kitchen.
  • ChefIndex: the number of the chef a GameObject is or belongs to, or -1.
  • PlayAnimation, ApplyMovement: on one chef, or every chef with -1. A movement lasts its Duration, or the level for 0.

These run on this machine only. For a gimmick online, run them on every machine from the same event.

Assets ​

csharp
public static Mesh Mesh(string objPath, float scale = 1f);
public static Texture2D Texture(string pngPath);
public static Sprite Sprite(string pngPath);
public static Material Material(Texture2D texture, string tint = null);
public static Material Clear(Texture2D texture = null, string tint = null, float alpha = 1f);
public static GameObject Model(string name, string objPath, string pngPath = null, float scale = 1f, string tint = null);

Assets loads art for props an addon builds itself, the way content models load. Paths are absolute: Path.Combine(ctx.Directory, "models/bell.obj"). Materials take the kitchen's look once a kitchen has loaded.

Clear is for glows, flames, bulbs and ghosts: unlit and see-through, the texture (or white) times tint at alpha from 0 to 1. It ignores the kitchen's lights and casts no shadow. Set the material's color to fade or pulse it:

csharp
Material ghost = Assets.Clear(atlas, null, 0f);
ghost.color = new Color(0.92f, 1f, 0.95f, 0.85f);

Models and art ​

  • OBJ: v, vt, vn and f (triangles or polygons, negative indices). Y up, metres, facing +Z. A food is about 0.3 to 0.5 across. At most 65,000 corners. Without normals they are calculated.
  • PNG: the texture over the OBJ's UVs. Square, a power of two, 128 to 1024.
  • Icons: square PNG with transparency, 128 px or more. Orders, crates and the editor palette show them.

Built-in names ​

Content.BuiltInIngredients, Content.BuiltInPreps and Content.Containers list them at run time. Kitchens add the names of their own crates.

IngredientsBun, BurritoChicken, BurritoMeat, Carrot, Cheese, Chicken, Chocolate, Cucumber, Dough, Egg, Flour, Honeycomb, Lettuce, Meat, Mushroom, NuggetChicken, Onion, Pasta, PastaTomato, Pepperoni, Potato, Prawn, Rice, Seaweed, SushiCarrot, SushiFish, SushiPrawn, SushiRice, Tomato, Tortilla, UncookedFish
Prepsraw, chopped, fried, boiled, steamed, baked, grilled, mixed, blended
Containersplate, glass, mug

A recipe can use a built-in only in a kitchen that has its crate and a station for its prep; the editor's recipe builder says what is missing.