Skip to content

IngredientDraft

Namespace Nfty.Core.Editing in assembly Nfty.Core.

public sealed class IngredientDraft

The whole ingredient being edited: identity, layer kind, colorization, the fixed canvas size, and its variants. Every variant's raster is created at IngredientDraft.Canvas — the single source of truth.

Constructors

IngredientDraft(string, string, LayerKind, Colorization?, Dimensions, IEnumerable<VariantDraft>)

public IngredientDraft(string id, string name, LayerKind kind, Colorization? colorization, Dimensions canvas, IEnumerable<VariantDraft> variants);

Creates a draft ingredient.

Parameters

  • id (string) - Stable identifier.
  • name (string) - Display name.
  • kind (LayerKind) - Layer kind.
  • colorization (Colorization?) - Color configuration, or null for Custom.
  • canvas (Dimensions) - Canvas size every variant must match.
  • variants (IEnumerable<VariantDraft>) - Initial variants.

Properties

Canvas

public Dimensions Canvas { get; }

The canvas every variant must match.

Colorization

public Colorization? Colorization { get; set; }

How it is colored; null for a Custom layer.

Id

public string Id { get; set; }

Stable identifier for the ingredient being built.

Kind

public LayerKind Kind { get; set; }

Which kind of layer this will be.

Name

public string Name { get; set; }

Display name.

Variants

public List<VariantDraft> Variants { get; }

The variants being edited.

Methods

AddVariant(string, string, double)

public VariantDraft AddVariant(string id, string name, double weight);

Adds a blank variant sized to the canvas. A Custom ingredient's variants are authored in color, so one gets a blank ColorMap as well — without it a freshly added Custom variant would have nothing to export.

Parameters

  • id (string) - Stable identifier.
  • name (string) - Display name.
  • weight (double) - Roll weight.

Returns. The new variant, already added.

DuplicateVariant(string, string, string)

public VariantDraft DuplicateVariant(string sourceId, string newId, string newName);

Appends a copy of an existing variant (same weight, cloned pixels) under a new id/name. Both rasters are cloned when both exist — copying only the value-map would give a Custom variant a gray ghost for artwork and silently block its save.

Parameters

  • sourceId (string) - The variant to copy.
  • newId (string) - The copy's identifier.
  • newName (string) - The copy's display name.

Returns. The copy, already added.

Exceptions

  • InvalidOperationException - The source is absent, or the new id is taken.

RemoveVariant(string)

public void RemoveVariant(string id);

Removes a variant by id. Throws if it is absent (the caller enforces any minimum count).

Parameters

  • id (string) - Id of the variant to remove.

Exceptions

  • InvalidOperationException - The ingredient has no variant with that id.