Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemGlow.cs
浏览该文件的文档.
1using Engine;
5
6namespace Game {
9
10 public Dictionary<GlowPoint, bool> m_glowPoints = [];
11
13
15
16 public static int[] m_drawOrders = [110];
17
18 public int[] DrawOrders => m_drawOrders;
19
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;
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,
81 );
82 m_batchesByType[1] = m_primitivesRenderer.TexturedBatch(
83 ContentManager.Get<Texture2D>("Textures/SquareGlow"),
84 false,
85 0,
90 );
91 m_batchesByType[2] = m_primitivesRenderer.TexturedBatch(
92 ContentManager.Get<Texture2D>("Textures/HorizontalRectGlow"),
93 false,
94 0,
99 );
100 m_batchesByType[3] = m_primitivesRenderer.TexturedBatch(
101 ContentManager.Get<Texture2D>("Textures/VerticalRectGlow"),
102 false,
103 0,
108 );
109 }
110 }
111}
static readonly BlendState AlphaBlend
static readonly DepthStencilState DepthRead
static readonly RasterizerState CullCounterClockwiseScissor
static float Saturate(float x)
static object Get(Type type, string name)
GlowPointType Type
override void Load(ValuesDictionary valuesDictionary)
virtual void Draw(Camera camera, int drawOrder)
PrimitivesRenderer3D m_primitivesRenderer
Dictionary< GlowPoint, bool > m_glowPoints
void RemoveGlowPoint(GlowPoint glowPoint)
SubsystemSky m_subsystemSky
TexturedBatch3D[] m_batchesByType
ValuesDictionary ValuesDictionary
static Color LerpNotSaturated(Color c1, Color c2, float f)
static float Dot(Vector3 v1, Vector3 v2)