Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HairShaderDataSet.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Collections.Generic
;
3
using
Microsoft.Xna.Framework
;
4
using
Terraria.DataStructures
;
5
6
namespace
Terraria.Graphics.Shaders
;
7
8
public
class
HairShaderDataSet
9
{
10
protected
List<HairShaderData>
_shaderData
=
new
List<HairShaderData>
();
11
12
protected
Dictionary<int, short>
_shaderLookupDictionary
=
new
Dictionary<int, short>
();
13
14
protected
byte
_shaderDataCount
;
15
16
public
T
BindShader<T>
(
int
itemId, T
shaderData
)
where
T
:
HairShaderData
17
{
18
if
(
_shaderDataCount
==
byte
.MaxValue)
19
{
20
throw
new
Exception
(
"Too many shaders bound."
);
21
}
22
_shaderLookupDictionary
[itemId] = ++
_shaderDataCount
;
23
_shaderData
.
Add
(
shaderData
);
24
return
shaderData
;
25
}
26
27
public
void
Apply
(
short
shaderId
,
Player
player,
DrawData
?
drawData
=
null
)
28
{
29
if
(
shaderId
!= 0 &&
shaderId
<=
_shaderDataCount
)
30
{
31
_shaderData
[
shaderId
- 1].Apply(player,
drawData
);
32
}
33
else
34
{
35
Main
.
pixelShader
.CurrentTechnique.Passes[0].Apply();
36
}
37
}
38
39
public
Color
GetColor
(
short
shaderId
,
Player
player,
Color
lightColor)
40
{
41
if
(
shaderId
!= 0 &&
shaderId
<=
_shaderDataCount
)
42
{
43
return
_shaderData
[
shaderId
- 1].GetColor(player, lightColor);
44
}
45
return
new
Color
(lightColor.
ToVector4
() * player.
hairColor
.
ToVector4
());
46
}
47
48
public
HairShaderData
GetShaderFromItemId
(
int
type
)
49
{
50
if
(
_shaderLookupDictionary
.
ContainsKey
(
type
))
51
{
52
return
_shaderData
[
_shaderLookupDictionary
[
type
] - 1];
53
}
54
return
null
;
55
}
56
57
public
short
GetShaderIdFromItemId
(
int
type
)
58
{
59
if
(
_shaderLookupDictionary
.
ContainsKey
(
type
))
60
{
61
return
_shaderLookupDictionary
[
type
];
62
}
63
return
-1;
64
}
65
}
System.Collections.Generic.Dictionary.ContainsKey
bool ContainsKey(TKey key)
Definition
Dictionary.cs:917
System.Collections.Generic.Dictionary.Add
void Add(TKey key, TValue value)
Definition
Dictionary.cs:873
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Exception
Definition
Exception.cs:15
Terraria.Graphics.Shaders.HairShaderDataSet.Apply
void Apply(short shaderId, Player player, DrawData? drawData=null)
Definition
HairShaderDataSet.cs:27
Terraria.Graphics.Shaders.HairShaderDataSet._shaderLookupDictionary
Dictionary< int, short > _shaderLookupDictionary
Definition
HairShaderDataSet.cs:12
Terraria.Graphics.Shaders.HairShaderDataSet.BindShader< T >
T BindShader< T >(int itemId, T shaderData)
Definition
HairShaderDataSet.cs:16
Terraria.Graphics.Shaders.HairShaderDataSet.GetColor
Color GetColor(short shaderId, Player player, Color lightColor)
Definition
HairShaderDataSet.cs:39
Terraria.Graphics.Shaders.HairShaderDataSet._shaderData
List< HairShaderData > _shaderData
Definition
HairShaderDataSet.cs:10
Terraria.Graphics.Shaders.HairShaderDataSet.GetShaderIdFromItemId
short GetShaderIdFromItemId(int type)
Definition
HairShaderDataSet.cs:57
Terraria.Graphics.Shaders.HairShaderDataSet.GetShaderFromItemId
HairShaderData GetShaderFromItemId(int type)
Definition
HairShaderDataSet.cs:48
Terraria.Graphics.Shaders.HairShaderDataSet._shaderDataCount
byte _shaderDataCount
Definition
HairShaderDataSet.cs:14
Terraria.Graphics.Shaders.HairShaderDataSet
Definition
HairShaderDataSet.cs:9
Terraria.Graphics.Shaders.HairShaderData
Definition
HairShaderData.cs:9
Terraria.Main.pixelShader
static Effect pixelShader
Definition
Main.cs:2764
Terraria.Main
Definition
Main.cs:79
Terraria.Player.hairColor
Color hairColor
Definition
Player.cs:2133
Terraria.Player
Definition
Player.cs:42
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.ExceptionArgument.type
@ type
System.ConsoleKey.T
@ T
System
Definition
BlockingCollection.cs:8
Terraria.DataStructures
Definition
AEntitySource_OnHit.cs:1
Terraria.Graphics.Shaders
Definition
ArmorShaderData.cs:6
Microsoft.Xna.Framework.Color.ToVector4
Vector4 ToVector4()
Definition
Color.cs:481
Microsoft.Xna.Framework.Color
Definition
Color.cs:12
Terraria.DataStructures.DrawData
Definition
DrawData.cs:7
source
Terraria.Graphics.Shaders
HairShaderDataSet.cs
Generated by
1.10.0