Part placement blocking
Navigate
This subsection describes the data fields used to implement the part placement blocking. That's used for thruster and weapon exclusion zones.
base_part.rules
defines a single layer: default
. This contributes to the fact that all base game parts are blocked by all exclusion zones unless your mod changes something.
The only other layer used in the base game is tall
, for deck cannons and such.
In order to do anything, layers need to be referenced in at least 1 "Prohibit" (see below), and ProhibitedBy
, counting inheritance.
Data fields
Prohibits
Name | Type | Defines types | Default value |
---|---|---|---|
Prohibits
|
list[string]
|
ProhibitLayer
|
[default] (In |
A list of ProhibitLayer
s that the part is going to contribute to when prohibiting the part placement.
In other words, what layers this part can block.
ProhibitedBy
Name | Type | Defines types | Default value |
---|---|---|---|
ProhibitedBy
|
list[ProhibitLayer | string]
|
ProhibitLayer
|
[default] (In |
A list of ProhibitLayer
s to use when checking if part is prohibited from placing.
In other words, construction of this part can only be blocked by these layers. If this is empty, it can be built anywhere -- but placing it on another part will still remove the crushed part.
Because ProhibitedBy = [default]
in base_part.rules
, any new part that doesn't manually reject this inheritance will be blocked by the same exclusion zones as base game parts. This is normally good because it saves you some work.
ProhibitDirection
Name | Type | Defines types | Default value |
---|---|---|---|
ProhibitLeft , ProhibitRight , ProhibitAbove , ProhibitBelow
|
int
|
- | 0 (In |
Amount of cells to prohibit in a certain direction, with respect to current rotation.
How it works
A rectangle of prohibited cells will be drawn. Its length is the specified value (E.g.ProhibitAbove = 2
means the length is 2), and its width is the width of the part.
E.g. for the small thruster, it's 1 cell wide. For the large laser blaster, it's 2 cells wide.
If this behavior is not exactly what you want, use ProhibitRects instead (see below).
Prohibits
(see above).ProhibitRects
Name | Type | Defines types | Default value |
---|---|---|---|
ProhibitRects
|
list[list[ProhibitLayer, IntRect]]
|
- | - |
A list of cell areas to "prohibit", relative to the origin.
This is the most flexible data field for blocking construction of parts. It's very different from the other "Prohibit" data fields in the previous sections.
This is what Deck Cannons use.
How it works
Each line in the list is a single prohibited area. Let's call it a "ProhibitRect" * (with no "s") for convenience. *Not actually a legal word in the code.
Each ProhibitRect is itself a list with two parts :
- The first half,
ProhibitLayer
, is the arbitrary name of the layer. Base game parts almost always usedefault
here. You can come up with your own layer name — any parts that reference it withProhibitedBy
will be affected by this area. If you don't writedefault
here, that area will not block base game parts. If you want both, duplicate that line and edit, so that you cover eachProhibitLayer
. - The other half is 4 numbers (integers) making up an
IntRect
— that's the area of cells to prohibit :- x is the offset from the part to the left. So a negative number would go to the right.
- y is the offset from the part downwards.
- width is the width of the area. It expands to the right.
- height is the height of the area. It expands downwards, since the tile at the [x & y] coordinates serves as the origin of the ProhibitRect area, at its top left.
width
and height
should not be ≤ 0:
- Negative values don't «invert», resulting in an empty area.
- 0 just results in an empty area.
Origin
The origin tile is the first cell of the physical rect in the upper left corner, regardless of orientation. So it's not the same for each orientation except when the part's size is 1x1.
This is important because the x and y above are counted from that origin. This is why you need to know exactly what direction your part faces by default, before you define this.
Be aware that for weapons, the "turret" (the part that moves to aim) also partially counts, which can easily mess up your calculations.
To find the origin fast, hover over the weapon or select it. The tile in the upper-left corner of the white UI selection box is the origin. That's only valid for that specific orientation.
You can also launch the game in Developer Mode, and examine the weapon there, which gives you all the details.
default
:
ProhibitRects
[
[default, [-1, -5, 2, 3]]
]
Let's take a look at its IntRect
:
- x & y =
1
&5
- width & height =
2
&3
This creates an area to the lower right (1
cell to the right and 5
cells downwards),
with a size of 2
cells horizontally and 3
cells vertically.