Blocks/Behavior

From Starbounder - Starbound Wiki
Jump to: navigation, search

(Click here to return to Blocks.)

Blocks do not always look the same in all circumstances. Depending on their surroundings, blocks will adopt different appearances based on their behavior type (for blocks with more than one variant, appearance also changes based on the chosen variant). Most of the time, the surroundings which are considered are merely the eight blocks immediately surrounding a given block; however, there are cases in which the blocks which are 2 tiles to the left and right are also checked.

In the following sections, positional words are used frequently to describe where other blocks are in relation to a given block which is trying to determine its appearance. Specifically, "on top" refers to the block just above, "on bottom" refers to the block just below, "on left" refers to the block just to the left, "on right" refers to the block just to the right, "on top-left" refers to the block immediately above and to the left, "on top-right" refers to the block immediately above and to the right, "on bottom-left" refers to the block immediately below and to the left, and "on bottom-right refers to the block immediately below and to the right. Also, "cardinally adjacent" refers to the blocks touching the edges of the block in question (this includes the blocks above, below, to the left and to the right), and "diagonally adjacent" refers to the blocks touching only the corners of the block in question.

There are eight different behavior types that a block can possess: Classic, Screw, Row, Column, Girder, Rail, Pipe, and Platform.

Classic

Blocks possessing the classic behavior type determine their appearance using the presence or absence of identical blocks in all adjacent slots. For example, Dirt, which uses the classic behavior type, only checks for other Dirt blocks when deciding how to appear to nearby players.

In all cases, the block's core (the 8x8 sprite that occupies the block's slot) is placed first. After the core is placed, the game checks for nearby identical blocks, placing down edges and corners where appropriate.

Once the previous step finishes, the game then checks to see whether shadows need to be applied to the block. Cardinal shadows take precedence over diagonal shadows, which can only be applied if no cardinal shadows have been applied.

This behavior type is the default behavior type assigned to blocks.

Screw

Blocks possessing the screw behavior type take on one of four appearances depending on the presence or absence of blocks directly above or below them:

  • If blocks are present on both top and bottom, the block looks like a middle segment of a large screw
  • If a block is present on top, but not on bottom, the block looks like the bottom tip of a large screw
  • If a block is present on bottom, but not on top, the block looks like the head of a large screw which was driven into the block below it
  • Otherwise, the block looks like the head of a large screw which was driven into the background behind it

Only the Silver Screw block uses this behavior type.

Row

Blocks possessing the row behavior type take on one of four appearances depending on the presence or absence of identical blocks directly to their left and right:

  • If identical blocks are present on both the left and the right, the block looks like a middle segment of a long object
  • If an identical block is present on the left, but not on the right, the block looks like the right end of a long object
  • If an identical block is present on the right, but not on the left, the block looks like the left end of a long object
  • Otherwise, the block takes on a unique single-block appearance

Only the Wooden Log block uses this behavior type.

Column

Blocks possessing the column behavior type act similarly to blocks possessing the screw behavior type, but with the key difference that only identical blocks are considered for the checks:

  • If identical blocks are present on both top and bottom, the block looks like a middle segment of a tall column
  • If an identical block is present on top, but not on bottom, the block looks like the bottom of a tall column
  • If an identical block is present on bottom, but not on top, the block looks like the top of a tall column
  • Otherwise, the block looks like a very short column

The Pillar Block uses this behavior type.

Girder

Blocks possessing the girder behavior type determine their appearance using the presence or absence of identical blocks cardinally adjacent to themselves:

  • If no identical blocks are cardinally adjacent, the block looks like a short vertical girder
  • If identical blocks are present on top or bottom (regardless of whether identical blocks are also present on left or right), the block's middle looks like a middle segment of a long vertical girder
    • If an identical block is not present on top, the block looks like the top end of a long vertical girder
    • If an identical block is not present on bottom, the block looks like the bottom end of a long vertical girder
  • If identical blocks are present on left or right, but not on top or bottom, the block's middle looks like a middle segment of a long horizontal girder
    • If an identical block is not present on left, the block looks like the left end of a long horizontal girder
    • If an identical block is not present on right, the block looks like the right end of a long horizontal girder

Blocks that have horizontal and vertical orientations, such as Ship Supports, use this behavior type.

Rail

Blocks possessing the rail behavior type determine their appearance using the presence or absence of valid blocks in all adjacent positions, both cardinally-adjacent positions and diagonally-adjacent positions. For rails, the following blocks and objects are classified as valid blocks: Rusty Rail, Composite Rail, Rail Bumper, Rail Switch (only in the "on" state), Rail Stop, and Rail Sensor.

  • If no valid blocks are present in any adjacent position, the rail is horizontal
  • If no valid blocks are diagonally adjacent or present on top or bottom, the rail is horizontal.
  • If valid blocks are present on left and right but not on top or bottom, the rail is horizontal.
  • If no valid blocks are diagonally adjacent or present on left or right, the rail is vertical
  • If valid blocks are present on top and bottom but not on left or right, the rail is vertical
  • If no valid blocks are cardinally adjacent or present on top-right or bottom-left, the rail is left-slant diagonal
  • If no valid blocks are cardinally adjacent or present on top-left or bottom-right, the rail is right-slant diagonal
  • Otherwise, the rail is circular with connectors, and it makes connections to adjacent valid blocks. Cardinally-adjacent valid blocks are preferred over diagonally-adjacent valid blocks, and the rail will only connect to a diagonally-adjacent valid block if there are no cardinally-adjacent valid blocks touching the diagonally-adjacent valid block.

Only Rusty Rail and Composite Rail blocks use this behavior type.

Pipe

Blocks possessing the pipe behavior type determine their appearance using the presence or absence of identical blocks in cardinally-adjacent positions. In addition, pipes sometimes take on a different appearance when placed in the background rather than the foreground, though only identical blocks in the same layer are considered (i.e. background pipes only check background blocks, and foreground pipes only check foreground blocks):

  • If no identical blocks are present in any cardinally-adjacent position, the pipe is horizontal with both ends capped
  • If no identical blocks are present on top or bottom, the pipe is horizontal, capping ends where space exists
  • If no identical blocks are present on left or right, the pipe is vertical, capping ends where space exists
  • If no identical block is present on top:
    • If no identical block is present on left, the pipe is an L-pipe with its holes on bottom and right. This L-pipe takes on a different appearance if it is in the background rather than the foreground
    • If no identical block is present on right, the pipe is an L-pipe with its holes on bottom and left. This L-pipe takes on a different appearance if it is in the background rather than the foreground
    • Otherwise, the pipe is a T-pipe which has holes on left, right and bottom
  • If no identical block is present on bottom:
    • If no identical block is present on left, the pipe is an L-pipe with its holes on top and right. This L-pipe takes on a different appearance if it is in the background rather than the foreground
    • If no identical block is present on right, the pipe is an L-pipe with its holes on top and left. This L-pipe takes on a different appearance if it is in the background rather than the foreground
    • Otherwise, the pipe is a T-pipe which has holes on left, right and top
  • If identical blocks are present in all cardinally-adjacent positions, the pipe is an X-pipe with holes on all four cardinal sides
  • If identical blocks are present on all sides except for the right, the pipe is a T-pipe with holes on top, left, and bottom
  • If identical blocks are present on all sides except for the left, the pipe is a T-pipe with holes on top, right, and bottom

All blocks resembling pipes, such as Sewer Pipe blocks, use this behavior type.

Platform

Blocks possessing the platform behavior type determine their appearance using the presence or absence of blocks in all adjacent slots as well as in the slots 2 tiles left and right of the given block (referred to later as "far left" and "far right").

The platform behavior type is the most complex of all the block behavior types, possessing a multitude of block checks which are performed in order until one of them succeeds, at which point it stops checking for other possibilities:

Crossed Stairs

  • If identical blocks are present in all diagonally-adjacent slots, but not in any cardinally-adjacent slots, the block becomes an overlapping pair of platform stairs with the left-slant stairs lying on top

Overriding Platforms

  • If identical blocks are present on left and right, the block is a flat platform
  • If identical blocks are present on bottom-left and top-left, but not on bottom, left or right, the block is a flat platform
  • Again, if identical blocks are present on left and right, the block is a flat platform (just in case it didn't succeed the first time when it should have succeeded)
  • If identical blocks are present on top-left and top-right, but not on top, left or right, the block is a flat platform
  • if identical blocks are present on bottom-left, top-left and right, the block is a flat platform
  • If identical blocks are present on bottom-right, top-right and left, the block is a flat platform
  • If identical blocks are present on left and top-left, a non-identical block is present on right, and no identical block is present on bottom-right, the block is a flat platform anchored on the right side
  • If identical blocks are present on right and top-right, a non-identical block is present on left, and no identical block is present on bottom-left, the block is a flat platform anchored on the left side
  • If identical blocks are present on left and top-left, but not on right and bottom-right, the block is a flat platform
  • If identical blocks are present on right and top-right, but not on left and bottom-left, the block is a flat platform

Stairs

  • If no identical block is present on bottom:
    • if identical blocks are present on top-right and bottom-right, but not on top-left, top, or right, the block is a set of right-slant stairs
    • if identical blocks are present on top-left and bottom-left, but not on top, top-right or left, the block is a set of left-slant stairs
    • if an identical block is present on bottom-left:
      • if identical blocks are present on left and far left, block is a flat platform laid over a set of right-slant stairs
      • otherwise, block is a set of right-slant stairs
    • if an identical block is present on bottom-right:
      • if identical blocks are present on right and far right, block is a flat platform laid over a set of left-slant stairs
      • otherwise, block is a set of left-slant stairs

More Stairs

  • If no identical block is present on top:
    • if identical blocks are present on top-right but not on left, block is set of right-slant stairs
    • if identical blocks are present on bottom-left and right but not on top-left and left, block is a set of right-slant stairs
    • if identical blocks are present on top-left but not on right, block is set of left-slant stairs
    • if identical blocks are present on bottom-right and left but not on top-right and right, block is a set of left-slant stairs

Final Checks

  • If non-identical blocks are present on left and right, block is a flat platform anchored on both the left side and the right side
  • If a non-identical block is present on left, block is a flat platform anchored on the left side
  • If a non-identical block is present on right, block is a flat platform anchored on the right side
  • Otherwise, block is a flat platform

This behavior type is unique to platforms - non-platform blocks never use this behavior type.

(Click here to return to Blocks.)