Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemGlow.cs
浏览该文件的文档.
1
using
Engine
;
2
using
Engine.Graphics
;
3
using
GameEntitySystem
;
4
using
TemplatesDatabase
;
5
6
namespace
Game
{
7
public
class
SubsystemGlow
:
Subsystem
,
IDrawable
{
8
public
SubsystemSky
m_subsystemSky
;
9
10
public
Dictionary<GlowPoint, bool>
m_glowPoints
= [];
11
12
public
PrimitivesRenderer3D
m_primitivesRenderer
=
new
();
13
14
public
TexturedBatch3D
[]
m_batchesByType
=
new
TexturedBatch3D
[4];
15
16
public
static
int
[]
m_drawOrders
= [110];
17
18
public
int
[]
DrawOrders
=>
m_drawOrders
;
19
20
public
GlowPoint
AddGlowPoint
() {
21
GlowPoint
glowPoint =
new
();
22
m_glowPoints
.Add(glowPoint,
true
);
23
return
glowPoint;
24
}
25
26
public
void
RemoveGlowPoint
(
GlowPoint
glowPoint) {
27
m_glowPoints
.Remove(glowPoint);
28
}
29
30
public
virtual
void
Draw
(
Camera
camera,
int
drawOrder) {
31
foreach
(
GlowPoint
key
in
m_glowPoints
.Keys) {
32
if
(key.
Color
.
A
> 0) {
33
Vector3
vector = key.Position - camera.ViewPosition;
34
float
num =
Vector3
.
Dot
(vector, camera.ViewDirection);
35
if
(num > 0.01f) {
36
float
num2 = vector.
Length
();
37
if
(num2 <
m_subsystemSky
.VisibilityRange) {
38
float
num3 = key.
Size
;
39
if
(key.
FarDistance
> 0f) {
40
num3 += (key.FarSize - key.
Size
) *
MathUtils
.
Saturate
(num2 / key.
FarDistance
);
41
}
42
Vector3
v = (0f - (0.01f + 0.02f * num)) / num2 * vector;
43
Color
color =
Color
.
LerpNotSaturated
(
44
key.
Color
,
45
m_subsystemSky
.ViewFogColor,
46
m_subsystemSky
.CalculateFog(camera.ViewPosition, key.
Position
)
47
);
48
Vector3
p = key.Position + num3 * (-key.Right - key.
Up
) + v;
49
Vector3
p2 = key.Position + num3 * (key.Right - key.
Up
) + v;
50
Vector3
p3 = key.Position + num3 * (key.Right + key.
Up
) + v;
51
Vector3
p4 = key.Position + num3 * (-key.Right + key.
Up
) + v;
52
m_batchesByType
[(int)key.
Type
]
53
.QueueQuad(
54
p,
55
p2,
56
p3,
57
p4,
58
new
Vector2
(0f, 0f),
59
new
Vector2
(1f, 0f),
60
new
Vector2
(1f, 1f),
61
new
Vector2
(0f, 1f),
62
color
63
);
64
}
65
}
66
}
67
}
68
m_primitivesRenderer
.Flush(camera.ViewProjectionMatrix);
69
}
70
71
public
override
void
Load
(
ValuesDictionary
valuesDictionary) {
72
m_subsystemSky
=
Project
.FindSubsystem<
SubsystemSky
>(
true
);
73
m_batchesByType
[0] =
m_primitivesRenderer
.TexturedBatch(
74
ContentManager
.
Get
<
Texture2D
>(
"Textures/RoundGlow"
),
75
false
,
76
0,
77
DepthStencilState
.
DepthRead
,
78
RasterizerState
.
CullCounterClockwiseScissor
,
79
BlendState
.
AlphaBlend
,
80
SamplerState
.
LinearClamp
81
);
82
m_batchesByType
[1] =
m_primitivesRenderer
.TexturedBatch(
83
ContentManager
.
Get
<
Texture2D
>(
"Textures/SquareGlow"
),
84
false
,
85
0,
86
DepthStencilState
.
DepthRead
,
87
RasterizerState
.
CullCounterClockwiseScissor
,
88
BlendState
.
AlphaBlend
,
89
SamplerState
.
LinearClamp
90
);
91
m_batchesByType
[2] =
m_primitivesRenderer
.TexturedBatch(
92
ContentManager
.
Get
<
Texture2D
>(
"Textures/HorizontalRectGlow"
),
93
false
,
94
0,
95
DepthStencilState
.
DepthRead
,
96
RasterizerState
.
CullCounterClockwiseScissor
,
97
BlendState
.
AlphaBlend
,
98
SamplerState
.
LinearClamp
99
);
100
m_batchesByType
[3] =
m_primitivesRenderer
.TexturedBatch(
101
ContentManager
.
Get
<
Texture2D
>(
"Textures/VerticalRectGlow"
),
102
false
,
103
0,
104
DepthStencilState
.
DepthRead
,
105
RasterizerState
.
CullCounterClockwiseScissor
,
106
BlendState
.
AlphaBlend
,
107
SamplerState
.
LinearClamp
108
);
109
}
110
}
111
}
Engine.Graphics.BlendState
定义
BlendState.cs:2
Engine.Graphics.BlendState.AlphaBlend
static readonly BlendState AlphaBlend
定义
BlendState.cs:27
Engine.Graphics.DepthStencilState
定义
DepthStencilState.cs:2
Engine.Graphics.DepthStencilState.DepthRead
static readonly DepthStencilState DepthRead
定义
DepthStencilState.cs:11
Engine.Graphics.PrimitivesRenderer3D
定义
PrimitivesRenderer3D.cs:4
Engine.Graphics.RasterizerState
定义
RasterizerState.cs:2
Engine.Graphics.RasterizerState.CullCounterClockwiseScissor
static readonly RasterizerState CullCounterClockwiseScissor
定义
RasterizerState.cs:23
Engine.Graphics.SamplerState
定义
SamplerState.cs:2
Engine.Graphics.SamplerState.LinearClamp
static SamplerState LinearClamp
定义
SamplerState.cs:25
Engine.Graphics.Texture2D
定义
Texture2D.cs:15
Engine.Graphics.TexturedBatch3D
定义
TexturedBatch3D.cs:2
Engine.MathUtils
定义
MathUtils.cs:2
Engine.MathUtils.Saturate
static float Saturate(float x)
定义
MathUtils.cs:163
Game.Camera
定义
Camera.cs:5
Game.ContentManager
定义
ContentManager.cs:50
Game.ContentManager.Get
static object Get(Type type, string name)
定义
ContentManager.cs:70
Game.GlowPoint
定义
GlowPoint.cs:4
Game.GlowPoint.Color
Color Color
定义
GlowPoint.cs:13
Game.GlowPoint.FarDistance
float FarDistance
定义
GlowPoint.cs:19
Game.GlowPoint.Size
float Size
定义
GlowPoint.cs:15
Game.GlowPoint.Up
Vector3 Up
定义
GlowPoint.cs:9
Game.GlowPoint.Type
GlowPointType Type
定义
GlowPoint.cs:21
Game.GlowPoint.Position
Vector3 Position
定义
GlowPoint.cs:5
Game.SubsystemGlow
定义
SubsystemGlow.cs:7
Game.SubsystemGlow.Load
override void Load(ValuesDictionary valuesDictionary)
定义
SubsystemGlow.cs:71
Game.SubsystemGlow.m_drawOrders
static int[] m_drawOrders
定义
SubsystemGlow.cs:16
Game.SubsystemGlow.Draw
virtual void Draw(Camera camera, int drawOrder)
定义
SubsystemGlow.cs:30
Game.SubsystemGlow.m_primitivesRenderer
PrimitivesRenderer3D m_primitivesRenderer
定义
SubsystemGlow.cs:12
Game.SubsystemGlow.m_glowPoints
Dictionary< GlowPoint, bool > m_glowPoints
定义
SubsystemGlow.cs:10
Game.SubsystemGlow.AddGlowPoint
GlowPoint AddGlowPoint()
定义
SubsystemGlow.cs:20
Game.SubsystemGlow.RemoveGlowPoint
void RemoveGlowPoint(GlowPoint glowPoint)
定义
SubsystemGlow.cs:26
Game.SubsystemGlow.m_subsystemSky
SubsystemSky m_subsystemSky
定义
SubsystemGlow.cs:8
Game.SubsystemGlow.DrawOrders
int[] DrawOrders
定义
SubsystemGlow.cs:18
Game.SubsystemGlow.m_batchesByType
TexturedBatch3D[] m_batchesByType
定义
SubsystemGlow.cs:14
Game.SubsystemSky
定义
SubsystemSky.cs:8
GameEntitySystem.Subsystem
定义
Subsystem.cs:5
GameEntitySystem.Subsystem.ValuesDictionary
ValuesDictionary ValuesDictionary
定义
Subsystem.cs:12
GameEntitySystem.Subsystem.Project
Project Project
定义
Subsystem.cs:10
Game.IDrawable
定义
IDrawable.cs:2
Engine.Graphics
定义
BaseBatch.cs:1
Engine.Graphics.ShaderParameterType.Vector2
@ Vector2
定义
ShaderParameterType.cs:4
Engine
定义
BaseSound.cs:10
GameEntitySystem
定义
Component.cs:6
Game
定义
ContentFileBridge.cs:4
TemplatesDatabase
定义
Database.cs:6
Engine.Color
定义
Color.cs:2
Engine.Color.A
byte A
定义
Color.cs:92
Engine.Color.LerpNotSaturated
static Color LerpNotSaturated(Color c1, Color c2, float f)
定义
Color.cs:169
Engine.Vector2
定义
Vector2.cs:2
Engine.Vector3
定义
Vector3.cs:2
Engine.Vector3.Length
float Length()
定义
Vector3.cs:116
Engine.Vector3.Dot
static float Dot(Vector3 v1, Vector3 v2)
定义
Vector3.cs:112
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Subsystem
SubsystemGlow.cs
制作者
1.16.1