Kitchen and props ​

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

namespace Carousel
{
    public sealed class Carousel : IAddon
    {
        public void Load(AddonContext ctx)
        {
            Content.Prop("hub")
                .Name("Carousel Hub")
                .Model("models/hub.obj", "textures/hub.png")
                .OnPlaced((go, cell) => go.AddComponent<Turner>().Hub = cell);
        }
    }

    public sealed class Turner : MonoBehaviour
    {
        public Cell Hub;
        private bool moved;

        private void Update()
        {
            if (moved || Kitchen.RoundTime < 15f)
                return;
            moved = true;
            GameObject station = Kitchen.Occupant(new Cell(Hub.X + 1, Hub.Z));
            if (station != null && Kitchen.Movable(station))
                Kitchen.MoveStation(station, new Cell(Hub.X + 1, Hub.Z + 1));
        }
    }
}

A level places Carousel Hubs like any object. Each one learns its cell as the level loads; fifteen seconds into the round the station east of the hub moves a cell north, with what is on it, and chefs use it in its new place.

Props ​

csharp
public sealed class PropBuilder
{
    public PropBuilder Name(string name);
    public PropBuilder Icon(string png);
    public PropBuilder Model(string obj, string png = null, float scale = 1f);
    public PropBuilder Tint(string hex);
    public PropBuilder Blocks(bool blocks = true);
    public PropBuilder OnPlaced(Action<GameObject, Cell> placed);
}
  • Model: without one the prop is an invisible marker, which a gimmick finds with OnPlaced.
  • Blocks: chefs can't walk through its cell. True by default.
  • OnPlaced: runs for each one the level places, on every machine, while the level loads (before the round starts). An exception is logged and the level carries on.

Kitchen ​

csharp
public static class Kitchen
{
    public static bool Active { get; }
    public static Vector3 CellSize { get; }
    public static Cell CellOf(Vector3 position);
    public static Vector3 PosOf(Cell cell, float y);
    public static GameObject Occupant(Cell cell);
    public static IList<GameObject> Stations { get; }
    public static Cell CellOfStation(GameObject station);
    public static void MoveStation(GameObject station, Cell cell);
    public static void TakeOffGrid(GameObject station);
    public static void PutOnGrid(GameObject station);
    public static bool Movable(GameObject go);
    public static float RoundTime { get; }
    public static float TimeLimit { get; }
    public static Camera Camera { get; }
    public static bool IsHost { get; }
    public static GameObject ItemOn(GameObject station);
    public static bool TakeAway(GameObject item);
    public static bool IsLocal(GameObject chef);
    public static bool Shove(GameObject chef, Vector3 velocity, float seconds = 0.25f);
    public static bool ClearCell(Cell cell, Vector3 axis, float speed = 5f);
    public static int ClearItems(Cell cell, Vector3 axis);
    public static bool Walkable(Cell cell);
    public static bool Pressed(GameObject chef, ChefButton button);
    public static bool PlaySound(string name);
    public static IList<string> Sounds { get; }
}

public enum ChefButton { PickUp, Use, Dash }

public struct Cell
{
    public readonly int X;
    public readonly int Z;
    public Cell(int x, int z);
}
  • Active: a kitchen with a grid is loaded. Outside one, Stations is empty, RoundTime is 0 and the rest throw InvalidOperationException.
  • Stations: every counter, board, hob and crate on the grid, by cell, so every machine has the same order.
  • MoveStation: moves a station and what is on it to a free cell and registers it there. Chefs pick what they face by the grid, so a station moved any other way can't be used.
  • TakeOffGrid, PutOnGrid: for a station a gimmick moves smoothly, by hand: off the grid while it moves, back in the cell under it after.
  • Movable: false for objects the scene baked into its static batches, whose meshes stay where they were. Stations a level places are movable.
  • RoundTime: seconds since the round's clock started; TimeLimit: the level's limit.
  • Camera: the camera that draws the kitchen, for screen-space effects.
  • IsHost: this machine decides what happens to items, offline or as the online host.
  • ItemOn: the plate, pot or food on a counter, station or crate, or null.
  • TakeAway: takes an item away like the bin does. Food is gone, and plates, pots and pans come back where the game returns them. Host only.
  • IsLocal: this machine moves the chef.
  • Shove: knocks one of this machine's chefs sideways for a moment, as a thrown item does, then its player has it back.
  • ClearCell: pushes this machine's chefs out of a cell along an axis to the side they can stand on. On the host, loose items in the cell move there too, or to the nearest cell a chef can reach. Call it every frame while a gate or a moving station takes the cell, and make the cell solid only once it returns true.
  • ClearItems: moves only the loose items, without pushing chefs, for a cell something will take soon, such as the dock a cart is on its way to. Host only; returns how many it moved.
  • Walkable: a chef could stand in the cell: no station, wall, blocking prop or closed gate. Chefs and items in it don't count.
  • Pressed: the chef's player pressed the button this frame; only ever true for chefs this machine moves.
  • PlaySound: plays one of the game's own sounds on this machine. False when this kitchen has no recording for it; Sounds lists the ones it has.

Run a gimmick from the round clock and the level's own data, never from Random or the frame count, so every machine does the same thing at the same time online.

Assets loads OBJ and PNG files for props a gimmick builds itself. Rigs, routes and decisions animate creatures and machines and agree on what happened online; Scenery and gloom redress and darken the base kitchen.