1using System.Globalization;
32 public ushort[]
Indices =
new ushort[714];
190 float explosionPressure =
m_random.Float(0f, 1f) < 0.2f ? 39 : 19;
192 bool setBodyOnFire =
true;
196 loader.OnLightningStrike(
this, ref targetPosition, ref strike, ref explosionPressure, ref setBodyOnFire);
207 float num =
float.MaxValue;
218 else if (num < 200f) {
224 DynamicArray<ComponentBody> dynamicArray = [];
226 for (
int i = 0; i < dynamicArray.
Count; i++) {
229 && componentBody.
Position.
Y > targetPosition.Y - 1.5f
232 new Vector2(targetPosition.X, targetPosition.Z)
238 if (componentCreature !=
null
248 for (
int j = -1; j <= 1; j++) {
249 for (
int k = -1; k <= 1; k++) {
250 for (
int l = -1; l <= 1; l++) {
259 float pressure =
m_random.Bool(0.2f) ? 39 : 19;
294 if (surfaceHeight.HasValue) {
306 float num =
MathUtils.
Lerp(1f, 0.5f, seasonalHumidity / 15f);
331 float x2 = Math.Clamp(num4 +
m_fogSeedRandom.Float(-20f, 20f), 62f, 180f);
351 Color c2 = 0.25f * color + 0.25f * color2 + 0.25f * color3 + 0.25f * color4;
401 loader.SkyDrawExtra(
this, camera);
409 m_primitiveRender.Shader =
Shader;
411 m_primitiveRender.Camera = camera;
441 for (
int i = 0; i < 8; i++) {
487 if (value.VertexBuffer ==
null
488 || value.IndexBuffer ==
null) {
489 Utilities.Dispose(ref value.VertexBuffer);
490 Utilities.Dispose(ref value.IndexBuffer);
494 value.LastUpdateTimeOfDay =
null;
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)
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)) {
519 value.LastUpdateTimeOfDay = timeOfDay;
520 value.LastUpdatePrecipitationIntensity = precipitationIntensity;
522 value.LastUpdateTemperature = seasonalTemperature;
531 m_shaderFlat.Color =
new Vector4(1f - num);
557 m_shaderTextured.Color =
new Vector4(1f, 1f, 1f, num);
576 float angle = num + (float)Math.PI;
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;
634 while (num2 > value.
Y) {
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);
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;
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;
651 flatBatch3D.
QueueLine(p, vector, color, color2);
652 flatBatch3D.
QueueLine(vector, vector2, color2, color3);
653 flatBatch3D.
QueueLine(vector2, p2, color3, color4);
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
695 DynamicArray<VertexPositionColorTexture> triangleVertices = texturedBatch3D.
TriangleVertices;
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++) {
706 int num4 =
MathUtils.
Max(Math.Abs(num2), Math.Abs(num3));
708 float num6 = num4 > 0 ? num5 / MathF.Sqrt(num2 * num2 + num3 * num3) : 0f;
709 float num7 = num2 * num6;
710 float num8 = num3 * num6;
712 Vector3 position =
new(viewPosition.X + num7 * 1900f, y, viewPosition.Z + num8 * 1900f);
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)) {
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);
810 for (
int i = 0; i < 8; i++) {
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);
827 for (
int i = 0; i < 7; i++) {
828 for (
int j = 0; j < 16; j++) {
830 int num3 = (j + 1) % 16;
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);
841 for (
int k = 2; k < 16; k++) {
843 skyDome.
Indices[num++] = (ushort)(k - 1);
844 skyDome.
Indices[num++] = (ushort)k;
859 c =
new Color(1f, 1f, 1f);
864 c =
new Color(1f, 0.8f, 0.6f);
865 v =
new Vector3(-0.007f, -0.05f, 1f);
869 c =
new Color(1f, 0.8f, 0.7f);
870 v =
new Vector3(0f, -0.11f, 1f);
873 x = random.
Float(0.7f, 1f);
881 float num = 7.65f * MathF.Pow(x, 3f);
882 float s = MathF.Pow(x, 4f);
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);
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);
922 #region CalculationSurvivalcraft
925 Vector3 vector = viewPosition - position;
927 float num = vector.
Length();
935 Vector3 vector = viewPosition - position;
937 float num = vector.
Length();
967 Vector3 v =
new(0.65f, 0.68f, 0.7f);
972 Vector3 vector3 =
new(1f, 0.3f, -0.2f);
973 Vector3 vector4 =
new(1f, 0.3f, -0.2f);
982 Color color =
new(
Vector3.
Lerp(vector2 + vector3 * num4 + vector4 * num5, v4, f3));
986 color = loader.ChangeSkyColor(color, direction, timeOfDay, temperature);
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 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
static SamplerState LinearWrap
static SamplerState LinearClamp
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 float Saturate(float x)
static int Max(int x1, int x2)
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)
Matrix ViewProjectionMatrix
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)
static int VisibilityRange
static SkyRenderingMode SkyRenderingMode
int? LastUpdateTemperature
float? LastUpdateFogDensity
float? LastUpdateTimeOfDay
float? LastUpdatePrecipitationIntensity
float LastUpdateLightningStrikeBrightness
VertexBuffer VertexBuffer
CalculateSkyColorDelegate CalculateSkyColor
SubsystemWeather m_subsystemWeather
SubsystemTimeOfDay m_subsystemTimeOfDay
virtual float VisibilityRange
virtual int SkyLightValue
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()
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)
Vector3? m_lightningStrikePosition
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()
Texture2D m_cloudsTexture
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)
Texture2D[] m_moonTextures
virtual float ViewFogDensity
Color[] m_cloudsLayerColors
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
double m_lastLightningStrikeTime
CalculateDawnGlowIntensityDelegate CalculateDawnGlowIntensity
Dictionary< GameWidget, SkyDome > m_skyDomes
delegate Color CalculateSkyColorDelegate(Vector3 direction, int temperature)
virtual float CalculateSeasonAngleSurvivalcraft()
VertexDeclaration m_starsVertexDeclaration
float m_lightningStrikeBrightness
delegate float CalculateDuskGlowIntensityDelegate(float timeOfDay)
static SkyShader ShaderAlphaTest
float[] m_cloudsLayerRadii
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 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)
static readonly Vector3 UnitX
static readonly Vector3 UnitY
static Vector4 Transform(Vector4 v, Matrix m)
Vector2 TextureCoordinate