Style class - DomeKeeperMods/Docs GitHub Wiki

Table of Contents


Overview

In the Dome Keeper game, a feature allows for color changes to various visual components - sprites, effects, particles, and UI elements. These colors are swapped out for alternative sets of colors, referred to as "palettes". This swapping mechanism is managed by the Style autoload.

As a mod developer, it's important to understand how Style class works.

In different game worlds, various color palettes are utilized. These palettes play a major role in determining how the game looks, as they specify the colors for each element present in the game world.

palette_recolor_icon_to_color

How Color Swapping Works

For a comprehensive understanding of how color swapping works, please visit the more theoretical page available here.

How to Use

To initialize a visual element in the Style singleton, use the following code:

Style.init($Node)

In this instance, $Node refers to a node, e.g., $Sprite or self. When a node is initialized using this function, it also recursively initializes all of its child nodes.

You will find this function call used extensively throughout the Dome Keeper's code base.

Prevent Unwanted Styling

If you want specific nodes to be omitted from getting styled recursively, the easiest way is to add them to a group unstyled. This way they will be skipped even if Style.init() is called on them.

If you copied a vanilla element like a resource drop, you may have to clear the inherited material.