tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.DrawLayer< InfoType > Class Template Reference

This class represents a layer of the drawing of an object, using a certain type of InfoType to help with its drawing. More...

+ Collaboration diagram for Terraria.ModLoader.DrawLayer< InfoType >:

Public Member Functions

virtual void Draw (ref InfoType drawInfo)
 Invokes this DrawLayer's layer action. More...
 
bool ShouldDraw< T > (IList< T > layers)
 Whether or not this layer should be drawn. Returns false if visible is false. If layerList is of type List<DrawLayer<InfoType>> and parent is not null, this will also return false if the parent is not drawn. More...
 

Public Attributes

readonly Action< InfoType > layer
 The delegate of this method, which can either do the actual drawing or add draw data, depending on what kind of layer this is. More...
 
readonly string mod
 The name of the mod to which this DrawLayer belongs. More...
 
readonly string Name
 The name which identifies this DrawLayer. More...
 
readonly DrawLayer< InfoType > parent
 The parent of this DrawLayer. If the parent is not drawn, this layer will not be drawn either. Defaults to null, which skips the parent check. More...
 
bool visible = true
 Whether or not this DrawLayer should be drawn. For vanilla layers, this will be set to true before all drawing-related hooks are called. For modded layers, you must set this to true or false yourself. More...
 

Protected Member Functions

 DrawLayer (string mod, string name, Action< InfoType > layer)
 Creates a DrawLayer with the given mod name, identifier name, and drawing action. More...
 
 DrawLayer (string mod, string name, DrawLayer< InfoType > parent, Action< InfoType > layer)
 Creates a DrawLayer with the given mod name, identifier name, parent layer, and drawing action. More...
 

Detailed Description

This class represents a layer of the drawing of an object, using a certain type of InfoType to help with its drawing.

Template Parameters
InfoType

Definition at line 10 of file DrawLayer.cs.

Constructor & Destructor Documentation

◆ DrawLayer() [1/2]

Terraria.ModLoader.DrawLayer< InfoType >.DrawLayer ( string  mod,
string  name,
Action< InfoType >  layer 
)
protected

Creates a DrawLayer with the given mod name, identifier name, and drawing action.

Parameters
mod
name
layer

Definition at line 39 of file DrawLayer.cs.

39 {
40 this.mod = mod;
41 this.Name = name;
42 this.parent = null;
43 this.layer = layer;
44 }
readonly string mod
The name of the mod to which this DrawLayer belongs.
Definition: DrawLayer.cs:15
readonly Action< InfoType > layer
The delegate of this method, which can either do the actual drawing or add draw data,...
Definition: DrawLayer.cs:27

References Terraria.ModLoader.DrawLayer< InfoType >.layer, and Terraria.ModLoader.DrawLayer< InfoType >.mod.

◆ DrawLayer() [2/2]

Terraria.ModLoader.DrawLayer< InfoType >.DrawLayer ( string  mod,
string  name,
DrawLayer< InfoType >  parent,
Action< InfoType >  layer 
)
protected

Creates a DrawLayer with the given mod name, identifier name, parent layer, and drawing action.

Parameters
mod
name
parent
layer

Definition at line 53 of file DrawLayer.cs.

53 {
54 this.mod = mod;
55 this.Name = name;
56 this.parent = parent;
57 this.layer = layer;
58 }
readonly DrawLayer< InfoType > parent
The parent of this DrawLayer. If the parent is not drawn, this layer will not be drawn either....
Definition: DrawLayer.cs:23

References Terraria.ModLoader.DrawLayer< InfoType >.layer, Terraria.ModLoader.DrawLayer< InfoType >.mod, and Terraria.ModLoader.DrawLayer< InfoType >.parent.

Member Function Documentation

◆ Draw()

virtual void Terraria.ModLoader.DrawLayer< InfoType >.Draw ( ref InfoType  drawInfo)
virtual

Invokes this DrawLayer's layer action.

Parameters
drawInfo

Definition at line 84 of file DrawLayer.cs.

84 {
85 this.layer(drawInfo);
86 }

References Terraria.ModLoader.DrawLayer< InfoType >.layer.

◆ ShouldDraw< T >()

bool Terraria.ModLoader.DrawLayer< InfoType >.ShouldDraw< T > ( IList< T >  layers)

Whether or not this layer should be drawn. Returns false if visible is false. If layerList is of type List<DrawLayer<InfoType>> and parent is not null, this will also return false if the parent is not drawn.

Template Parameters
T
Parameters
layers
Returns
Type Constraints
T :DrawLayer<InfoType> 

Definition at line 66 of file DrawLayer.cs.

66 : DrawLayer<InfoType> {
67 if (!this.visible) {
68 return false;
69 }
70 DrawLayer<InfoType> parentLayer = this.parent;
71 while (parentLayer != null) {
72 if (!parentLayer.visible || !layers.Contains((T)parentLayer)) {
73 return false;
74 }
75 parentLayer = parentLayer.parent;
76 }
77 return true;
78 }
bool visible
Whether or not this DrawLayer should be drawn. For vanilla layers, this will be set to true before al...
Definition: DrawLayer.cs:31

References Terraria.ModLoader.DrawLayer< InfoType >.parent, and Terraria.ModLoader.DrawLayer< InfoType >.visible.

Member Data Documentation

◆ layer

readonly Action<InfoType> Terraria.ModLoader.DrawLayer< InfoType >.layer

The delegate of this method, which can either do the actual drawing or add draw data, depending on what kind of layer this is.

Definition at line 27 of file DrawLayer.cs.

Referenced by Terraria.ModLoader.DrawLayer< InfoType >.DrawLayer(), and Terraria.ModLoader.DrawLayer< InfoType >.Draw().

◆ mod

readonly string Terraria.ModLoader.DrawLayer< InfoType >.mod

The name of the mod to which this DrawLayer belongs.

Definition at line 15 of file DrawLayer.cs.

Referenced by Terraria.ModLoader.DrawLayer< InfoType >.DrawLayer().

◆ Name

readonly string Terraria.ModLoader.DrawLayer< InfoType >.Name

The name which identifies this DrawLayer.

Definition at line 19 of file DrawLayer.cs.

◆ parent

readonly DrawLayer<InfoType> Terraria.ModLoader.DrawLayer< InfoType >.parent

The parent of this DrawLayer. If the parent is not drawn, this layer will not be drawn either. Defaults to null, which skips the parent check.

Definition at line 23 of file DrawLayer.cs.

Referenced by Terraria.ModLoader.DrawLayer< InfoType >.DrawLayer(), and Terraria.ModLoader.DrawLayer< InfoType >.ShouldDraw< T >().

◆ visible

bool Terraria.ModLoader.DrawLayer< InfoType >.visible = true

Whether or not this DrawLayer should be drawn. For vanilla layers, this will be set to true before all drawing-related hooks are called. For modded layers, you must set this to true or false yourself.

Definition at line 31 of file DrawLayer.cs.

Referenced by Terraria.ModLoader.DrawLayer< InfoType >.ShouldDraw< T >().