Barotrauma Server Doc
Barotrauma.Sprite Class Reference
Inheritance diagram for Barotrauma.Sprite:
Barotrauma.SpriteSheet

Public Member Functions

override string ToString ()
 
 Sprite (ContentXElement element, string path="", string file="", bool lazyLoad=false)
 
 Sprite (string newFile, Vector2 newOrigin)
 
 Sprite (string newFile, Rectangle? sourceRectangle, Vector2? origin=null, float rotation=0)
 
void Remove ()
 
void ReloadXML ()
 Works only if there is a name attribute defined for the sprite. For items and structures, the entity id or name is used if the sprite's name attribute is not defined. More...
 
bool ParseTexturePath (string path="", string file="")
 

Static Public Member Functions

static Identifier GetIdentifier (XElement sourceElement)
 Creates a supposedly unique identifier from the parent element. If the parent element is not found, uses the sprite element. TODO: If there are multiple elements with exactly the same data, the ids will fail. -> Is there a better way to identify the sprites? ALSO TODO: delete :) More...
 

Public Attributes

Vector2 size = Vector2.One
 
float rotation
 

Protected Attributes

Vector2 offset
 
Vector2 origin
 
float depth
 

Properties

ContentXElement SourceElement [get]
 Reference to the xml element from where the sprite was created. Can be null if the sprite was not defined in xml! More...
 
bool LazyLoad [get]
 
Rectangle SourceRect [get, set]
 
float Depth [get, set]
 
Vector2 Origin [get, set]
 In pixels More...
 
Vector2 RelativeOrigin [get, set]
 0 - 1 More...
 
Vector2 RelativeSize [get]
 
ContentPath FilePath [get]
 
string FullPath [get]
 
bool Compress [get]
 
Identifier EntityIdentifier [get, set]
 Identifier of the Map Entity so that we can link the sprite to its owner. More...
 
string Name [get, set]
 

Detailed Description

Definition at line 13 of file Sprite.cs.

Constructor & Destructor Documentation

◆ Sprite() [1/3]

Barotrauma.Sprite.Sprite ( ContentXElement  element,
string  path = "",
string  file = "",
bool  lazyLoad = false 
)

Definition at line 110 of file Sprite.cs.

◆ Sprite() [2/3]

Barotrauma.Sprite.Sprite ( string  newFile,
Vector2  newOrigin 
)

Definition at line 165 of file Sprite.cs.

◆ Sprite() [3/3]

Barotrauma.Sprite.Sprite ( string  newFile,
Rectangle?  sourceRectangle,
Vector2?  origin = null,
float  rotation = 0 
)

Definition at line 171 of file Sprite.cs.

Member Function Documentation

◆ GetIdentifier()

static Identifier Barotrauma.Sprite.GetIdentifier ( XElement  sourceElement)
static

Creates a supposedly unique identifier from the parent element. If the parent element is not found, uses the sprite element. TODO: If there are multiple elements with exactly the same data, the ids will fail. -> Is there a better way to identify the sprites? ALSO TODO: delete :)

Definition at line 206 of file Sprite.cs.

◆ ParseTexturePath()

bool Barotrauma.Sprite.ParseTexturePath ( string  path = "",
string  file = "" 
)

Definition at line 291 of file Sprite.cs.

◆ ReloadXML()

void Barotrauma.Sprite.ReloadXML ( )

Works only if there is a name attribute defined for the sprite. For items and structures, the entity id or name is used if the sprite's name attribute is not defined.

Definition at line 231 of file Sprite.cs.

◆ Remove()

void Barotrauma.Sprite.Remove ( )

Definition at line 215 of file Sprite.cs.

◆ ToString()

override string Barotrauma.Sprite.ToString ( )

Definition at line 93 of file Sprite.cs.

Member Data Documentation

◆ depth

float Barotrauma.Sprite.depth
protected

Definition at line 44 of file Sprite.cs.

◆ offset

Vector2 Barotrauma.Sprite.offset
protected

Definition at line 24 of file Sprite.cs.

◆ origin

Vector2 Barotrauma.Sprite.origin
protected

Definition at line 32 of file Sprite.cs.

◆ rotation

float Barotrauma.Sprite.rotation

Definition at line 38 of file Sprite.cs.

◆ size

Vector2 Barotrauma.Sprite.size = Vector2.One

Definition at line 36 of file Sprite.cs.

Property Documentation

◆ Compress

bool Barotrauma.Sprite.Compress
get

Definition at line 91 of file Sprite.cs.

◆ Depth

float Barotrauma.Sprite.Depth
getset

Definition at line 52 of file Sprite.cs.

◆ EntityIdentifier

Identifier Barotrauma.Sprite.EntityIdentifier
getset

Identifier of the Map Entity so that we can link the sprite to its owner.

Definition at line 101 of file Sprite.cs.

◆ FilePath

ContentPath Barotrauma.Sprite.FilePath
get

Definition at line 87 of file Sprite.cs.

◆ FullPath

string Barotrauma.Sprite.FullPath
get

Definition at line 89 of file Sprite.cs.

◆ LazyLoad

bool Barotrauma.Sprite.LazyLoad
get

Definition at line 26 of file Sprite.cs.

◆ Name

string Barotrauma.Sprite.Name
getset

Definition at line 102 of file Sprite.cs.

◆ Origin

Vector2 Barotrauma.Sprite.Origin
getset

In pixels

Definition at line 61 of file Sprite.cs.

◆ RelativeOrigin

Vector2 Barotrauma.Sprite.RelativeOrigin
getset

0 - 1

Definition at line 75 of file Sprite.cs.

◆ RelativeSize

Vector2 Barotrauma.Sprite.RelativeSize
get

Definition at line 85 of file Sprite.cs.

◆ SourceElement

ContentXElement Barotrauma.Sprite.SourceElement
get

Reference to the xml element from where the sprite was created. Can be null if the sprite was not defined in xml!

Definition at line 18 of file Sprite.cs.

◆ SourceRect

Rectangle Barotrauma.Sprite.SourceRect
getset

Definition at line 46 of file Sprite.cs.