Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
TextureAtlas.cs
浏览该文件的文档.
1
using
System.Globalization;
2
using
Engine
;
3
using
Engine.Graphics
;
4
5
namespace
Game
{
6
public
class
TextureAtlas
{
7
public
Texture2D
m_texture
;
8
9
public
Dictionary<string, Rectangle>
m_rectangles
= [];
10
11
public
Texture2D
Texture
=>
m_texture
;
12
13
public
TextureAtlas
(
Texture2D
texture,
string
atlasDefinition,
string
prefix) {
14
m_texture
= texture;
15
string
[] array = atlasDefinition.Split([
'\n'
,
'\r'
], StringSplitOptions.RemoveEmptyEntries);
16
int
num = 0;
17
while
(
true
) {
18
if
(num < array.Length) {
19
string
[] array2 = array[num].Split([
' '
], StringSplitOptions.RemoveEmptyEntries);
20
if
(array2.Length < 5) {
21
break
;
22
}
23
string
key = prefix + array2[0];
24
Rectangle
value =
new
() {
25
Left
=
int
.Parse(array2[1], CultureInfo.InvariantCulture),
26
Top
=
int
.Parse(array2[2], CultureInfo.InvariantCulture),
27
Width =
int
.Parse(array2[3], CultureInfo.InvariantCulture),
28
Height =
int
.Parse(array2[4], CultureInfo.InvariantCulture)
29
};
30
m_rectangles
.Add(key, value);
31
num++;
32
continue
;
33
}
34
return
;
35
}
36
throw
new
InvalidOperationException(
"Invalid texture atlas definition."
);
37
}
38
39
public
bool
ContainsTexture
(
string
textureName) =>
m_rectangles
.ContainsKey(textureName);
40
41
public
Vector4
?
GetTextureCoordinates
(
string
textureName) {
42
if
(
m_rectangles
.TryGetValue(textureName, out
Rectangle
value)) {
43
Vector4
value2 =
default
;
44
value2.X = value.Left / (float)
m_texture
.Width;
45
value2.Y = value.Top / (float)
m_texture
.Height;
46
value2.Z = value.Right / (float)
m_texture
.Width;
47
value2.W = value.Bottom / (float)
m_texture
.Height;
48
return
value2;
49
}
50
return
null
;
51
}
52
}
53
}
Engine.Graphics.Texture2D
定义
Texture2D.cs:15
Game.TextureAtlas.TextureAtlas
TextureAtlas(Texture2D texture, string atlasDefinition, string prefix)
定义
TextureAtlas.cs:13
Game.TextureAtlas.m_texture
Texture2D m_texture
定义
TextureAtlas.cs:7
Game.TextureAtlas.m_rectangles
Dictionary< string, Rectangle > m_rectangles
定义
TextureAtlas.cs:9
Game.TextureAtlas.Texture
Texture2D Texture
定义
TextureAtlas.cs:11
Game.TextureAtlas.ContainsTexture
bool ContainsTexture(string textureName)
定义
TextureAtlas.cs:39
Game.TextureAtlas.GetTextureCoordinates
Vector4? GetTextureCoordinates(string textureName)
定义
TextureAtlas.cs:41
Engine.Graphics
定义
BaseBatch.cs:1
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Game.ElectricConnectorDirection.Left
@ Left
定义
ElectricConnectorDirection.cs:4
Game.ElectricConnectorDirection.Top
@ Top
定义
ElectricConnectorDirection.cs:3
Engine.Rectangle
定义
Rectangle.cs:2
Engine.Vector4
定义
Vector4.cs:2
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Game
TextureAtlas.cs
制作者
1.16.1