Class FgdFile
Namespace: ValveResourceFormat.IO.Fgd
Assembly: ValveResourceFormat.dll
The classes a game declares for its tools in FGD files: the entity classes of the map editor with their variables, inputs, outputs and the helpers they are drawn with. Files are read the way Hammer reads them.
public sealed class FgdFileInheritance
object ← FgdFile
Constructors
FgdFile()
Initializes classes that find the files they read on disk: a file named without a folder is looked for next to the file that includes it, and then in the current folder.
public FgdFile()FgdFile(Func<string, Stream?>)
Initializes classes that open the files named without a folder through a file system first, such as the one a game mounts, before they are looked for on disk.
public FgdFile(Func<string, Stream?> openFile)Parameters
openFile Func<string, Stream?>
Opens a file by its name, or gives null where there is none.
Properties
Classes
Gets the classes, in the order they are declared.
public List<FgdClass> Classes { get; }Property Value
EntityGroups
Gets the groups entity classes are listed under.
public List<FgdEntityGroup> EntityGroups { get; }Property Value
Errors
Gets what could not be read. Reading carries on past it at the next section, or the next key of a class where only the key is wrong, so everything else of a file is still read.
public List<FgdError> Errors { get; }Property Value
Fallback
Gets or sets the classes FgdFile.FindClass(string) looks in for a class none is declared under here. Classes are still only based on the classes of their own FGD files.
public FgdFile? Fallback { get; set; }Property Value
GridNav
Gets the grid a game lays its navigation out on, where a file declares one.
public (int EdgeSize, int OffsetX, int OffsetY, int PickHeight)? GridNav { get; }Property Value
(int EdgeSize, int OffsetX, int OffsetY, int PickHeight)?
MapSize
Gets the bounds of a map along each axis, where a file of an older game declares them.
public (int Low, int High)? MapSize { get; }Property Value
VisGroupFilters
Gets the filters a file declares for what is shown of a map, as the keys they are declared with.
public List<KVObject> VisGroupFilters { get; }Property Value
List<KVObject>
Methods
FindClass(string)
Finds a class by its name, without regard to case, here and then in FgdFile.Fallback.
public FgdClass? FindClass(string name)Parameters
name string
Name of the class.
Returns
The class, or null when none is declared under that name.
Load(string)
Reads a file and the files it includes. Classes are not given what they take from the classes they are based on until FgdFile.ResolveBaseClasses() is called, once every file is read.
public bool Load(string fileName)Parameters
fileName string
The file, as a path or as a name to open through the file system of the classes.
Returns
bool
Whether the file was read without errors.
LoadGameFiles(KVObject)
Loads the files the Hammer block of the gameinfo.gi of a game names, the way Hammer does when it starts: the one under fgd, and the ones under fgd_files that exist, as a game can name some it does not ship. Base classes are resolved after each file.
public bool LoadGameFiles(KVObject hammer)Parameters
hammer KVObject
The Hammer block.
Returns
bool
Whether any of the files exists. They come with the tools of a game.
LoadText(string, string)
Reads FGD text.
public bool LoadText(string text, string fileName)Parameters
text string
The text of an FGD file.
fileName string
Name the text is reported under.
Returns
bool
Whether the text was read without errors.
ResolveBaseClasses()
Gives every class what it takes from the classes it is based on: their variables, inputs and outputs, their tags and keys, and their size and color where it declares none. Helpers are not taken. It can be called again after more files are read: what a class has by then counts as its own, so it keeps the variables it already took over the ones its bases have since changed, and gains the ones they added.
public void ResolveBaseClasses()ToString()
Lists the classes with what they declare, and what could not be read.
public override string ToString()Returns
string
The listing.

