返回提交历史
Modified
Common/DeathDomainPrimitiveTextureSystem.cs
+48
-0
Modified
Projectiles/DeathDomainHarvestSlashProjectile.cs
+18
-5
XFEstudio/DeathMod
保持领域贯穿刀光截断处宽度
6569642
代码差异
2 个文件
+66
-5
@@ -134,6 +134,54 @@ internal sealed class DeathDomainPrimitiveTextureSystem : ModSystem
134
134
DrawBlade(start, rotation, length, width, color, completion);
135
135
}
136
136
137
internal static void DrawBladeRange(
138
Vector2 start,
139
float rotation,
140
float length,
141
float width,
142
Color color,
143
float completion,
144
float rangeStart,
145
float rangeEnd)
146
{
147
Texture2D? texture = BladeMask;
148
if (texture is null && !Main.dedServ)
149
{
150
texture = CreateBladeMask();
151
BladeMask = texture;
152
}
153
154
completion = MathHelper.Clamp(completion, 0f, 1f);
155
rangeStart = MathHelper.Clamp(rangeStart, 0f, 1f);
156
rangeEnd = MathHelper.Clamp(rangeEnd, rangeStart, 1f);
157
if (texture is null
158
|| length <= 0.05f
159
|| width <= 0.05f
160
|| completion <= 0.001f
161
|| rangeEnd - rangeStart <= 0.0001f)
162
{
163
return;
164
}
165
166
float visibleLength = Math.Max(0.5f, length * completion);
167
int sourceStart = Math.Clamp((int)Math.Floor(rangeStart * texture.Width), 0, texture.Width - 1);
168
int sourceEnd = Math.Clamp((int)Math.Ceiling(rangeEnd * texture.Width), sourceStart + 1, texture.Width);
169
Rectangle source = new(sourceStart, 0, sourceEnd - sourceStart, texture.Height);
170
float widthGrowth = MathHelper.Lerp(0.22f, 1f, SmoothStep(0f, 0.55f, completion));
171
Vector2 position = start + rotation.ToRotationVector2() * (visibleLength * sourceStart / texture.Width);
172
173
Main.EntitySpriteDraw(
174
texture,
175
position,
176
source,
177
color,
178
rotation,
179
new Vector2(0f, texture.Height * 0.5f),
180
new Vector2(visibleLength / texture.Width, width * widthGrowth / texture.Height),
181
SpriteEffects.None,
182
0f);
183
}
184
137
185
internal static void DrawRadialGradient(SpriteBatch batch, Vector2 center, float radius, Color color)
138
186
{
139
187
if (Main.dedServ || radius <= 0.5f)
@@ -197,18 +197,31 @@ public class DeathDomainHarvestSlashProjectile : ModProjectile
197
197
float exclusionEnd = exclusionStart + Math.Max(0f, excludedLength);
198
198
float firstLength = MathHelper.Clamp(exclusionStart, 0f, visibleLength);
199
199
if (firstLength > 0.05f)
200
DeathDomainPrimitiveTextureSystem.DrawBlade(start, rotation, firstLength, width, color);
200
{
201
DeathDomainPrimitiveTextureSystem.DrawBladeRange(
202
start,
203
rotation,
204
length,
205
width,
206
color,
207
reveal,
208
0f,
209
firstLength / visibleLength);
210
}
201
211
202
212
float secondStart = MathHelper.Clamp(exclusionEnd, 0f, visibleLength);
203
213
float secondLength = visibleLength - secondStart;
204
214
if (secondLength > 0.05f)
205
215
{
206
DeathDomainPrimitiveTextureSystem.DrawBlade(
207
start + direction * secondStart,
216
DeathDomainPrimitiveTextureSystem.DrawBladeRange(
217
start,
208
218
rotation,
209
secondLength,
219
length,
210
220
width,
211
color);
221
color,
222
reveal,
223
secondStart / visibleLength,
224
1f);
212
225
}
213
226
}
214
227