Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SimulatePressure()

void Terraria.GameContent.Biomes.GraniteBiome.SimulatePressure ( out Rectangle effectedMapArea)
inlineprivate

Definition at line 106 of file GraniteBiome.cs.

107 {
108 //IL_0072: Unknown result type (might be due to invalid IL or missing references)
109 //IL_0077: Unknown result type (might be due to invalid IL or missing references)
110 //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
111 //IL_00a9: Unknown result type (might be due to invalid IL or missing references)
112 //IL_0157: Unknown result type (might be due to invalid IL or missing references)
113 //IL_015b: Unknown result type (might be due to invalid IL or missing references)
114 //IL_015d: Unknown result type (might be due to invalid IL or missing references)
115 //IL_0162: Unknown result type (might be due to invalid IL or missing references)
116 //IL_0167: Unknown result type (might be due to invalid IL or missing references)
117 int length = _sourceMagmaMap.GetLength(0);
118 int length2 = _sourceMagmaMap.GetLength(1);
119 int num = length / 2;
120 int num2 = length2 / 2;
121 int num3 = num;
122 int num4 = num3;
123 int num5 = num2;
124 int num6 = num5;
125 for (int i = 0; i < 300; i++)
126 {
127 for (int j = num3; j <= num4; j++)
128 {
129 for (int k = num5; k <= num6; k++)
130 {
131 Magma magma = _sourceMagmaMap[j, k];
132 if (!magma.IsActive)
133 {
134 continue;
135 }
136 double num7 = 0.0;
137 Vector2D val = Vector2D.Zero;
138 for (int l = -1; l <= 1; l++)
139 {
140 for (int m = -1; m <= 1; m++)
141 {
142 if (l == 0 && m == 0)
143 {
144 continue;
145 }
146 Vector2D val2 = _normalisedVectors[(l + 1) * 3 + (m + 1)];
147 Magma magma2 = _sourceMagmaMap[j + l, k + m];
148 if (magma.Pressure > 0.01 && !magma2.IsActive)
149 {
150 if (l == -1)
151 {
152 num3 = Utils.Clamp(j + l, 1, num3);
153 }
154 else
155 {
156 num4 = Utils.Clamp(j + l, num4, length - 2);
157 }
158 if (m == -1)
159 {
160 num5 = Utils.Clamp(k + m, 1, num5);
161 }
162 else
163 {
164 num6 = Utils.Clamp(k + m, num6, length2 - 2);
165 }
166 _targetMagmaMap[j + l, k + m] = magma2.ToFlow();
167 }
168 double pressure = magma2.Pressure;
169 num7 += pressure;
170 val += pressure * val2;
171 }
172 }
173 num7 /= 8.0;
174 if (num7 > magma.Resistance)
175 {
176 double num8 = ((Vector2D)(ref val)).Length() / 8.0;
177 double val3 = Math.Max(num7 - num8 - magma.Pressure, 0.0) + num8 + magma.Pressure * 0.875 - magma.Resistance;
178 val3 = Math.Max(0.0, val3);
179 _targetMagmaMap[j, k] = Magma.CreateFlow(val3, Math.Max(0.0, magma.Resistance - val3 * 0.02));
180 }
181 }
182 }
183 if (i < 2)
184 {
185 _targetMagmaMap[num, num2] = Magma.CreateFlow(25.0);
186 }
188 }
189 effectedMapArea = new Rectangle(num3, num5, num4 - num3 + 1, num6 - num5 + 1);
190 }
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static Vector2D Zero
Definition Vector2D.cs:24
static Magma CreateFlow(double pressure, double resistance=0.0)

References Terraria.GameContent.Biomes.GraniteBiome._normalisedVectors, Terraria.GameContent.Biomes.GraniteBiome._sourceMagmaMap, Terraria.GameContent.Biomes.GraniteBiome._targetMagmaMap, Terraria.GameContent.Biomes.GraniteBiome.Magma.CreateFlow(), System.length, System.length2, System.Math.Max(), and ReLogic.Utilities.Vector2D.Zero.

Referenced by Terraria.GameContent.Biomes.GraniteBiome.Place().