FgdEntity

class fgdtools.FgdEntity(class_type, definitions, name, description=None, properties=[], spawnflags=[], inputs=[], outputs=[])[source]

An entity, as represented in a Fgd file.

__init__(class_type, definitions, name, description=None, properties=[], spawnflags=[], inputs=[], outputs=[])[source]

Creates an instance of FgdEntity.

Parameters
  • class_type (str) – The entity’s type. Ex: ‘BaseClass’, ‘SolidClass’, ‘PointClass’, etc…

  • definitions (list[dict]) – Information defining the entity within the editor. Ex: ‘base()’, ‘size()’, ‘line()’, ‘studioprop()’, etc…

  • name (str) – The entity’s name.

  • description (str, optional) – The entity’s description.

  • properties (list[FgdEntityProperty], optional) – The entity’s properties.

  • spawnflags (list[FgdEntitySpawnflag], optional) – The entity’s spawnflags.

  • inputs (list[FgdEntityInput], optional) – The entity’s inputs.

  • output (list[FgdEntityOutput], optional) – The entity’s outputs.

__repr__()[source]

A partial, printable summary of a FgdEntity.

Returns

A Python formated string.

Return type

str

property schema

A schematic view of this entity’s attributes.

Returns

A dictionary.

Return type

dict

property properties_schema

A schematic view of this entity’s properties.

Returns

A list of dictionaries.

Return type

list[dict]

property inputs_schema

A schematic view of this entity’s inputs.

Returns

A list of dictionaries.

Return type

list[dict]

property outputs_schema

A schematic view of this entity’s outputs.

Returns

A list of dictionaries.

Return type

list[dict]

property spawnflags_schema

A schematic view of this entity’s spanwnflags.

Returns

A list of dictionaries.

Return type

list[dict]

property class_type

The entity’s type.

Return type

str

property parents

The entity’s parent entities, as defined in the entity’s base(definition).

Return type

list[FgdEntity]

property name

The entity’s type.

Return type

str

property description

The entity’s description.

Return type

str

property definitions

The entity’s definitions.

Return type

list[dict]

property properties

The entity’s properties, including inherited properties.

Note: As in the way Hammer behaves, properties of the same name are overridden.

Return type

list[FgdEntityProperty]

property spawnflags

The entity’s spawnflags, including inherited spawnflags.

Note: As in the way Hammer behaves, the spawnflags definition will merge with inherited definitions only if there is no collision between values. If there is a collision, only the latest definition will be taken into account.

Return type

list[FgdEntitySpawnflag]

property inputs

The entity’s inputs, including inherited inputs.

Note: As in the way Hammer behaves, inputs cannot be overridden. All duplicate inputs are ignored, only the oldest is returned.

Return type

list[FgdEntityInput]

property outputs

The entity’s outputs, including inherited outputs.

Note: As in the way Hammer behaves, outputs cannot be overridden. All duplicate outputs are returned.

Return type

list[FgdEntityOutput]

property_by_name(prop_name)[source]

Finds an entity property by its name.

Parameters

prop_name (str) – The entity property name to look for.

Raises

PropertyNotFound – Whenever an entity property could not be found.

Returns

An entity property with matching name.

Return type

FgdEntityProperty

spawnflag_by_value(spawnflag_value)[source]

Finds a property choice by its value.

Parameters

spawnflag_value (int) – The property spawnflag value to look for.

Raises

SpawnflagNotFound – Whenever an entity spawnflag could not be found.

Returns

An entity spawnflag with matching value.

Return type

FgdEntitySpawnflag

input_by_name(input_name)[source]

Finds an entity input by its name.

Parameters

input_name (str) – The entity input name to look for.

Raises

InputNotFound – Whenever an entity input could not be found.

Returns

An entity input with matching name.

Return type

FgdEntityInput

output_by_name(output_name)[source]

Finds an entity output by its name.

Parameters

output_name (str) – The entity output name to look for.

Raises

OutputNotFound – Whenever an entity output could not be found.

Returns

An entity output with matching name.

Return type

FgdEntityOutput

fgd_str()[source]

A string representation of the FgdEntity formated as in the a .fgd file.

Returns

Fgd formated string.

Return type

str