Documentation: StreamingKeepAliveComponent

From Noita Wiki
Jump to navigation Jump to search
Name Type Initial Value Example Range Description
Members
TEMP_TEMPY float 0 [0, 3.5]
TEMP_TEMP_TEMP float 0 [0, 3.5]

Behaviour

StreamingKeepAliveComponent can load in new chunks and keep loaded in chunks loaded.

It loads all chunks that are in the entity's first HitboxComponent. If it doesn't have one then it just loads the chunk that the entity is currently in (as-if it has a 0x0 HitboxComponent).

To keep loaded chunks loaded, it uses the previous region with 256 pixels added to the left, right, top, and bottom.

Both of these region checks are inclusive, which means they are effectively extended by 1 pixel to the bottom and right.

The table below demonstrates a couple different setups that are possible. The blue cross is the entity with a StreamingKeepAliveComponent and possibly a Hitbox, and the red squares are chunks.

Entity XML Load Keep loaded
<!-- Simple entity. 1x1 load and 513x513 keep loaded -->
<Entity>
  <StreamingKeepAliveComponent />

  <_Transform
    position.x="256"
    position.y="256" />
</Entity>
KeepAlive Simple Load.png KeepAlive Simple Keep Loaded.png
<!-- Same as above but off-center -->
<Entity>
  <StreamingKeepAliveComponent />

  <_Transform
    position.x="156"
    position.y="156" />
</Entity>
KeepAlive SimpleOffset Load.png KeepAlive SimpleOffset Keep Loaded.png
<!-- Entity with a 100x100 (+1) hitbox -->
<Entity>
  <StreamingKeepAliveComponent />

  <HitboxComponent
    aabb_min_x="-50"
    aabb_min_y="-50"
    aabb_max_x="50"
    aabb_max_y="50" />

  <_Transform
    position.x="462"
    position.y="256" />
</Entity>
KeepAlive Small Load.png KeepAlive Small Keep Loaded.png
<!-- Entity with an inverted hitbox work a bit strangely but can still be useful.
     -512x-512 (+1) hitbox -->
<Entity>
  <StreamingKeepAliveComponent />

  <HitboxComponent
    aabb_min_x="256"
    aabb_min_y="256"
    aabb_max_x="-256"
    aabb_max_y="-256" />

  <_Transform
    position.x="256"
    position.y="256" />
</Entity>
KeepAlive Inverted Load.png KeepAlive Inverted Keep Loaded.png

Issues

The game tries to keep at most STREAMING_CHUNK_TARGET chunks loaded at any time, by default this is set to 12. It's very easy to go over this limit if you use this component a couple times in a mod. When you are over this limit, the game constantly logs "Warning - streaming didn't find any chunks it could stream away..." and "Too many chunks!". This hurts performance and can lead to huge log files.