All objects in Beyond are instantiated from a template, which contains a set of constraints limiting where the building can be built.
A simple constraints syntax allows for all kind of combinations. It relies on the fact that a template has only one top level constraint, which in most cases is made of a mix of other constraints.
Testing constraints returns true when the object can be placed at its current position, and false otherwise.
List of possible constraints:
OR (List<Constraints>) : True if any of the constraints in the list is true
AND (List<Constraints>): True if all the constraints in the list are true
TOPCLEAR(): The top of the object must be clear from terrain
ALLCLEAR(layermask): The whole object must be clear from this layer mask (terrain, trees,...)
BASEIN(depth): The base of the object must be in the terrain by at least depth units
NEEDS (List<Template> , List<Offset> , List<Side>): The object needs another object from one of the templates in the list to be in one of the cells defined by the list of offsets on one of the sides in the list of sides.
NEEDSALL (Template , List<Offset> , List<Side>): The object needs another object from the Template in all of the cells defined by the list of offsets and any of the sides from the list of sides.
FIRSTINGROUP(): The object doesn't need to snap if the group is empty. This constraints allows for the placement of the first Foundation, which in turns creates a group. (Foundations placed later cannot fulfill this constraints since the group is not empty, so they'll have to snap)
Example: Floor
A floor needs to be all clear from terrain and either have a floor neighbouring it on the same level or a wall 3 cells below. This is represented like this:
Floor constraints = AND (C4 , C3)
C4 = ALLCLEAR()
C3 = OR (C2 , C1)
C2 = NEEDS ({Wall} , {(0,-3,0)},{left,forward,right,back})
C1 = NEEDS({Floor} , {(-1,0,0) ; (+1,0,0) ; (0,0,-1) ; (0,0,+1)},{down})
Example: Foundation
A Foundation needs to have its base inside the terrain, its top must be clear, and it can either be the first element in a group, or snap to another Foundation on one of its horizontal sides:
Foundation constraints = AND(C5 , C4, C3)
C5 = TOPCLEAR()
C4 = BASEIN(0.2)
C3 = OR(C2,C1)
C2 = FIRSTINGROUP()
C1 = NEEDS({Foundation} , {(-1,0,0) ; (+1,0,0) ; (0,0,-1) ; (0,0,+1)},{down})