Small optimizations
This commit is contained in:
1 parent
22c5a74991
commit
2b23659689
4 files changed
+14
-14
No files matched your search
@@ -68,10 +68,10 @@ namespace CalamityMod.Projectiles.Magic
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
if (TrailDrawer is null)
|
||||
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, true, GameShaders.Misc["CalamityMod:FabstaffRay"]);
|
||||
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, false, GameShaders.Misc["CalamityMod:FabstaffRay"]);
|
||||
|
||||
GameShaders.Misc["CalamityMod:FabstaffRay"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/FabstaffStreak"));
|
||||
TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 40);
|
||||
TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 8);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Ray");
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 72;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 54;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,19 +38,16 @@ namespace CalamityMod
|
||||
|
||||
private Vector2 PrivateEvaluate(Vector2[] points, float T)
|
||||
{
|
||||
if (points.Length > 2)
|
||||
while (points.Length > 2)
|
||||
{
|
||||
Vector2[] nextPoints = new Vector2[points.Length - 1];
|
||||
for (int k = 0; k < points.Length - 1; k++)
|
||||
{
|
||||
nextPoints[k] = Vector2.Lerp(points[k], points[k + 1], T);
|
||||
}
|
||||
return PrivateEvaluate(nextPoints, T);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Vector2.Lerp(points[0], points[1], T);
|
||||
points = nextPoints;
|
||||
}
|
||||
return Vector2.Lerp(points[0], points[1], T);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,13 +374,16 @@ namespace CalamityMod
|
||||
{
|
||||
float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2);
|
||||
|
||||
if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && (Collision.CanHitLine(origin, 1, 1, Main.npc[index].Center, 1, 1) || ignoreTiles))
|
||||
if (!Main.npc[index].WithinRange(origin, distance + extraDistance) ||
|
||||
!(Collision.CanHitLine(origin, 1, 1, Main.npc[index].Center, 1, 1) || ignoreTiles))
|
||||
{
|
||||
if (Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye)
|
||||
bossFound = true;
|
||||
distance = Vector2.Distance(origin, Main.npc[index].Center);
|
||||
closestTarget = Main.npc[index];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye)
|
||||
bossFound = true;
|
||||
distance = Vector2.Distance(origin, Main.npc[index].Center);
|
||||
closestTarget = Main.npc[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user