返回提交历史
Modified
Common/DeathDomainPrimitiveTextureSystem.cs
+54
-3
Modified
Common/DeathDomainVisualSystem.cs
+42
-46
Modified
Items/DeathNecklace.cs
+1
-1
Modified
Projectiles/DeathDomainHarvestSlashProjectile.cs
+0
-17
XFEstudio/DeathMod
修正领域流场方向并优化斩击预警
c129391
代码差异
4 个文件
+97
-67
@@ -15,6 +15,7 @@ namespace DeathMod.Common;
15
15
internal sealed class DeathDomainPrimitiveTextureSystem : ModSystem
16
16
{
17
17
internal static Texture2D? BladeMask { get; private set; }
18
internal static Texture2D? RadialGradientMask { get; private set; }
18
19
19
20
private static Texture2D CreateBladeMask()
20
21
{
@@ -44,12 +45,44 @@ internal sealed class DeathDomainPrimitiveTextureSystem : ModSystem
44
45
return texture;
45
46
}
46
47
48
private static Texture2D CreateRadialGradientMask()
49
{
50
const int size = 512;
51
Texture2D texture = new(Main.instance.GraphicsDevice, size, size, false, SurfaceFormat.Color);
52
Color[] pixels = new Color[size * size];
53
for (int y = 0; y < size; y++)
54
{
55
float normalizedY = (y + 0.5f) / size * 2f - 1f;
56
for (int x = 0; x < size; x++)
57
{
58
float normalizedX = (x + 0.5f) / size * 2f - 1f;
59
float distance = (float)Math.Sqrt(normalizedX * normalizedX + normalizedY * normalizedY);
60
float falloff = MathHelper.Clamp(1f - distance, 0f, 1f);
61
float alpha = falloff * falloff * (3f - 2f * falloff);
62
alpha = (float)Math.Pow(alpha, 1.18f);
63
byte value = (byte)Math.Clamp((int)Math.Round(alpha * 255f), 0, 255);
64
pixels[y * size + x] = new Color(value, value, value, value);
65
}
66
}
67
68
texture.SetData(pixels);
69
return texture;
70
}
71
47
72
public override void Unload()
48
73
{
49
Texture2D? texture = BladeMask;
74
Texture2D? bladeTexture = BladeMask;
75
Texture2D? gradientTexture = RadialGradientMask;
50
76
BladeMask = null;
51
if (texture is not null && !Main.dedServ)
52
Main.QueueMainThreadAction(texture.Dispose);
77
RadialGradientMask = null;
78
if (!Main.dedServ && (bladeTexture is not null || gradientTexture is not null))
79
{
80
Main.QueueMainThreadAction(() =>
81
{
82
bladeTexture?.Dispose();
83
gradientTexture?.Dispose();
84
});
85
}
53
86
}
54
87
55
88
internal static void DrawBlade(
@@ -101,6 +134,24 @@ internal sealed class DeathDomainPrimitiveTextureSystem : ModSystem
101
134
DrawBlade(start, rotation, length, width, color, completion);
102
135
}
103
136
137
internal static void DrawRadialGradient(SpriteBatch batch, Vector2 center, float radius, Color color)
138
{
139
if (Main.dedServ || radius <= 0.5f)
140
return;
141
142
Texture2D texture = RadialGradientMask ??= CreateRadialGradientMask();
143
batch.Draw(
144
texture,
145
center,
146
null,
147
color,
148
0f,
149
texture.Size() * 0.5f,
150
radius * 2f / texture.Width,
151
SpriteEffects.None,
152
0f);
153
}
154
104
155
private static float SmoothStep(float start, float end, float value)
105
156
{
106
157
if (end <= start)
@@ -186,10 +186,11 @@ internal class DeathDomainVisualSystem : ModSystem
186
186
float coreNoiseAmplitude = Math.Min(coreRadius * 0.18f, MathHelper.Lerp(5f, 10f, mastery) * MathHelper.Lerp(0.35f, 1f, reveal));
187
187
float blackOpacity = MathHelper.Lerp(0.50f, 0.96f, mastery) * reveal;
188
188
DrawFilledNoiseDisc(batch, pixel, center, coreRadius, coreNoiseTime, coreNoiseSeed, coreNoiseAmplitude, Color.Black * blackOpacity);
189
DrawFilledNoiseDisc(batch, pixel, center, coreRadius * 0.32f, -time * 0.62f, 27.4f,
190
MathHelper.Lerp(2.2f, 4.8f, mastery), new Color(155, 12, 38) * (0.11f * pulse));
191
DrawFilledNoiseDisc(batch, pixel, center, coreRadius * 0.16f, time * 0.9f, 31.8f,
192
MathHelper.Lerp(1.2f, 3.2f, mastery), new Color(255, 74, 96) * (0.17f * pulse));
189
DeathDomainPrimitiveTextureSystem.DrawRadialGradient(
190
batch,
191
center,
192
coreRadius * MathHelper.Lerp(0.48f, 0.58f, mastery),
193
new Color(255, 58, 84) * (MathHelper.Lerp(0.16f, 0.24f, mastery) * pulse));
193
194
DrawOutwardPressureWaves(batch, pixel, center, coreRadius, time, mastery, pulse);
194
195
DrawNoiseBoundary(batch, pixel, center, coreRadius, coreNoiseTime, coreNoiseSeed, coreNoiseAmplitude, 2.2f, 0.76f * pulse, mastery, gaps: false);
195
196
DrawInwardSuctionWaves(batch, pixel, center, radius, coreRadius, time, mastery, pulse);
@@ -335,48 +336,45 @@ internal class DeathDomainVisualSystem : ModSystem
335
336
float mastery,
336
337
float pulse)
337
338
{
338
// Short comet-like streams move unambiguously from the outer radius toward
339
// the event horizon. Their tails always remain farther from the centre than
340
// their heads, so the absorption direction cannot appear reversed.
339
// Preserve the original long black-hole accretion lines. Only the animated
340
// highlight direction is reversed so they now read as being swallowed by
341
// the event horizon instead of being emitted from it.
341
342
int streamCount = 7 + (int)Math.Round(mastery * 5f);
342
343
float outerRadius = edgeRadius + MathHelper.Lerp(72f, 126f, mastery);
343
344
for (int stream = 0; stream < streamCount; stream++)
344
345
{
345
346
float seed = stream * 4.731f + 2.4f;
346
float head = PositiveModulo(time * MathHelper.Lerp(0.44f, 0.68f, mastery)
347
float movingHead = 1f - PositiveModulo(time * MathHelper.Lerp(0.48f, 0.78f, mastery)
347
348
+ stream / (float)streamCount, 1f);
348
349
float baseAngle = stream * MathHelper.TwoPi / streamCount
349
+ BoundaryNoise(stream, time * 0.12f, seed) * 0.045f;
350
float trailLength = MathHelper.Lerp(0.18f, 0.28f, mastery);
351
float tail = Math.Max(0f, head - trailLength);
352
float spawnFade = MathHelper.SmoothStep(0f, 0.09f, head);
353
float arrivalFade = 1f - MathHelper.SmoothStep(0.84f, 1f, head);
350
- time * (0.13f + mastery * 0.08f)
351
+ BoundaryNoise(stream, time * 0.18f, seed) * 0.06f;
354
352
355
const int points = 18;
353
const int points = 46;
356
354
Vector2 previous = Vector2.Zero;
357
bool hasPrevious = false;
358
355
for (int point = 0; point < points; point++)
359
356
{
360
float trailProgress = point / (points - 1f);
361
float inward = MathHelper.Lerp(tail, head, trailProgress);
357
float inward = point / (points - 1f);
362
358
float curved = inward * inward * (3f - 2f * inward);
363
359
float angle = baseAngle + inward * MathHelper.Lerp(1.08f, 1.54f, mastery);
364
360
float radius = MathHelper.Lerp(outerRadius, edgeRadius + 2f, curved)
365
361
+ BoundaryNoise(angle, -time * 0.82f, seed) * MathHelper.Lerp(5.2f, 1.2f, inward);
366
362
Vector2 current = center + angle.ToRotationVector2() * radius;
367
if (hasPrevious)
363
if (point > 0)
368
364
{
369
float headGlow = MathHelper.SmoothStep(0f, 1f, trailProgress);
370
float opacity = pulse * spawnFade * arrivalFade * headGlow * (0.18f + headGlow * 0.72f);
365
float bodyFade = (float)Math.Sin(inward * MathHelper.Pi);
366
float distanceFromHead = Math.Abs(inward - movingHead);
367
float movingGlow = 1f - MathHelper.SmoothStep(0.02f, 0.25f, distanceFromHead);
368
float opacity = bodyFade * pulse * (0.16f + movingGlow * 0.64f);
371
369
Color color = Color.Lerp(
372
370
new Color(18, 0, 8),
373
371
Color.Lerp(new Color(174, 3, 40), new Color(255, 34, 76), mastery),
374
headGlow);
375
float width = MathHelper.Lerp(0.45f, 3.8f + mastery * 1.6f, headGlow);
372
inward * (0.45f + movingGlow * 0.55f));
373
float width = MathHelper.Lerp(0.55f, 3.4f + mastery * 1.7f, inward)
374
* (0.68f + movingGlow * 0.48f);
376
375
DrawSegment(batch, pixel, previous, current - previous, color * opacity, width);
377
376
}
378
377
previous = current;
379
hasPrevious = true;
380
378
}
381
379
}
382
380
}
@@ -390,47 +388,45 @@ internal class DeathDomainVisualSystem : ModSystem
390
388
float mastery,
391
389
float pulse)
392
390
{
393
int streamCount = 8 + (int)Math.Round(mastery * 6f);
394
float innerRadius = Math.Max(5f, coreRadius * 0.055f);
391
// This is the same continuous accretion-line construction used outside,
392
// with radius progression, spiral turn and highlight travel all inverted.
393
int streamCount = 7 + (int)Math.Round(mastery * 5f);
394
float innerRadius = Math.Max(5f, coreRadius * 0.06f);
395
395
float outerRadius = coreRadius * 0.90f;
396
396
for (int stream = 0; stream < streamCount; stream++)
397
397
{
398
398
float seed = 42.7f + stream * 3.117f;
399
float head = PositiveModulo(time * MathHelper.Lerp(0.38f, 0.62f, mastery)
399
float movingHead = PositiveModulo(time * MathHelper.Lerp(0.48f, 0.78f, mastery)
400
400
+ stream / (float)streamCount, 1f);
401
float trailLength = MathHelper.Lerp(0.16f, 0.24f, mastery);
402
float tail = Math.Max(0f, head - trailLength);
403
401
float baseAngle = stream * MathHelper.TwoPi / streamCount
404
- BoundaryNoise(stream, time * 0.15f, seed) * 0.055f;
405
float spawnFade = MathHelper.SmoothStep(0f, 0.10f, head);
406
float arrivalFade = 1f - MathHelper.SmoothStep(0.82f, 1f, head);
402
+ time * (0.13f + mastery * 0.08f)
403
- BoundaryNoise(stream, time * 0.18f, seed) * 0.06f;
407
404
408
const int points = 15;
405
const int points = 40;
409
406
Vector2 previous = Vector2.Zero;
410
bool hasPrevious = false;
411
407
for (int point = 0; point < points; point++)
412
408
{
413
float trailProgress = point / (points - 1f);
414
float outward = MathHelper.Lerp(tail, head, trailProgress);
409
float outward = point / (points - 1f);
415
410
float curved = outward * outward * (3f - 2f * outward);
416
float angle = baseAngle - outward * MathHelper.Lerp(0.72f, 1.12f, mastery);
411
float angle = baseAngle - outward * MathHelper.Lerp(1.08f, 1.54f, mastery);
417
412
float radius = MathHelper.Lerp(innerRadius, outerRadius, curved)
418
+ BoundaryNoise(angle, time * 0.74f, seed) * MathHelper.Lerp(1.1f, 3.8f, outward);
413
+ BoundaryNoise(angle, time * 0.82f, seed) * MathHelper.Lerp(1.2f, 4.6f, outward);
419
414
Vector2 current = center + angle.ToRotationVector2() * radius;
420
if (hasPrevious)
415
if (point > 0)
421
416
{
422
float headGlow = MathHelper.SmoothStep(0f, 1f, trailProgress);
423
float opacity = pulse * spawnFade * arrivalFade * headGlow * (0.15f + headGlow * 0.62f);
417
float bodyFade = (float)Math.Sin(outward * MathHelper.Pi);
418
float distanceFromHead = Math.Abs(outward - movingHead);
419
float movingGlow = 1f - MathHelper.SmoothStep(0.02f, 0.25f, distanceFromHead);
420
float opacity = bodyFade * pulse * (0.13f + movingGlow * 0.58f);
424
421
Color color = Color.Lerp(
425
new Color(255, 112, 130),
426
Color.Lerp(new Color(148, 5, 38), new Color(226, 18, 58), mastery),
427
outward);
428
float width = MathHelper.Lerp(3.2f + mastery, 0.7f, outward)
429
* (0.62f + headGlow * 0.55f);
422
new Color(255, 116, 136),
423
Color.Lerp(new Color(112, 2, 28), new Color(220, 18, 58), mastery),
424
outward * 0.78f);
425
float width = MathHelper.Lerp(3.5f + mastery * 1.4f, 0.65f, outward)
426
* (0.66f + movingGlow * 0.46f);
430
427
DrawSegment(batch, pixel, previous, current - previous, color * opacity, width);
431
428
}
432
429
previous = current;
433
hasPrevious = true;
434
430
}
435
431
}
436
432
}
@@ -16,7 +16,7 @@ public class DeathNecklace : ModItem, IDeathAltarUpgradeable
16
16
{
17
17
public const int MaxCoreLevel = 10;
18
18
public const int MaxVolleyLevel = 5;
19
public const float RadiusGrowthPerLevel = 33f;
19
public const float RadiusGrowthPerLevel = 10f;
20
20
21
21
private static readonly DeathAltarUpgradeType[] UpgradeTypes =
22
22
[
@@ -107,10 +107,7 @@ public class DeathDomainHarvestSlashProjectile : ModProjectile
107
107
{
108
108
float progress = (age - slash * SlashDelayFrames) / (float)SlashActiveFrames;
109
109
if (progress <= 0f)
110
{
111
DrawPendingCut(slash);
112
110
continue;
113
}
114
111
if (progress >= 1f)
115
112
continue;
116
113
DrawExecutionBlade(progress, slash);
@@ -118,20 +115,6 @@ public class DeathDomainHarvestSlashProjectile : ModProjectile
118
115
return false;
119
116
}
120
117
121
private void DrawPendingCut(int slash)
122
{
123
float rotation = GetSlashRotation(Projectile.rotation, slash);
124
float length = GetSlashLength(Mastery, Projectile.scale, slash);
125
float pulse = 0.72f + (float)Math.Sin(Main.GlobalTimeWrappedHourly * 13f + slash * 2.1f) * 0.18f;
126
DrawTaperedBladeLayer(
127
Projectile.Center - Main.screenPosition,
128
rotation,
129
length,
130
(1.55f + Mastery * 0.5f) * Projectile.scale,
131
1f,
132
new Color(255, 8, 48, 0) * pulse);
133
}
134
135
118
private void DrawExecutionBlade(float progress, int slash)
136
119
{
137
120
// Begin as a single point, then visibly stretch it along the warning line.