Banana 2077
README.md
LightBudget
Keeps the lights nearest the camera switched on, under the renderer's cap on point, spot and area lights (64). The renderer otherwise draws the first 64 lights it was handed wherever the camera is. A city with more than 64 lights leaves the rest dark, however close the player stands to them.
Every interval seconds the component ranks every point and spot light under the entities named in roots. The score is how far the camera's focus stands outside the light's reach, where the focus is the main camera moved lookAhead metres along its view. The best-ranked lights stay on and the rest are switched off with enabled = false.
Lights it never touches
- Lights outside the roots, such as the player's, an enemy's or an effect's. The rows they hold come out of the budget.
- Lights authored switched off. They stay off.
Spare rows: spare rows stay free, so a light that gameplay spawns is drawn the moment it appears.
Modes: it works in play only. In edit, every light stays as authored. Disabling or removing the component switches every light it turned off back on.
Cost:
- Finding the lights is spread over a few frames, 60 entities a frame.
- It rescans the roots every
rescanseconds, but only when their entity count changed. - Each ranking reads every managed light's position plus the renderer's light rows (about 2 ms for 130 lights).
Where it's used: game.city.district attaches it to the district root, with roots = "district club" covering the street and The Banana Split.
Fields
| field | default | meaning |
|---|---|---|
roots | "district club" | Names of the entities whose descendant lights are managed, space separated |
capacity | 64 | Point + spot + area lights the renderer draws at once |
spare | 2 | Rows kept free for lights spawned outside the roots |
lookAhead | 10 | Metres along the camera's view the focus sits, so lights ahead beat lights behind |
interval | 0.25 | Seconds between re-rankings |
rescan | 5 | Seconds between checks for lights added under or removed from the roots |
There are no sibling components to add.