-
Notifications
You must be signed in to change notification settings - Fork 1
Map
Gaspar edited this page Jan 20, 2024
·
19 revisions
Represents the .map file with its entities stored in a list.
| Attribute | Type | Description | Note |
|---|---|---|---|
name |
str |
The filename of the map | Automatically assigned when the map is loaded, not use when create a map from scratch |
path |
str |
The path to the loaded map file | Currently unused |
entities |
list[Entity] |
List of entities in the map | |
entity_counter |
int |
Counter for assigning unique IDs to entities |
Constructor method for the
Mapclass.
Parameters:
filename(str, optional): The filename of the map.
# Create a map from scratch
m = Map()Add brushes to the worldspawn entity.
Parameters:
*args(Union[Brush, List[Brush]]): Variable number of brushes or list of brushes to be added.
# Add brushes individually
m.add_brush(brush1)
m.add_brush(brush2)# Add all brushes at once
m.add_brush(brush1, brush2)# Add a list of brushes
list_brushes = [brush1, brush2]
m.add_brush(list_brushes)Add entities to the map.
Parameters:
*args(Union[Entity, List[Entity]]): Variable number of entities or list of entities to be added.
# Add entities individually
m.add_entity(ent1)
m.add_entity(ent2)# Add all entities at once
m.add_brush(ent1, ent2)# Add a list of entities
list_entities = [ent1, ent2]
m.add_brush(*list_entities)Return a deepcopy of the current map instance, useful for backup.
m_copy = m.copy()Return the parent entity of the specified brush.
Parameters:
target_brush(Brush): The target brush.
Returns:
Union[Entity, None]: The parent entity if found, else `None.
entity = m.get_entity_by_brush(brush1)Return a list of entities with a specified classname.
Parameters:
name(str): The classname value
Returns:
List[Entity]
m.get_entity_by_class('func_door')Return a string representation of the map.
Returns:
str: A string representation of the map.
Return an iterator over the Map entities.
Returns:
iter: An iterator over the Map entities.
# Instead of `for entity in m.entities:`
for entity in m:
# ...Check if an Entity or Brush instance is in Map
Returns:
bool: True if entity or brush is in map, False otherwise.
ent1 = Entity()
ent2 = Entity()
b = Brush()
m.add_entity(ent1)
m.add_brush(b)
if ent1 in m: # True
# ...
if ent2 in m: # False
# ...
if b in m: # True
# ...Get a list of all brushes in the map.
list_brushes = m.brushesGet a list of all brush entities in the map.
list_brush_entities = m.brush_entitiesGet a list of all brush faces in the map.
list_faces = m.facesGet a list of all point entities in the map.
list_point_entities = m.point_entitiesGet the worldspawn entity.
Returns:
Union[Entity, None]: The worldspawn entity if found, else `None.
world = m.worldspawn