Scenery and gloom
Gloom gloom = null;
Levels.LevelStarted += level =>
{
if (!level.Picks(ctx.Id))
return;
Scenery.Hide("Candelabra");
Scenery.HideMaterial("mat_wizard_book_01");
Texture2D stone = Assets.Texture(Path.Combine(ctx.Directory, "art", "floor.png"));
Scenery.Restyle("mat_wizard_stonetile_01", stone, 2f, new Color(0.8f, 0.8f, 0.9f));
gloom = new Gloom(new Color(0.02f, 0.035f, 0.08f)) { Amount = 0.4f, Outside = 0.86f };
gloom.Room(new Bounds(Vector3.zero, new Vector3(16f, 0.1f, 11f)), 1.1f);
GloomLight torch = gloom.Light(new Vector3(-3f, 0f, 4f), 2.9f, 0.85f);
torch.Warmth = new Color(1f, 0.55f, 0.2f, 0.13f);
foreach (GameObject chef in Content.Chefs)
gloom.Light(chef.transform, 2.3f, 0.6f);
};
Levels.LevelEnded += level =>
{
if (gloom != null)
gloom.Dispose();
gloom = null;
};The candelabras and the books go, the floor turns to grey stone, and the kitchen goes dim, with a warm pool round a torch and a lighter patch round each chef.
Scenery
public static class Scenery
{
public static IList<GameObject> Find(string name);
public static int Hide(GameObject piece);
public static int Hide(string name);
public static IList<string> Materials { get; }
public static int HideMaterial(string material);
public static int Restyle(string material, Texture2D texture, float tiling, Color tint);
}Scenery is the base kitchen's own walls, floors, furniture, characters and lights. Stations, chefs, items and what a level places are never scenery. Changes last until the kitchen unloads. Make them from Levels.LevelStarted, and every player who loads the level sees the same kitchen.
Find: the pieces whose name containsname, ignoring case, in scene order. A piece whose parent also matches is left out.Hide: hides a piece and everything under it: renderers, lights and particles, including its share of a mesh the kitchen merged with its neighbours. Colliders stay, so walls still stop chefs. Returns the number of meshes hidden.Materials: the materials the scenery is drawn with. Many kitchens merge their walls and furniture into a few big meshes, and those can only be changed by material.HideMaterial: hides everything drawn with the material, merged pieces included.Restyle: draws everything that uses the material with your texture instead, keeping the game's shader, baked light and shape.tilingrepeats the texture that many times where the old one was drawn once;tintmultiplies it.
Log Scenery.Materials once to see a kitchen's materials. Wizard 3-3's books, for example, are mat_wizard_book_01 to mat_wizard_book_04.
Gloom
public sealed class Gloom : IDisposable
{
public Gloom(Color colour);
public Color Colour { get; set; }
public float Amount { get; set; }
public float Outside { get; set; }
public IList<GloomLight> Lights { get; }
public void Room(Bounds area, float edge = 1f);
public GloomLight Light(Vector3 at, float radius, float strength = 1f);
public GloomLight Light(Transform follow, float radius, float strength = 1f);
public bool Remove(GloomLight light);
public void Dispose();
}
public sealed class GloomLight
{
public Transform Follow { get; set; }
public Vector3 Position { get; set; }
public float Radius { get; set; }
public float Strength { get; set; }
public Color Warmth { get; set; }
}Gloom draws darkness over the kitchen camera's picture. It costs a fraction of a millisecond a frame, much less than a real light.
Amount: how dark the room is, 0 (clear) to 1 (the colour itself).Outside: how dark everything beyond it is.Room: the floor area of the room. Darkness fades fromAmounttoOutsideoveredgemetres past it. Without a room the whole picture getsAmount.Light: a pool that lifts the dark: fully inside a third of its radius, fading out to the edge. It stays put or follows a transform, such as a chef or a torch.Warmth: a colour added over the pool, strongest at its middle, with its alpha as the amount.- Change a light's
RadiusandStrengthevery frame for a flicker.
Gloom draws on this machine only and changes nothing in the game, so it is safe online. Dispose it when the level ends.