entity_like

class EntityLike

Bases: SpatialLike

Abstract base class for a blueprintable entity. Allows the user to specify custom entity analogues that can be passed into Blueprint instances. Group and RailPlanner are examples of custom EntityLike classes.

All EntityLike subclasses must implement the following properties:

  • name

  • type

  • id

  • tile_width

  • tile_height

  • position

  • collision_set

  • collision_mask

property circuit_connectable : bool

Whether or not this EntityLike can be connected using circuit wires.

Example:

>>> from draftsman.entity import *
>>> Beacon().circuit_connectable
False
>>> Inserter().circuit_connectable
True
>>> DeciderCombinator().circuit_connectable
True
abstract property collision_mask : set[str]

A set of strings representing the collision layers that this object collides with.

abstract property collision_set : CollisionSet | None

Set of CollisionShape where the Entity’s position acts as their origin.

property double_grid_aligned : bool

Whether or not this EntityLike is “double-grid-aligned”, which applies to entities which need to align with the rail grid.

property dual_circuit_connectable : bool

Whether or not this EntityLike has two circuit connection points.

Example:

>>> from draftsman.entity import *
>>> Beacon().dual_circuit_connectable
False
>>> Inserter().dual_circuit_connectable
False
>>> DeciderCombinator().dual_circuit_connectable
True
property dual_power_connectable : bool

Whether or not this EntityLike has two power connection points.

Example:

>>> from draftsman.entity import *
>>> Beacon().dual_power_connectable
False
>>> ElectricPole().dual_power_connectable
False
>>> PowerSwitch().dual_power_connectable
True
property flags : set[str]

The set of flags associated with this EntityLike. Returns None if the entitylike is not recognized by Draftsman.

abstract property global_position : Vector

Position of the object, expressed in global space (world space). The sum position of this object and all of its parent’s positions combined.

property parent : Collection | None

The parent Collection object that contains the entity, or None if the entity does not currently exist within an Collection.

abstract property position : Vector

Position of the object, expressed in local space. Local space can be either global space (if the EntityLike exists in a Blueprint at a root level) or local to it’s parent Group.

property power_connectable : bool

Whether or not this EntityLike can be connected using power wires.

Example:

>>> from draftsman.entity import *
>>> Beacon().power_connectable
False
>>> ElectricPole().power_connectable
True
>>> PowerSwitch().power_connectable
True
property rotatable : bool

Whether or not this EntityLike has the capability of being rotated. This does not mean that blueprints containing these entities cannot be rotated; rather, it just means they will only ever have one orientation.

For example, it’s impossible for a Factorio Reactor to be oriented, so Reactor.rotatable always returns False.

get() Entity | list[Entity]

Gets this Entity. Redundant for regular instances of Entity, but is needed for Collections like Group.

This function resolves some abstract EntityLike object (which can have no direct relation to Factorio whatsoever) to one or more valid Factorio-importable Entity instances.

Returns:

One or more Entity instances that represents this entire EntityLike.

get_world_bounding_box() AABB | None

Gets the world-space coordinates AABB that completely encompasses the collision_set of this SpatialLike. Returns None if the collision set of the target object is unknown.

get_world_collision_set() CollisionSet

Get’s the world-space coordinate CollisionSet of the object, AKA the collection of all shapes that this EntityLike interacts with.

Returns:

A copy of this objects CollisionSet with the correct world-space location.

abstract mergable_with(other: EntityLike) bool

Checks to see if an entity is “mergable” with another entity. This means that if a certain set of criteria is met, the attributes of other will be combined to the attributes of this entity. This is useful for mimicking cases where entities of the same name and type are placed on top of each other, merging them together into a single entity with shared attributes.

For the full list of all merging rules, see (TODO).

Note

This function does not actually merge the two, it simply checks to see if such a merge is considered valid. To actually merge the two entities use merge().

Parameters:
other: EntityLike

The other EntityLike to check against.

Returns:

True if they can be merged, False otherwise.

abstract merge(other: EntityLike) None

Changes the attributes of the calling entity with the attributes of the passed in entity. The attributes of other take precedence over the attributes of the calling entity. They can be either copied or merged together, depending on the specific attribute being merged.

For the full list of all merging rules, see (TODO).

Parameters:
other: EntityLike

The other EntityLike to merge with.