XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

DeathMod

【Terraria】DeathMod (now aka Soul Harvest)

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/DeathMod

凝实死神领域刀光并延长破裂残留

5b8fcad
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

3 个文件 +98 -16
Modified Common/DeathDomainCrescentVisualSystem.cs +89 -7
@@ -18,6 +18,7 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
18 18 {
19 19 private const int AngularSegments = 128;
20 20 private const int DepthBands = 18;
21 private const int ResidualLifetimeFrames = 30;
21 22 private const float HalfSweep = ReaperCombatRegistry.DeathPrimaryHalfSweep;
22 23 private const float OuterRadiusRatio = 0.91f;
23 24 private const float MaximumThicknessRatio =
@@ -28,6 +29,8 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
28 29 private static VertexPositionColorTexture[] vertices =
29 30 new VertexPositionColorTexture[(AngularSegments + 1) * (DepthBands + 1)];
30 31 private static short[] indices = CreateIndices();
32 private static VertexPositionColorTexture[] rimVertices =
33 new VertexPositionColorTexture[(AngularSegments + 1) * 2];
31 34
32 35 private readonly record struct CrescentDrawState(
33 36 Vector2 Center,
@@ -61,7 +64,7 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
61 64 List<long>? stale = null;
62 65 foreach ((long key, CrescentDrawState state) in drawStates)
63 66 {
64 if (Main.GameUpdateCount <= state.UpdateTick + 1)
67 if (Main.GameUpdateCount <= state.UpdateTick + ResidualLifetimeFrames)
65 68 continue;
66 69 stale ??= [];
67 70 stale.Add(key);
@@ -81,6 +84,7 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
81 84 effect = null;
82 85 vertices = [];
83 86 indices = [];
87 rimVertices = [];
84 88 if (oldEffect is not null && !Main.dedServ)
85 89 Main.QueueMainThreadAction(oldEffect.Dispose);
86 90 }
@@ -112,10 +116,11 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
112 116
113 117 foreach (CrescentDrawState state in drawStates.Values)
114 118 {
115 if (Main.GameUpdateCount > state.UpdateTick + 1)
119 if (Main.GameUpdateCount > state.UpdateTick + ResidualLifetimeFrames)
116 120 continue;
117 121 BuildVertices(state);
118 122 DrawBackdropLayers(graphicsDevice);
123 DrawStableRim(graphicsDevice, state);
119 124 }
120 125 }
121 126
@@ -147,7 +152,8 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
147 152 // The frontier uses the same eased 0..1 clock as the held blade. Revealing
148 153 // the whole face at 42% left the weapon floating far behind its hot edge.
149 154 float reveal = Smooth01(state.LifeProgress);
150 float erosion = Smooth01((state.LifeProgress - 0.30f) / 0.66f);
155 float residualProgress = GetResidualProgress(state);
156 float erosion = Smooth01(residualProgress);
151 157 float rotationCos = (float)Math.Cos(state.Rotation);
152 158 float rotationSin = (float)Math.Sin(state.Rotation);
153 159
@@ -187,12 +193,15 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
187 193 Vector2 world = state.Center + rotated;
188 194 Vector2 screen = world - Main.screenPosition;
189 195
190 float integrity = state.PreserveInterior ? 1f
196 float integrity = residualProgress <= 0f || state.PreserveInterior
197 && Main.GameUpdateCount <= state.UpdateTick + 1
198 ? 1f
191 199 : ReaperCrescentPrimitiveTextureSystem
192 200 .SampleDeathInteriorIntegrity(progress, depth, erosion);
193 float depthFade = MathHelper.Lerp(0.96f, 0.78f, depth);
194 float alpha = state.Opacity * revealAlpha * capAlpha
195 * integrity * depthFade;
201 // The Death Domain is an opaque world-space window. Only the
202 // reveal frontier, interior fracture, and terminal dissolve may
203 // lower alpha; depth never lets the ordinary world bleed through.
204 float alpha = revealAlpha * capAlpha * integrity;
196 205
197 206 // World-space UVs are deliberately independent of the current
198 207 // crescent angle, radius, and animation frame. Only the mask
@@ -205,6 +214,79 @@ internal sealed class DeathDomainCrescentVisualSystem : ModSystem
205 214 }
206 215 }
207 216
217 private static void DrawStableRim(GraphicsDevice graphicsDevice,
218 CrescentDrawState state)
219 {
220 if (effect is null)
221 return;
222
223 float residualProgress = GetResidualProgress(state);
224 float opacity = 1f - Smooth01((residualProgress - 0.74f) / 0.26f);
225 if (opacity <= 0.001f)
226 return;
227
228 DrawRimStrip(graphicsDevice, state, state.Radius * 0.030f,
229 new Color(238, 5, 60) * (opacity * 0.82f));
230 DrawRimStrip(graphicsDevice, state, state.Radius * 0.0125f,
231 new Color(255, 225, 220) * (opacity * 0.96f));
232 }
233
234 private static void DrawRimStrip(GraphicsDevice graphicsDevice,
235 CrescentDrawState state, float width, Color color)
236 {
237 if (effect is null)
238 return;
239
240 float reveal = Smooth01(state.LifeProgress);
241 float rotationCos = (float)Math.Cos(state.Rotation);
242 float rotationSin = (float)Math.Sin(state.Rotation);
243 float outerRadius = state.Radius * OuterRadiusRatio;
244 int vertexIndex = 0;
245 for (int segment = 0; segment <= AngularSegments; segment++)
246 {
247 float progress = segment / (float)AngularSegments;
248 float angle = MathHelper.Lerp(-HalfSweep, HalfSweep, progress)
249 * state.SwingDirection;
250 float revealAlpha = 1f - SmoothStep(reveal - 0.024f,
251 reveal + 0.010f, progress);
252 float capAlpha = SmoothStep(0f, 0.018f, progress)
253 * SmoothStep(0f, 0.018f, 1f - progress);
254 Color vertexColor = color * (revealAlpha * capAlpha);
255 Vector2 radial = angle.ToRotationVector2();
256 for (int side = 0; side < 2; side++)
257 {
258 float localRadius = outerRadius - side * width;
259 Vector2 local = radial * localRadius;
260 Vector2 rotated = new(
261 local.X * rotationCos - local.Y * rotationSin,
262 local.X * rotationSin + local.Y * rotationCos);
263 Vector2 screen = state.Center + rotated - Main.screenPosition;
264 rimVertices[vertexIndex++] = new VertexPositionColorTexture(
265 new Vector3(screen, 0f), vertexColor, Vector2.Zero);
266 }
267 }
268
269 effect.TextureEnabled = false;
270 foreach (EffectPass pass in effect.CurrentTechnique.Passes)
271 {
272 pass.Apply();
273 graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip,
274 rimVertices, 0, rimVertices.Length - 2);
275 }
276 effect.TextureEnabled = true;
277 }
278
279 private static float GetResidualProgress(CrescentDrawState state)
280 {
281 ulong age = Main.GameUpdateCount > state.UpdateTick
282 ? Main.GameUpdateCount - state.UpdateTick
283 : 0;
284 if (age <= 1)
285 return 0f;
286 return MathHelper.Clamp((age - 1f) / (ResidualLifetimeFrames - 1f),
287 0f, 1f);
288 }
289
208 290 private static short[] CreateIndices()
209 291 {
210 292 short[] result = new short[AngularSegments * DepthBands * 6];
Modified Common/ReaperCrescentPrimitiveTextureSystem.cs +6 -8
@@ -178,12 +178,11 @@ internal sealed class ReaperCrescentPrimitiveTextureSystem : ModSystem
178 178 new Color(194, 16, 61, 0) * layerOpacity, effects);
179 179 }
180 180
181 float pulse = 0.985f + (float)Math.Sin(time * 5.8f) * 0.012f;
182 181 DrawBloodFramePair(firstTexture, secondTexture, frameBlend,
183 screenCenter, rotation, scale * 1.018f,
182 screenCenter, rotation, scale,
184 183 new Color(235, 20, 68, 0) * (opacity * 0.16f), effects);
185 184 DrawBloodFramePair(firstTexture, secondTexture, frameBlend,
186 screenCenter, rotation, scale * pulse, Color.White * opacity, effects);
185 screenCenter, rotation, scale, Color.White * opacity, effects);
187 186 }
188 187
189 188 internal static void DrawDeathDomainCrescentRim(
@@ -220,17 +219,16 @@ internal sealed class ReaperCrescentPrimitiveTextureSystem : ModSystem
220 219 {
221 220 float lag = swingDirection * (0.016f + layer * 0.017f);
222 221 DrawBloodFramePair(firstTexture, secondTexture, frameBlend,
223 screenCenter, rotation - lag, scale * (1f - layer * 0.014f),
222 screenCenter, rotation - lag, scale,
224 223 new Color(208, 12, 54, 0)
225 224 * (opacity * (0.034f + layer * 0.012f)), effects);
226 225 }
227 226
228 float pulse = 0.99f + (float)Math.Sin(time * 5.8f) * 0.008f;
229 227 DrawBloodFramePair(firstTexture, secondTexture, frameBlend,
230 screenCenter, rotation, scale * 1.015f,
228 screenCenter, rotation, scale,
231 229 new Color(235, 20, 68, 0) * (opacity * 0.18f), effects);
232 230 DrawBloodFramePair(firstTexture, secondTexture, frameBlend,
233 screenCenter, rotation, scale * pulse, Color.White * opacity,
231 screenCenter, rotation, scale, Color.White * opacity,
234 232 effects);
235 233 }
236 234
@@ -491,7 +489,7 @@ internal sealed class ReaperCrescentPrimitiveTextureSystem : ModSystem
491 489
492 490 Vector4 scene = surface[y * TextureSize + x].ToVector4();
493 491 Vector3 color = new(scene.X, scene.Y, scene.Z);
494 float alpha = body * MathHelper.Lerp(0.96f, 0.78f, sample.Depth);
492 float alpha = body;
495 493 float crimsonVein = Ridge((float)Math.Sin(sample.Progress * 21f
496 494 - sample.Depth * 18f + 0.9f), 9f);
497 495 color = Vector3.Lerp(color, new Vector3(0.66f, 0.008f, 0.09f),
Modified Projectiles/SickleSwingProjectile.cs +3 -1
@@ -952,7 +952,9 @@ public sealed class SickleSwingProjectile : ModProjectile
952 952 {
953 953 if (snapshot.Form == ReaperFormId.Death)
954 954 {
955 DrawDeathPrimaryTrail();
955 // The opaque domain face and its fixed-size cutting edge are emitted
956 // together by DeathDomainCrescentVisualSystem. Drawing the old sprite
957 // rim here would reintroduce a pulsing duplicate over that geometry.
956 958 return;
957 959 }
958 960 if (VisualForm == ReaperFormId.Void)