Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemSky.cs
浏览该文件的文档.
1using System.Globalization;
2using Engine;
6
7namespace Game {
9 public struct SkyVertex {
11
12 public Color Color;
13 }
14
15 public class SkyDome : IDisposable {
16 public const int VerticesCountX = 16;
17
18 public const int VerticesCountY = 8;
19
20 public float? LastUpdateTimeOfDay;
21
23
25
26 public float? LastUpdateFogDensity;
27
29
30 public SkyVertex[] Vertices = new SkyVertex[128];
31
32 public ushort[] Indices = new ushort[714];
33
35
37
38 public virtual void Dispose() {
39 Utilities.Dispose(ref VertexBuffer);
40 Utilities.Dispose(ref IndexBuffer);
41 }
42 }
43
44 public struct StarVertex {
46
48
49 public Color Color;
50 }
51
53
55
57
59
61
63
65
67
69
71
73
75
76 public Random m_random = new();
77
78 public Random m_fogSeedRandom = new();
79
81
82 public float m_viewFogBottom;
83
84 public float m_viewFogTop;
85
86 public float m_viewHazeStart;
87
88 public float m_viewHazeDensity;
89
90 public float m_viewFogDensity;
91
92 public bool m_viewIsSkyVisible;
93
95
97
99
101
102 public static UnlitShader m_shaderFlat = new(true, false, true, false);
103
104 public static UnlitShader m_shaderTextured = new(true, true, false, false);
105
108 new VertexElement(12, VertexElementFormat.NormalizedByte4, VertexElementSemantic.Color)
109 );
110
111 public Dictionary<GameWidget, SkyDome> m_skyDomes = [];
112
114
116
119 new VertexElement(12, VertexElementFormat.Vector2, VertexElementSemantic.TextureCoordinate),
120 new VertexElement(20, VertexElementFormat.NormalizedByte4, VertexElementSemantic.Color)
121 );
122
123 public const int m_starsCount = 250;
124
126
128
130
131 public bool DrawSkyEnabled = true;
132
133 // ReSharper disable UnassignedField.Global
135 // ReSharper restore UnassignedField.Global
136
137 public bool FogEnabled = true;
138
139 public int[] m_drawOrders = [-100, 5, 105];
140
141 public float[] m_cloudsLayerRadii = [0f, 0.8f, 0.95f, 1f];
142
143 public Color[] m_cloudsLayerColors = new Color[5];
144
145 public static int[] m_lightValuesMoonless = [0, 3, 6, 9, 12, 15];
146
147 public static int[] m_lightValuesNormal = [3, 5, 8, 10, 13, 15];
148
149 public virtual float SkyLightIntensity { get; set; }
150
151 public virtual int MoonPhase { get; set; }
152
153 public virtual int SkyLightValue { get; set; }
154
155 public virtual float VisibilityRange { get; set; }
156
157 public virtual float VisibilityRangeYMultiplier { get; set; }
158
159 public virtual float ViewUnderWaterDepth { get; set; }
160
161 public virtual float ViewUnderMagmaDepth { get; set; }
162
164
165 public virtual float ViewFogBottom => m_viewFogBottom;
166
167 public virtual float ViewFogTop => m_viewFogTop;
168
169 public virtual float ViewHazeStart => m_viewHazeStart;
170
171 public virtual float ViewHazeDensity => m_viewHazeDensity;
172
173 public virtual float ViewFogDensity => m_viewFogDensity;
174
176
177 public int[] DrawOrders => m_drawOrders;
178
180
181 // ReSharper disable UnassignedField.Global
182 public static SkyShader Shader;
183
185 // ReSharper restore UnassignedField.Global
186
187 public static bool DrawGalaxyEnabled = true;
188
189 public virtual void MakeLightningStrike(Vector3 targetPosition, bool manual) {
190 float explosionPressure = m_random.Float(0f, 1f) < 0.2f ? 39 : 19;
191 bool strike = m_subsystemTime.GameTime - m_lastLightningStrikeTime > 1.0;
192 bool setBodyOnFire = true;
194 "OnLightningStrike",
195 loader => {
196 loader.OnLightningStrike(this, ref targetPosition, ref strike, ref explosionPressure, ref setBodyOnFire);
197 return false;
198 }
199 );
200 if (m_lightningStrikePosition.HasValue
201 || !strike) {
202 return;
203 }
205 m_lightningStrikePosition = targetPosition;
207 float num = float.MaxValue;
208 foreach (Vector3 listenerPosition in m_subsystemAudio.ListenerPositions) {
209 float num2 = Vector2.Distance(new Vector2(listenerPosition.X, listenerPosition.Z), new Vector2(targetPosition.X, targetPosition.Z));
210 if (num2 < num) {
211 num = num2;
212 }
213 }
214 float delay = m_subsystemAudio.CalculateDelay(num);
215 if (num < 40f) {
216 m_subsystemAudio.PlayRandomSound("Audio/ThunderNear", 1f, m_random.Float(-0.2f, 0.2f), 0f, delay);
217 }
218 else if (num < 200f) {
219 m_subsystemAudio.PlayRandomSound("Audio/ThunderFar", 0.8f, m_random.Float(-0.2f, 0.2f), 0f, delay);
220 }
221 if (m_subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode != 0) {
222 return;
223 }
224 DynamicArray<ComponentBody> dynamicArray = [];
225 m_subsystemBodies.FindBodiesAroundPoint(new Vector2(targetPosition.X, targetPosition.Z), 4f, dynamicArray);
226 for (int i = 0; i < dynamicArray.Count; i++) {
227 ComponentBody componentBody = dynamicArray.Array[i];
228 if (setBodyOnFire
229 && componentBody.Position.Y > targetPosition.Y - 1.5f
230 && Vector2.Distance(
231 new Vector2(componentBody.Position.X, componentBody.Position.Z),
232 new Vector2(targetPosition.X, targetPosition.Z)
233 )
234 < 4f) {
235 componentBody.Entity.FindComponent<ComponentOnFire>()?.SetOnFire(null, m_random.Float(12f, 15f));
236 }
237 ComponentCreature componentCreature = componentBody.Entity.FindComponent<ComponentCreature>();
238 if (componentCreature != null
239 && componentCreature.PlayerStats != null) {
240 componentCreature.PlayerStats.StruckByLightning++;
241 }
242 }
243 bool flag = true;
244 int num3 = Terrain.ToCell(targetPosition.X);
245 int num4 = Terrain.ToCell(targetPosition.Y);
246 int num5 = Terrain.ToCell(targetPosition.Z);
247 if (!manual) {
248 for (int j = -1; j <= 1; j++) {
249 for (int k = -1; k <= 1; k++) {
250 for (int l = -1; l <= 1; l++) {
251 if (BlocksManager.Blocks[m_subsystemTerrain.Terrain.GetCellContents(num3 + j, num4 + k, num5 + l)] is LeavesBlock) {
252 flag = false;
253 }
254 }
255 }
256 }
257 }
258 if (flag) {
259 float pressure = m_random.Bool(0.2f) ? 39 : 19;
260 Project.FindSubsystem<SubsystemExplosions>(true).AddExplosion(num3, num4 + 1, num5, pressure, false, true);
261 }
262 int cellValue = m_subsystemTerrain.Terrain.GetCellValue(num3, num4, num5);
263 int num6 = Terrain.ExtractContents(cellValue);
264 if (num6 != 0) {
265 Block block = BlocksManager.Blocks[num6];
266 m_subsystemParticles.AddParticleSystem(
267 block.CreateDebrisParticleSystem(m_subsystemTerrain, new Vector3(num3 + 0.5f, num4 + 1.5f, num5 + 0.5f), cellValue, 2.5f)
268 );
269 }
270 }
271
272 public delegate float CalculateFogDelegate(Vector3 viewPosition, Vector3 position);
273
275
276 public delegate float CalculateFogNoHazeDelegate(Vector3 viewPosition, Vector3 position);
277
279
280 public virtual void Update(float dt) {
283 }
284
285 public virtual void Draw(Camera camera, int drawOrder) {
286 if (drawOrder == m_drawOrders[0]) {
289 Vector3 viewPosition = camera.ViewPosition;
290 int x = Terrain.ToCell(viewPosition.X);
291 int y = Terrain.ToCell(viewPosition.Y);
292 int z = Terrain.ToCell(viewPosition.Z);
293 float? surfaceHeight = m_subsystemFluidBlockBehavior.GetSurfaceHeight(x, y, z, out FluidBlock surfaceFluidBlock);
294 if (surfaceHeight.HasValue) {
295 if (surfaceFluidBlock is WaterBlock) {
296 ViewUnderWaterDepth = surfaceHeight.Value + 0.1f - viewPosition.Y;
297 }
298 else if (surfaceFluidBlock is MagmaBlock) {
299 ViewUnderMagmaDepth = surfaceHeight.Value + 1f - viewPosition.Y;
300 }
301 }
302 if (ViewUnderWaterDepth > 0f) {
303 int seasonalHumidity = m_subsystemTerrain.Terrain.GetSeasonalHumidity(x, z);
304 int temperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(x, z) + SubsystemWeather.GetTemperatureAdjustmentAtHeight(y);
305 Color c = BlockColorsMap.Water.Lookup(temperature, seasonalHumidity);
306 float num = MathUtils.Lerp(1f, 0.5f, seasonalHumidity / 15f);
307 float num2 = MathUtils.Lerp(1f, 0.2f, MathUtils.Saturate(0.075f * (ViewUnderWaterDepth - 2f)));
308 float num3 = MathUtils.Lerp(0.33f, 1f, SkyLightIntensity);
309 m_viewHazeStart = 0f;
310 m_viewHazeDensity = MathUtils.Lerp(0.25f, 0.1f, num * num2 * num3);
311 m_viewFogDensity = 0f;
312 m_viewFogBottom = 0f;
313 m_viewFogTop = 1f;
314 m_viewFogColor = Color.MultiplyColorOnly(c, 0.66f * num2 * num3); //在水中的视图雾颜色
316 m_viewIsSkyVisible = false;
317 }
318 else if (ViewUnderMagmaDepth > 0f) {
319 m_viewHazeStart = 0f;
320 m_viewHazeDensity = 10f;
321 m_viewFogDensity = 0f;
322 m_viewFogBottom = 0f;
323 m_viewFogTop = 1f;
324 m_viewFogColor = new Color(255, 80, 0); //在岩浆中的视图雾颜色
326 m_viewIsSkyVisible = false;
327 }
328 else {
330 float num4 = m_fogSeedRandom.Bool(0.66f) ? m_fogSeedRandom.Float(62f, 82f) : m_fogSeedRandom.Float(62f, 180f);
331 float x2 = Math.Clamp(num4 + m_fogSeedRandom.Float(-20f, 20f), 62f, 180f);
332 float num5 = m_fogSeedRandom.Bool(0.66f) ? m_fogSeedRandom.Float(12f, 22f) : m_fogSeedRandom.Float(12f, 80f);
333 m_viewFogBottom = MathUtils.Lerp(num4, x2, m_subsystemWeather.FogProgress);
335 m_viewFogDensity = MathF.Pow(m_subsystemWeather.FogIntensity, 2f) * m_fogSeedRandom.Float(0.04f, 0.1f);
336 float num6 = 256f;
337 float num7 = 128f;
338 int seasonalTemperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(
339 Terrain.ToCell(viewPosition.X),
340 Terrain.ToCell(viewPosition.Z)
341 );
342 float f = CalculateHazeFactor();
343 float num8 = MathUtils.Lerp(0.5f, 0f, f);
344 float num9 = MathUtils.Lerp(1f, 0.8f, f);
346 m_viewHazeDensity = 1f / ((num9 - num8) * VisibilityRange);
347 Color color = CalculateSkyColor(new Vector3(1f, 0f, 0f), seasonalTemperature);
348 Color color2 = CalculateSkyColor(new Vector3(0f, 0f, 1f), seasonalTemperature);
349 Color color3 = CalculateSkyColor(new Vector3(-1f, 0f, 0f), seasonalTemperature);
350 Color color4 = CalculateSkyColor(new Vector3(0f, 0f, -1f), seasonalTemperature);
351 Color c2 = 0.25f * color + 0.25f * color2 + 0.25f * color3 + 0.25f * color4;
352 Color c3 = CalculateSkyColor(new Vector3(camera.ViewDirection.X, 0f, camera.ViewDirection.Z), seasonalTemperature);
353 //在正常情况下(空气中)视图雾
356 VisibilityRange / num6,
357 VisibilityRange / num7,
358 MathF.Pow(m_subsystemWeather.PrecipitationIntensity, 4f)
359 );
360 m_viewIsSkyVisible = true;
361 }
362 if (!FogEnabled) {
364 m_viewFogDensity = 0f;
365 }
366 if (!DrawSkyEnabled
369 FlatBatch2D flatBatch2D = m_primitivesRenderer2d.FlatBatch(
370 -1,
374 );
375 int count = flatBatch2D.TriangleVertices.Count;
377 "ViewFogColor",
378 modLoader => {
379 modLoader.ViewFogColor(ViewUnderWaterDepth, ViewUnderMagmaDepth, ref m_viewFogColor);
380 return false;
381 }
382 );
383 flatBatch2D.QueueQuad(Vector2.Zero, camera.ViewportSize, 0f, m_viewFogColor);
384 flatBatch2D.TransformTriangles(camera.ViewportMatrix, count);
386 }
387 }
388 else if (drawOrder == m_drawOrders[1]) {
392 DrawSkydome(camera);
393 if (DrawGalaxyEnabled) {
394 DrawStars(camera);
395 DrawSunAndMoon(camera);
396 }
397 DrawClouds(camera);
399 "SkyDrawExtra",
400 loader => {
401 loader.SkyDrawExtra(this, camera);
402 return false;
403 }
404 );
405 if (Shader != null
406 && ShaderAlphaTest != null) {
407 if (m_primitiveRender.Shader == null
408 && m_primitiveRender.ShaderAlphaTest == null) {
409 m_primitiveRender.Shader = Shader;
410 m_primitiveRender.ShaderAlphaTest = ShaderAlphaTest;
411 m_primitiveRender.Camera = camera;
412 }
414 }
415 else {
417 }
418 }
419 }
420 else {
421 DrawLightning(camera);
423 }
424 }
425
426 public override void Load(ValuesDictionary valuesDictionary) {
427 m_subsystemTimeOfDay = Project.FindSubsystem<SubsystemTimeOfDay>(true);
428 m_subsystemSeasons = Project.FindSubsystem<SubsystemSeasons>(true);
429 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
430 m_subsystemGameInfo = Project.FindSubsystem<SubsystemGameInfo>(true);
431 m_subsystemTerrain = Project.FindSubsystem<SubsystemTerrain>(true);
432 m_subsystemWeather = Project.FindSubsystem<SubsystemWeather>(true);
433 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
434 m_subsystemBodies = Project.FindSubsystem<SubsystemBodies>(true);
435 m_subsystemParticles = Project.FindSubsystem<SubsystemParticles>(true);
437 m_sunTexture = ContentManager.Get<Texture2D>("Textures/Sun");
438 m_glowTexture = ContentManager.Get<Texture2D>("Textures/SkyGlow");
439 m_cloudsTexture = ContentManager.Get<Texture2D>("Textures/Clouds");
441 for (int i = 0; i < 8; i++) {
442 m_moonTextures[i] = ContentManager.Get<Texture2D>($"Textures/Moon{(i + 1).ToString(CultureInfo.InvariantCulture)}");
443 }
447 Display.DeviceReset += Display_DeviceReset;
448 }
449
462
463 public override void Dispose() {
464 Display.DeviceReset -= Display_DeviceReset;
465 Utilities.Dispose(ref m_starsVertexBuffer);
466 Utilities.Dispose(ref m_starsIndexBuffer);
467 foreach (SkyDome value in m_skyDomes.Values) {
468 value.Dispose();
469 }
470 m_skyDomes.Clear();
471 }
472
473 public virtual void Display_DeviceReset() {
474 Utilities.Dispose(ref m_starsVertexBuffer);
475 Utilities.Dispose(ref m_starsIndexBuffer);
476 foreach (SkyDome value in m_skyDomes.Values) {
477 value.Dispose();
478 }
479 m_skyDomes.Clear();
480 }
481
482 public virtual void DrawSkydome(Camera camera) {
483 if (!m_skyDomes.TryGetValue(camera.GameWidget, out SkyDome value)) {
484 value = new SkyDome();
485 m_skyDomes.Add(camera.GameWidget, value);
486 }
487 if (value.VertexBuffer == null
488 || value.IndexBuffer == null) {
489 Utilities.Dispose(ref value.VertexBuffer);
490 Utilities.Dispose(ref value.IndexBuffer);
491 value.VertexBuffer = new VertexBuffer(m_skyVertexDeclaration, value.Vertices.Length);
492 value.IndexBuffer = new IndexBuffer(IndexFormat.SixteenBits, value.Indices.Length);
493 FillSkyIndexBuffer(value);
494 value.LastUpdateTimeOfDay = null;
495 }
496 int x = Terrain.ToCell(camera.ViewPosition.X);
497 int z = Terrain.ToCell(camera.ViewPosition.Z);
498 float precipitationIntensity = m_subsystemWeather.PrecipitationIntensity;
499 float timeOfDay = m_subsystemTimeOfDay.TimeOfDay;
500 int seasonalTemperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(x, z);
501 bool flag = true;
502 if (value.LastUpdateTimeOfDay.HasValue
503 && !(MathF.Abs(timeOfDay - value.LastUpdateTimeOfDay.Value) > 0.0005f)
504 && value.LastUpdatePrecipitationIntensity.HasValue
505 && !(MathF.Abs(precipitationIntensity - value.LastUpdatePrecipitationIntensity.Value) > 0.02f)
506 && ((precipitationIntensity != 0f && precipitationIntensity != 1f)
507 || value.LastUpdatePrecipitationIntensity.Value == precipitationIntensity)
508 && m_lightningStrikeBrightness == value.LastUpdateLightningStrikeBrightness
509 && value.LastUpdateTemperature.HasValue) {
510 int? lastUpdateTemperature = value.LastUpdateTemperature;
511 if (seasonalTemperature == lastUpdateTemperature.GetValueOrDefault()
512 && lastUpdateTemperature.HasValue
513 && value.LastUpdateTemperature.HasValue
514 && !(MathF.Abs(m_viewFogDensity - (value.LastUpdateFogDensity ?? 0f)) > 0.002f)) {
515 flag = false;
516 }
517 }
518 if (flag) {
519 value.LastUpdateTimeOfDay = timeOfDay;
520 value.LastUpdatePrecipitationIntensity = precipitationIntensity;
521 value.LastUpdateLightningStrikeBrightness = m_lightningStrikeBrightness;
522 value.LastUpdateTemperature = seasonalTemperature;
523 value.LastUpdateFogDensity = m_viewFogDensity;
524 FillSkyVertexBuffer(value, timeOfDay, precipitationIntensity, seasonalTemperature);
525 }
526 Display.DepthStencilState = DepthStencilState.DepthRead;
527 Display.RasterizerState = RasterizerState.CullNoneScissor;
528 float num = CalculateSkyFog(camera.ViewPosition);
529 Display.BlendState = BlendState.Opaque;
530 m_shaderFlat.Transforms.World[0] = Matrix.CreateTranslation(camera.ViewPosition) * camera.ViewProjectionMatrix;
531 m_shaderFlat.Color = new Vector4(1f - num);
532 m_shaderFlat.AdditiveColor = num * new Vector4(ViewFogColor);
533 Display.DrawIndexed(PrimitiveType.TriangleList, m_shaderFlat, value.VertexBuffer, value.IndexBuffer, 0, value.IndexBuffer.IndicesCount);
534 }
535
536 public virtual void DrawStars(Camera camera) {
537 float precipitationIntensity = m_subsystemWeather.PrecipitationIntensity;
538 float timeOfDay = m_subsystemTimeOfDay.TimeOfDay;
539 if (m_starsVertexBuffer == null
540 || m_starsIndexBuffer == null) {
541 Utilities.Dispose(ref m_starsVertexBuffer);
542 Utilities.Dispose(ref m_starsIndexBuffer);
546 }
547 Display.DepthStencilState = DepthStencilState.DepthRead;
548 Display.RasterizerState = RasterizerState.CullNoneScissor;
549 float num = MathUtils.Sqr((1f - CalculateLightIntensity(timeOfDay)) * (1f - precipitationIntensity));
550 num *= 1f - CalculateSkyFog(camera.ViewPosition);
551 if (num > 0.01f) {
552 Display.BlendState = BlendState.Additive;
553 m_shaderTextured.Transforms.World[0] = Matrix.CreateRotationZ(-2f * timeOfDay * (float)Math.PI)
556 * camera.ViewProjectionMatrix;
557 m_shaderTextured.Color = new Vector4(1f, 1f, 1f, num);
558 m_shaderTextured.Texture = ContentManager.Get<Texture2D>("Textures/Star");
559 m_shaderTextured.SamplerState = SamplerState.LinearClamp;
561 PrimitiveType.TriangleList,
565 0,
566 m_starsIndexBuffer.IndicesCount
567 );
568 }
569 }
570
571 public virtual void DrawSunAndMoon(Camera camera) {
572 float precipitationIntensity = m_subsystemWeather.PrecipitationIntensity;
573 float timeOfDay = m_subsystemTimeOfDay.TimeOfDay;
574 float f = MathUtils.Max(CalculateDawnGlowIntensity(timeOfDay), CalculateDuskGlowIntensity(timeOfDay));
575 float num = (float)Math.PI * 2f * (timeOfDay - m_subsystemTimeOfDay.Midday);
576 float angle = num + (float)Math.PI;
577 float num2 = MathUtils.Lerp(90f, 160f, f);
578 float num3 = MathUtils.Lerp(60f, 80f, f);
579 Color color = Color.Lerp(new Color(255, 255, 255), new Color(255, 255, 160), f);
580 Color white = Color.White;
581 white *= 1f - SkyLightIntensity;
582 color *= MathUtils.Lerp(1f, 0f, precipitationIntensity);
583 white *= MathUtils.Lerp(1f, 0f, precipitationIntensity);
584 Color color2 = color * 0.6f * MathUtils.Lerp(1f, 0f, precipitationIntensity);
585 Color color3 = color * 0.2f * MathUtils.Lerp(1f, 0f, precipitationIntensity);
586 TexturedBatch3D batch = m_primitivesRenderer3d.TexturedBatch(
588 false,
589 0,
591 null,
593 );
594 TexturedBatch3D batch2 = m_primitivesRenderer3d.TexturedBatch(
596 false,
597 1,
599 null,
601 );
602 TexturedBatch3D batch3 = m_primitivesRenderer3d.TexturedBatch(
604 false,
605 1,
607 null,
609 );
610 QueueCelestialBody(batch, camera.ViewPosition, color2, 900f, 3.5f * num2, num);
611 QueueCelestialBody(batch, camera.ViewPosition, color3, 900f, 3.5f * num3, angle);
612 QueueCelestialBody(batch2, camera.ViewPosition, color, 900f, num2, num);
613 QueueCelestialBody(batch3, camera.ViewPosition, white, 900f, num3, angle);
614 }
615
616 public virtual void DrawLightning(Camera camera) {
617 if (!m_lightningStrikePosition.HasValue) {
618 return;
619 }
621 Color color0 = (1f - CalculateSkyFog(camera.ViewPosition)) * Color.White;
623 Vector3 unitY = Vector3.UnitY;
625 Viewport viewport = Display.Viewport;
626 float num = Vector4.Transform(new Vector4(value, 1f), camera.ViewProjectionMatrix).W
627 * 2f
628 / (viewport.Width * camera.ProjectionMatrix.M11);
629 for (int i = 0; i < (int)(m_lightningStrikeBrightness * 30f); i++) {
630 float s = m_random.NormalFloat(0f, 1f * num);
631 float s2 = m_random.NormalFloat(0f, 1f * num);
632 Vector3 v2 = s * v + s2 * unitY;
633 float num2 = 260f;
634 while (num2 > value.Y) {
635 uint num3 = MathUtils.Hash((uint)(m_lightningStrikePosition.Value.X + 100f * m_lightningStrikePosition.Value.Z + 200f * num2));
636 float num4 = MathUtils.Lerp(4f, 10f, (float)(double)(num3 & 0xFF) / 255f);
637 float s3 = (num3 & 1) == 0 ? 1 : -1;
638 float s4 = MathUtils.Lerp(0.05f, 0.2f, (float)(double)((num3 >> 8) & 0xFF) / 255f);
639 float num5 = num2;
640 float num6 = num5 - num4 * MathUtils.Lerp(0.45f, 0.55f, ((num3 >> 16) & 0xFF) / 255f);
641 float num7 = num5 - num4 * MathUtils.Lerp(0.45f, 0.55f, ((num3 >> 24) & 0xFF) / 255f);
642 float num8 = num5 - num4;
643 Vector3 p = new Vector3(value.X, num5, value.Z) + v2;
644 Vector3 vector = new Vector3(value.X, num6, value.Z) + v2 - num4 * v * s3 * s4;
645 Vector3 vector2 = new Vector3(value.X, num7, value.Z) + v2 + num4 * v * s3 * s4;
646 Vector3 p2 = new Vector3(value.X, num8, value.Z) + v2;
647 Color color = color0 * 0.2f * MathUtils.Saturate((260f - num5) * 0.2f);
648 Color color2 = color0 * 0.2f * MathUtils.Saturate((260f - num6) * 0.2f);
649 Color color3 = color0 * 0.2f * MathUtils.Saturate((260f - num7) * 0.2f);
650 Color color4 = color0 * 0.2f * MathUtils.Saturate((260f - num8) * 0.2f);
651 flatBatch3D.QueueLine(p, vector, color, color2);
652 flatBatch3D.QueueLine(vector, vector2, color2, color3);
653 flatBatch3D.QueueLine(vector2, p2, color3, color4);
654 num2 -= num4;
655 }
656 }
657 float num9 = MathUtils.Lerp(
658 0.3f,
659 0.75f,
660 0.5f * (float)Math.Sin(MathUtils.Remainder(1.0 * m_subsystemTime.GameTime, 6.2831854820251465)) + 0.5f
661 );
662 m_lightningStrikeBrightness -= m_subsystemTime.GameTimeDelta / num9;
663 if (m_lightningStrikeBrightness <= 0f) {
666 }
667 }
668
669 public virtual void DrawClouds(Camera camera) {
671 return;
672 }
673 float f = CalculateHazeFactor();
674 float num = MathUtils.Lerp(0.03f, 1f, MathUtils.Sqr(SkyLightIntensity)) * MathUtils.Lerp(1f, 0.2f, f);
675 float f2 = CalculateSkyFog(camera.ViewPosition);
676 m_cloudsLayerColors[0] = Color.Lerp(Color.White * (num * 0.75f), ViewFogColor, f2);
677 m_cloudsLayerColors[1] = Color.Lerp(Color.White * (num * 0.66f), ViewFogColor, f2);
680 double gameTime = m_subsystemTime.GameTime;
681 Vector3 viewPosition = camera.ViewPosition;
682 Vector2 v = new(
683 (float)MathUtils.Remainder(0.002 * gameTime - viewPosition.X / 1900f * 1.75f, 1.0) + viewPosition.X / 1900f * 1.75f,
684 (float)MathUtils.Remainder(0.002 * gameTime - viewPosition.Z / 1900f * 1.75f, 1.0) + viewPosition.Z / 1900f * 1.75f
685 );
686 TexturedBatch3D texturedBatch3D = m_primitivesRenderer3d.TexturedBatch(
688 false,
689 2,
691 null,
694 );
695 DynamicArray<VertexPositionColorTexture> triangleVertices = texturedBatch3D.TriangleVertices;
696 DynamicArray<int> triangleIndices = texturedBatch3D.TriangleIndices;
697 int count = triangleVertices.Count;
698 int count2 = triangleVertices.Count;
699 int count3 = triangleIndices.Count;
700 triangleVertices.Count += 49;
701 triangleIndices.Count += 216;
702 for (int i = 0; i < 7; i++) {
703 for (int j = 0; j < 7; j++) {
704 int num2 = j - 3;
705 int num3 = i - 3;
706 int num4 = MathUtils.Max(Math.Abs(num2), Math.Abs(num3));
707 float num5 = m_cloudsLayerRadii[num4];
708 float num6 = num4 > 0 ? num5 / MathF.Sqrt(num2 * num2 + num3 * num3) : 0f;
709 float num7 = num2 * num6;
710 float num8 = num3 * num6;
711 float y = MathUtils.Lerp(600f, 60f, num5 * num5);
712 Vector3 position = new(viewPosition.X + num7 * 1900f, y, viewPosition.Z + num8 * 1900f);
713 Vector2 texCoord = new Vector2(position.X, position.Z) / 1900f * 1.75f - v;
714 Color color = m_cloudsLayerColors[num4];
715 texturedBatch3D.TriangleVertices.Array[count2++] = new VertexPositionColorTexture(position, color, texCoord);
716 if (j > 0
717 && i > 0) {
718 int num9 = count + j + i * 7;
719 int num10 = count + (j - 1) + i * 7;
720 int num11 = count + (j - 1) + (i - 1) * 7;
721 int num12 = count + j + (i - 1) * 7;
722 if ((num2 <= 0 && num3 <= 0)
723 || (num2 > 0 && num3 > 0)) {
724 texturedBatch3D.TriangleIndices.Array[count3++] = num9;
725 texturedBatch3D.TriangleIndices.Array[count3++] = num10;
726 texturedBatch3D.TriangleIndices.Array[count3++] = num11;
727 texturedBatch3D.TriangleIndices.Array[count3++] = num11;
728 texturedBatch3D.TriangleIndices.Array[count3++] = num12;
729 texturedBatch3D.TriangleIndices.Array[count3++] = num9;
730 }
731 else {
732 texturedBatch3D.TriangleIndices.Array[count3++] = num9;
733 texturedBatch3D.TriangleIndices.Array[count3++] = num10;
734 texturedBatch3D.TriangleIndices.Array[count3++] = num12;
735 texturedBatch3D.TriangleIndices.Array[count3++] = num10;
736 texturedBatch3D.TriangleIndices.Array[count3++] = num11;
737 texturedBatch3D.TriangleIndices.Array[count3++] = num12;
738 }
739 }
740 }
741 }
743 }
744
745 public virtual void QueueCelestialBody(TexturedBatch3D batch, Vector3 viewPosition, Color color, float distance, float radius, float angle) {
746 color *= 1f - CalculateSkyFog(viewPosition);
747 if (color.A > 0) {
749 m *= Matrix.CreateTranslation(0f, distance, 0f);
750 m *= Matrix.CreateRotationZ(0f - angle);
752 m *= Matrix.CreateTranslation(viewPosition);
753 Vector3 v = new(0f - radius, 0f, 0f - radius);
754 Vector3 v2 = new(radius, 0f, 0f - radius);
755 Vector3 v3 = new(radius, 0f, radius);
756 Vector3 v4 = new(0f - radius, 0f, radius);
757 Vector3.Transform(ref v, ref m, out v);
758 Vector3.Transform(ref v2, ref m, out v2);
759 Vector3.Transform(ref v3, ref m, out v3);
760 Vector3.Transform(ref v4, ref m, out v4);
761 batch.QueueQuad(
762 v,
763 v2,
764 v3,
765 v4,
766 new Vector2(1f, 0f),
767 new Vector2(1f, 1f),
768 new Vector2(0f, 1f),
769 new Vector2(0f, 0f),
770 color
771 );
772 }
773 }
774
782
783 public virtual void UpdateMoonPhase() {
784 MoonPhase = ((int)Math.Floor(m_subsystemTimeOfDay.Day - 0.5 + 5.0) % 8 + 8) % 8;
785 }
786
787 public delegate float CalculateLightIntensityDelegate(float timeOfDay);
788
790
791 public delegate float CalculateSeasonAngleDelegate();
792
794
795 public delegate float CalculateHazeFactorDelegate();
796
798
799 public delegate Color CalculateSkyColorDelegate(Vector3 direction, int temperature);
800
802
803 public delegate float CalculateSkyFogDelegate(Vector3 viewPosition);
804
806
808
809 public virtual void FillSkyVertexBuffer(SkyDome skyDome, float timeOfDay, float precipitationIntensity, int temperature) {
810 for (int i = 0; i < 8; i++) {
811 float x = (float)Math.PI / 2f * MathUtils.Sqr(i / 7f);
812 for (int j = 0; j < 16; j++) {
813 int num = j + i * 16;
814 float x2 = (float)Math.PI * 2f * j / 16f;
815 float num2 = 1800f * MathF.Cos(x);
816 skyDome.Vertices[num].Position.X = num2 * MathF.Sin(x2);
817 skyDome.Vertices[num].Position.Z = num2 * MathF.Cos(x2);
818 skyDome.Vertices[num].Position.Y = 1800f * MathF.Sin(x) - (i == 0 ? 450f : 0f);
819 skyDome.Vertices[num].Color = CalculateSkyColor(skyDome.Vertices[num].Position, temperature);
820 }
821 }
822 skyDome.VertexBuffer.SetData(skyDome.Vertices, 0, skyDome.Vertices.Length);
823 }
824
825 public virtual void FillSkyIndexBuffer(SkyDome skyDome) {
826 int num = 0;
827 for (int i = 0; i < 7; i++) {
828 for (int j = 0; j < 16; j++) {
829 int num2 = j;
830 int num3 = (j + 1) % 16;
831 int num4 = i;
832 int num5 = i + 1;
833 skyDome.Indices[num++] = (ushort)(num2 + num4 * 16);
834 skyDome.Indices[num++] = (ushort)(num3 + num4 * 16);
835 skyDome.Indices[num++] = (ushort)(num3 + num5 * 16);
836 skyDome.Indices[num++] = (ushort)(num3 + num5 * 16);
837 skyDome.Indices[num++] = (ushort)(num2 + num5 * 16);
838 skyDome.Indices[num++] = (ushort)(num2 + num4 * 16);
839 }
840 }
841 for (int k = 2; k < 16; k++) {
842 skyDome.Indices[num++] = 0;
843 skyDome.Indices[num++] = (ushort)(k - 1);
844 skyDome.Indices[num++] = (ushort)k;
845 }
846 skyDome.IndexBuffer.SetData(skyDome.Indices, 0, skyDome.Indices.Length);
847 }
848
849 public virtual void FillStarsBuffers() {
850 Random random = new(10);
851 StarVertex[] array = new StarVertex[m_starsCount * 4];
852 for (int i = 0; i < m_starsCount; i++) {
853 float x;
854 Color c;
855 Vector3 v;
856 switch (i) {
857 case 0:
858 x = 1.05f;
859 c = new Color(1f, 1f, 1f);
860 v = new Vector3(0f, 0f, 1f);
861 break;
862 case 1:
863 x = 0.91f;
864 c = new Color(1f, 0.8f, 0.6f);
865 v = new Vector3(-0.007f, -0.05f, 1f);
866 break;
867 case 2:
868 x = 0.94f;
869 c = new Color(1f, 0.8f, 0.7f);
870 v = new Vector3(0f, -0.11f, 1f);
871 break;
872 default:
873 x = random.Float(0.7f, 1f);
874 c = new Color(random.Float(0.8f, 1f), 0.8f, random.Float(0.8f, 1f));
875 do {
876 v = new Vector3(random.Float(-1f, 1f), random.Float(-1f, 1f), random.Float(-1f, 1f));
877 }
878 while (v.LengthSquared() > 1f);
879 break;
880 }
881 float num = 7.65f * MathF.Pow(x, 3f);
882 float s = MathF.Pow(x, 4f);
883 c = Color.MultiplyAlphaOnly(c, s);
884 v = Vector3.Normalize(v);
885 Vector3 v2 = 900f * v;
887 Vector3 v3 = Vector3.Normalize(Vector3.Cross(vector, v));
888 Vector3 position = v2 + num * (-vector - v3);
889 Vector3 position2 = v2 + num * (vector - v3);
890 Vector3 position3 = v2 + num * (vector + v3);
891 Vector3 position4 = v2 + num * (-vector + v3);
892 array[i * 4] = new StarVertex { Position = position, TextureCoordinate = new Vector2(0f, 0f), Color = c };
893 array[i * 4 + 1] = new StarVertex { Position = position2, TextureCoordinate = new Vector2(1f, 0f), Color = c };
894 array[i * 4 + 2] = new StarVertex { Position = position3, TextureCoordinate = new Vector2(1f, 1f), Color = c };
895 array[i * 4 + 3] = new StarVertex { Position = position4, TextureCoordinate = new Vector2(0f, 1f), Color = c };
896 }
897 m_starsVertexBuffer.SetData(array, 0, array.Length);
898 ushort[] array2 = new ushort[m_starsCount * 6];
899 for (int j = 0; j < m_starsCount; j++) {
900 array2[j * 6] = (ushort)(j * 4);
901 array2[j * 6 + 1] = (ushort)(j * 4 + 1);
902 array2[j * 6 + 2] = (ushort)(j * 4 + 2);
903 array2[j * 6 + 3] = (ushort)(j * 4 + 2);
904 array2[j * 6 + 4] = (ushort)(j * 4 + 3);
905 array2[j * 6 + 5] = (ushort)(j * 4);
906 }
907 m_starsIndexBuffer.SetData(array2, 0, array2.Length);
908 }
909
910 public delegate float CalculateDawnGlowIntensityDelegate(float timeOfDay);
911
913
914 public delegate float CalculateDuskGlowIntensityDelegate(float timeOfDay);
915
917
918 public delegate float CalculateWinterDistanceDelegate();
919
921
922 #region CalculationSurvivalcraft
923
924 public virtual float CalculateFogSurvivalcraft(Vector3 viewPosition, Vector3 position) {
925 Vector3 vector = viewPosition - position;
926 vector.Y *= VisibilityRangeYMultiplier;
927 float num = vector.Length();
928 float num2 = (FogIntegral(viewPosition.Y) - FogIntegral(position.Y)) / (viewPosition.Y - position.Y);
929 float num3 = MathUtils.Saturate(ViewHazeDensity * (num - ViewHazeStart));
930 float num4 = num2 * ViewFogDensity * num;
931 return MathUtils.Saturate(num3 + num4);
932 }
933
934 public virtual float CalculateFogNoHazeSurvivalcraft(Vector3 viewPosition, Vector3 position) {
935 Vector3 vector = viewPosition - position;
936 vector.Y *= VisibilityRangeYMultiplier;
937 float num = vector.Length();
938 return MathUtils.Saturate((FogIntegral(viewPosition.Y) - FogIntegral(position.Y)) / (viewPosition.Y - position.Y) * ViewFogDensity * num);
939 }
940
941 public virtual float CalculateLightIntensitySurvivalcraft(float timeOfDay) {
942 if (IntervalUtils.IsBetween(timeOfDay, m_subsystemTimeOfDay.NightStart, m_subsystemTimeOfDay.DawnStart)) {
943 return 0f;
944 }
945 if (IntervalUtils.IsBetween(timeOfDay, m_subsystemTimeOfDay.DawnStart, m_subsystemTimeOfDay.DayStart)) {
946 return IntervalUtils.Interval(m_subsystemTimeOfDay.DawnStart, timeOfDay) / m_subsystemTimeOfDay.DawnInterval;
947 }
948 if (IntervalUtils.IsBetween(timeOfDay, m_subsystemTimeOfDay.DayStart, m_subsystemTimeOfDay.DuskStart)) {
949 return 1f;
950 }
951 return 1f - IntervalUtils.Interval(m_subsystemTimeOfDay.DuskStart, timeOfDay) / m_subsystemTimeOfDay.DuskInterval;
952 }
953
954 public virtual float CalculateSeasonAngleSurvivalcraft() => -0.4f
955 - 0.7f * (0.5f - 0.5f * MathF.Cos((m_subsystemGameInfo.WorldSettings.TimeOfYear - SubsystemSeasons.MidSummer) * 2f * MathF.PI));
956
957 public virtual float CalculateHazeFactorSurvivalcraft() =>
958 MathUtils.Saturate(m_subsystemWeather.PrecipitationIntensity + 30f * m_viewFogDensity);
959
960 public virtual Color CalculateSkyColorSurvivalcraft(Vector3 direction, int temperature) {
961 float timeOfDay = m_subsystemTimeOfDay.TimeOfDay;
962 float f = CalculateHazeFactor();
963 direction = Vector3.Normalize(direction);
964 Vector2 vector = Vector2.Normalize(new Vector2(direction.X, direction.Z));
965 float num = CalculateLightIntensity(timeOfDay);
966 float f2 = MathUtils.Saturate(temperature / 15f);
967 Vector3 v = new(0.65f, 0.68f, 0.7f);
968 Vector3 v2 = Vector3.Lerp(new Vector3(0.33f, 0.39f, 0.46f), new Vector3(0.15f, 0.3f, 0.56f), f2);
969 Vector3 v3 = Vector3.Lerp(new Vector3(0.79f, 0.83f, 0.88f), new Vector3(0.64f, 0.77f, 0.91f), f2);
970 Vector3 v4 = Vector3.Lerp(v2, v, f) * num;
971 Vector3 vector2 = Vector3.Lerp(v3, v, f) * num;
972 Vector3 vector3 = new(1f, 0.3f, -0.2f);
973 Vector3 vector4 = new(1f, 0.3f, -0.2f);
974 if (m_lightningStrikePosition.HasValue) {
976 }
977 float num2 = MathUtils.Lerp(CalculateDawnGlowIntensity(timeOfDay), 0f, f);
978 float num3 = MathUtils.Lerp(CalculateDuskGlowIntensity(timeOfDay), 0f, f);
979 float f3 = MathUtils.Saturate((direction.Y - 0.1f) / 0.4f);
980 float num4 = num2 * MathUtils.Sqr(MathUtils.Saturate(0f - vector.X));
981 float num5 = num3 * MathUtils.Sqr(MathUtils.Saturate(vector.X));
982 Color color = new(Vector3.Lerp(vector2 + vector3 * num4 + vector4 * num5, v4, f3));
984 "ChangeSkyColor",
985 loader => {
986 color = loader.ChangeSkyColor(color, direction, timeOfDay, temperature);
987 return true;
988 }
989 );
990 return color;
991 }
992
993 public virtual float CalculateSkyFogSurvivalcraft(Vector3 viewPosition) =>
994 CalculateFogNoHaze(viewPosition, viewPosition + new Vector3(1000f, 150f, 0f));
995
996 public virtual float CalculateDawnGlowIntensitySurvivalcraft(float timeOfDay) {
997 float num = MathUtils.Lerp(0.1f, 0.75f, MathUtils.LinearStep(-0.05f, 0.15f, CalculateWinterDistance()));
998 float middawn = m_subsystemTimeOfDay.Middawn;
999 float num2 = 1f * m_subsystemTimeOfDay.DawnInterval;
1000 return num * MathUtils.Max(1f - IntervalUtils.Distance(timeOfDay, middawn) / num2 * 2f, 0f);
1001 }
1002
1003 public virtual float CalculateDuskGlowIntensitySurvivalcraft(float timeOfDay) {
1004 float num = MathUtils.Lerp(0.2f, 1f, MathUtils.LinearStep(-0.05f, 0.15f, CalculateWinterDistance()));
1005 float middusk = m_subsystemTimeOfDay.Middusk;
1006 float num2 = 1f * m_subsystemTimeOfDay.DuskInterval;
1007 return num * MathUtils.Max(1f - IntervalUtils.Distance(timeOfDay, middusk) / num2 * 2f, 0f);
1008 }
1009
1015
1016 #endregion
1017 }
1018}
Engine.Color Color
Engine.Vector3 Vector3
readonly DynamicArray< VertexPositionColor > TriangleVertices
void TransformTriangles(Matrix matrix, int start=0, int end=-1)
readonly DynamicArray< int > TriangleIndices
readonly DynamicArray< VertexPositionColorTexture > TriangleVertices
static readonly BlendState Opaque
static readonly BlendState Additive
static readonly BlendState AlphaBlend
static readonly DepthStencilState None
static readonly DepthStencilState DepthRead
static Viewport Viewport
static void DrawIndexed(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, IndexBuffer indexBuffer, int startIndex, int indicesCount)
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Color color)
void QueueLine(Vector3 p1, Vector3 p2, Color color)
static readonly RasterizerState CullNoneScissor
void QueueQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector2 texCoord1, Vector2 texCoord2, Vector2 texCoord3, Vector2 texCoord4, Color color)
static float Remainder(float x, float y)
static float SmoothStep(float min, float max, float x)
static int Hash(int key)
static float Saturate(float x)
static int Max(int x1, int x2)
static int Sqr(int x)
static float Lerp(float x1, float x2, float f)
static float LinearStep(float zero, float one, float f)
Color Lookup(int temperature, int humidity)
static BlockColorsMap Water
virtual BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
Vector3 ViewPosition
GameWidget GameWidget
Matrix ViewportMatrix
Vector3 ViewDirection
Matrix ProjectionMatrix
Matrix ViewProjectionMatrix
Vector2 ViewportSize
static object Get(Type type, string name)
static bool IsBetween(float t, float t1, float t2)
static float Interval(float t1, float t2)
static float Midpoint(float t1, float t2, float factor=0.5f)
static float Distance(float t1, float t2)
float Float()
static SkyRenderingMode SkyRenderingMode
CalculateSkyColorDelegate CalculateSkyColor
SubsystemWeather m_subsystemWeather
SubsystemTimeOfDay m_subsystemTimeOfDay
virtual float VisibilityRange
virtual float CalculateFogSurvivalcraft(Vector3 viewPosition, Vector3 position)
virtual float CalculateSkyFogSurvivalcraft(Vector3 viewPosition)
SubsystemTerrain m_subsystemTerrain
SubsystemBodies m_subsystemBodies
virtual Color ViewFogColor
delegate float CalculateSkyFogDelegate(Vector3 viewPosition)
virtual void FillSkyIndexBuffer(SkyDome skyDome)
virtual void MakeLightningStrike(Vector3 targetPosition, bool manual)
VertexDeclaration m_skyVertexDeclaration
CalculateSeasonAngleDelegate CalculateSeasonAngle
virtual float CalculateHazeFactorSurvivalcraft()
static SkyShader Shader
virtual void DrawClouds(Camera camera)
SubsystemGameInfo m_subsystemGameInfo
static UnlitShader m_shaderTextured
virtual void DrawSkydome(Camera camera)
virtual float CalculateLightIntensitySurvivalcraft(float timeOfDay)
virtual void DrawStars(Camera camera)
CalculateLightIntensityDelegate CalculateLightIntensity
delegate float CalculateHazeFactorDelegate()
SubsystemSeasons m_subsystemSeasons
PrimitivesRenderer2D m_primitivesRenderer2d
delegate float CalculateFogNoHazeDelegate(Vector3 viewPosition, Vector3 position)
virtual void Draw(Camera camera, int drawOrder)
IndexBuffer m_starsIndexBuffer
virtual float VisibilityRangeYMultiplier
virtual float CalculateFogNoHazeSurvivalcraft(Vector3 viewPosition, Vector3 position)
virtual float ViewHazeDensity
virtual void InitializeCalculation()
virtual float FogIntegral(float y)
CalculateSkyFogDelegate CalculateSkyFog
virtual void UpdateMoonPhase()
virtual void UpdateLightAndViewParameters()
virtual Color CalculateSkyColorSurvivalcraft(Vector3 direction, int temperature)
delegate float CalculateDawnGlowIntensityDelegate(float timeOfDay)
virtual float CalculateDuskGlowIntensitySurvivalcraft(float timeOfDay)
static UnlitShader m_shaderFlat
virtual float ViewUnderWaterDepth
virtual void Update(float dt)
virtual void Display_DeviceReset()
static bool DrawGalaxyEnabled
virtual void QueueCelestialBody(TexturedBatch3D batch, Vector3 viewPosition, Color color, float distance, float radius, float angle)
CalculateDuskGlowIntensityDelegate CalculateDuskGlowIntensity
SkyPrimitiveRender m_primitiveRender
CalculateWinterDistanceDelegate CalculateWinterDistance
override void Load(ValuesDictionary valuesDictionary)
SubsystemTime m_subsystemTime
static int[] m_lightValuesMoonless
virtual float CalculateWinterDistanceSurvivalcraft()
virtual void DrawSunAndMoon(Camera camera)
delegate float CalculateSeasonAngleDelegate()
PrimitivesRenderer3D m_primitivesRenderer3d
virtual void FillSkyVertexBuffer(SkyDome skyDome, float timeOfDay, float precipitationIntensity, int temperature)
VertexBuffer m_starsVertexBuffer
virtual float SkyLightIntensity
CalculateFogDelegate CalculateFog
virtual float ViewUnderMagmaDepth
delegate float CalculateLightIntensityDelegate(float timeOfDay)
virtual float ViewFogDensity
SubsystemParticles m_subsystemParticles
delegate float CalculateFogDelegate(Vector3 viewPosition, Vector3 position)
CalculateHazeFactorDelegate CalculateHazeFactor
virtual void DrawLightning(Camera camera)
CalculateFogNoHazeDelegate CalculateFogNoHaze
SubsystemAudio m_subsystemAudio
virtual void FillStarsBuffers()
virtual float ViewHazeStart
SubsystemFluidBlockBehavior m_subsystemFluidBlockBehavior
virtual float CalculateDawnGlowIntensitySurvivalcraft(float timeOfDay)
delegate float CalculateWinterDistanceDelegate()
virtual float ViewFogBottom
CalculateDawnGlowIntensityDelegate CalculateDawnGlowIntensity
Dictionary< GameWidget, SkyDome > m_skyDomes
override void Dispose()
delegate Color CalculateSkyColorDelegate(Vector3 direction, int temperature)
virtual float CalculateSeasonAngleSurvivalcraft()
VertexDeclaration m_starsVertexDeclaration
delegate float CalculateDuskGlowIntensityDelegate(float timeOfDay)
static SkyShader ShaderAlphaTest
static int[] m_lightValuesNormal
static Func< int, int > GetTemperatureAdjustmentAtHeight
static int ExtractContents(int value)
static int ToCell(float x)
Component FindComponent(Type type, string name, bool throwOnError)
ValuesDictionary ValuesDictionary
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static Color MultiplyAlphaOnly(Color c, float s)
static Color Lerp(Color c1, Color c2, float f)
static Color Transparent
定义 Color.cs:5
static Color White
static Color MultiplyColorOnly(Color c, float s)
static Matrix CreateRotationX(float radians)
static Matrix CreateTranslation(float x, float y, float z)
static Matrix CreateRotationZ(float radians)
static readonly Matrix Identity
static readonly Vector2 Zero
static Vector2 Normalize(Vector2 v)
static float Distance(Vector2 v1, Vector2 v2)
static Vector3 Lerp(Vector3 v1, Vector3 v2, float f)
static Vector3 Transform(Vector3 v, Matrix m)
static Vector3 Cross(Vector3 v1, Vector3 v2)
static Vector3 Normalize(Vector3 v)
static Vector3 Max(Vector3 v, float f)
float LengthSquared()
static readonly Vector3 UnitX
static readonly Vector3 UnitY
static Vector4 Transform(Vector4 v, Matrix m)