entity_like¶
- class EntityLike¶
Bases:
SpatialLikeAbstract 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
CollisionShapewhere 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
Noneif 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
Collectionobject that contains the entity, orNoneif the entity does not currently exist within anCollection.
- 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
EntityLikehas 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
Reactorto be oriented, soReactor.rotatablealways returnsFalse.
- get() Entity | list[Entity]¶
Gets this
Entity. Redundant for regular instances ofEntity, but is needed forCollectionslikeGroup.This function resolves some abstract
EntityLikeobject (which can have no direct relation to Factorio whatsoever) to one or more valid Factorio-importableEntityinstances.- Returns:
One or more
Entityinstances that represents this entireEntityLike.
- get_world_bounding_box() AABB | None¶
Gets the world-space coordinates AABB that completely encompasses the
collision_setof thisSpatialLike. ReturnsNoneif the collision set of the target object is unknown.
- get_world_collision_set() CollisionSet¶
Get’s the world-space coordinate
CollisionSetof the object, AKA the collection of all shapes that this EntityLike interacts with.- Returns:
A copy of this objects
CollisionSetwith 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
otherwill 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
EntityLiketo check against.
- Returns:
Trueif they can be merged,Falseotherwise.
- abstract merge(other: EntityLike) None¶
Changes the attributes of the calling entity with the attributes of the passed in entity. The attributes of
othertake 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
EntityLiketo merge with.