Skip to content

Allow Color serialization from named colors in palette prototypes. - #7064

Open
whatston3 wants to merge 9 commits into
space-wizards:masterfrom
whatston3:2026-08-24-going-to-palette-town
Open

whatston3 wants to merge 9 commits into
space-wizards:masterfrom
whatston3:2026-08-24-going-to-palette-town

Conversation

@whatston3

@whatston3 whatston3 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

About the PR

This PR adds Color serialization from palette colors. These are specified in YAML in the form <PALETTE_NAME>.<COLOR_NAME>, e.g. Paper.bounty.

Palettes are specified in a palette prototype (refer to space-wizards/space-station-14#45826 for examples)

Adds a PaletteManager to handle caching and looking up these values, with a few convenience methods to get a random color out of a particular palette.

If added, could provide an alternative for #7027 where it's used as a content-side palette.

Why / Balance

One of the changes brainstormed from space-wizards/space-station-14#45540.

Being able to reference the same Color from completely different YAML files based on the same palette, without needing anchors or parenting seems useful.

Technical details

Adds a new PaletteManager (placed into Robust.Shared.ColorNaming, name not ideal but still fits). This is registered as a new dependency. PaletteManager holds both a named reference to specific colors (allowing for direct lookup from YAML), and a reference from a palette to an unnamed list of Colors inside.

Adds a PalettePrototype to store named references to Colors (implementation largely taken from SS14's ColorPalettePrototype) with a localized name.

PalettePrototypes serialize with a high priority (arbitrarily set to 1000 to allow lower/higher values). They have a PostDeserialize handler that registers their Colors with the PaletteManager - this currently builds a dictionary as it reads the values on initial serialization (frozen by Initialize), then expects to receive updates on the prototype reload event.

Probably an error - if changes were add/update, but removals were handled by the reload event, probably makes more sense.

Test plan

space-wizards/space-station-14#45540 is a sample of this in use, and a decent sandbox for testing.

Should write a small integration test that adds a known set of colors in two serialization passes, testing the parsed Color values of a test entity prototype - adding a color, changing a color, removing a color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant