tModLoader

tModLoader

Scryie Jun 9, 2023 @ 11:21am
Why does this code error
public override bool PreDraw(ref Color lightColor) {
Projectile.type = ModContent.ProjectileType<EnchantedBeamClone>();

// This code handles the after images.
if (Projectile.ai[0] == 1f) {
Texture2D projectileTexture = TextureAssets.Projectile[Projectile.type].Value;
Vector2 drawPosition = Projectile.position + new Vector2(Projectile.width, Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition;
Vector2 drawOrigin = new Vector2(projectileTexture.Width, projectileTexture.Height) / 2f;
Color drawColor = Projectile.GetAlpha(lightColor);
drawColor.A = 127;
drawColor *= 0.5f;
int launchTimer = (int)Projectile.ai[1];
if (launchTimer > 5) {
launchTimer = 5;
}

SpriteEffects spriteEffects = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

for (float transparancy = 1f; transparancy >= 0f; transparancy -= 0.125f) {
float opacity = 1f - transparancy;
Vector2 drawAdjustment = Projectile.velocity * -launchTimer * transparancy;
Main.EntitySpriteDraw(projectileTexture, drawPosition + drawAdjustment, null, drawColor * opacity, Projectile.rotation, drawOrigin, Projectile.scale * 1.15f * MathHelper.Lerp(0.5f, 1f, opacity), spriteEffects, 0);
}
}
}

I get this error

Error: C:/Users/(I blocked name name out)\Documents\My Games\Terraria\tModLoader\..\tModLoader\ModSources\ProgressRework\Projectiles\Clone\EnchantedBeamClone.cs(62,24): error CS0161: 'EnchantedBeamClone.PreDraw(ref Color)': not all code paths return a value
< >
Showing 1-1 of 1 comments
Scryie Jun 9, 2023 @ 11:25am 
nvm just needed to put return true; at the bottom
< >
Showing 1-1 of 1 comments
Per page: 1530 50

Date Posted: Jun 9, 2023 @ 11:21am
Posts: 1