tModLoader Error(s) CS 0103, CS 0117, CS 0115 (1.4)

RADICALAdrift

Official Terrarian
Currently got these errors while updating my mod to TML 1.4, Tried letting Visual Studio 2022 suggest edits but to no avail

Multi-CS Error codes.png

And here is the code (Only one code block as the code is pretty much identical for the 2 projectiles)
C:
using Terraria;
using Terraria.ID;
using Terraria.Enums;
using Terraria.Audio;
using Terraria.ModLoader;
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace OPDefense.Projectiles.Summon
{
    public class GODBeamProjectile : ModProjectile
    {
        private Vector2 _targetPos;
        private int _charge;
        private float _moveDist = 45f;
        public override void SetStaticDefaults()
        {
            Projectile.width = 10;
            Projectile.height = 10;
            Projectile.friendly = true;
            Projectile.penetrate = -1;
            Projectile.tileCollide = false;
            Projectile.DamageType = DamageClass.Summon;
            Projectile.hide = true;
            DisplayName.SetDefault("GOD's Destructive Beam");
        }
        public override bool PreDraw(ref Color lightColor)
        {
            if (_charge == 100)
            {
                Vector2 unit = _targetPos - Main.player[Projectile.owner].Center;
                unit.Normalize();
                DrawLaser(spriteBatch, Main.ProjectileTexture[Projectile.type], Main.player[Projectile.owner].Center, unit, 5, Projectile.damage, -1.57f, 1f, 1000f, Color.White, 45);
            }
            return false;
        }
        public override void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default(Color), int transDist = 50)
        {
            Vector2 origin = start;
            float r = unit.ToRotation() + rotation;
 
            #region Draw laser body
            for (float i = transDist; i <= _moveDist; i += step)
            {
                Color c = Color.White;
                origin = start + i * unit;
                spriteBatch.Draw(texture, origin - Main.screenPosition,
                    new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : c, r,
                    new Vector2(28 / 2, 26 / 2), scale, 0, 0);
            }
            #endregion
 
            #region Draw laser tail
            spriteBatch.Draw(texture, start + unit * (transDist - step) - Main.screenPosition,
                new Rectangle(0, 0, 28, 26), Color.White, r, new Vector2(28 / 2, 26 / 2), scale, 0, 0);
            #endregion
 
            #region Draw laser head
            spriteBatch.Draw(texture, start + (_moveDist + step) * unit - Main.screenPosition,
                new Rectangle(0, 52, 28, 26), Color.White, r, new Vector2(28 / 2, 26 / 2), scale, 0, 0);
            #endregion
        }
        public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            if (_charge == 100)
            {
                Player p = Main.player[Projectile.owner];
                Vector2 unit = (Main.player[Projectile.owner].Center - _targetPos);
                unit.Normalize();
                float point = 0f;
                if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), p.Center - 95f * unit, p.Center - unit * _moveDist, 22, ref point))
                {
                    return true;
                }
            }
            return false;
        }
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.immune[Projectile.owner] = 5;
        }
        public override void AI()
        {
 
            Vector2 mousePos = Main.MouseWorld;
            Player player = Main.player[Projectile.owner];
 
            #region Set projectile position
            if (Projectile.owner == Main.myPlayer)
            {
                Vector2 diff = mousePos - player.Center;
                diff.Normalize();
                Projectile.position = player.Center + diff * _moveDist;
                Projectile.timeLeft = 2;
                int dir = Projectile.position.X > player.position.X ? 1 : -1;
                player.ChangeDir(dir);
                player.heldProj = Projectile.whoAmI;
                player.itemTime = 2;
                player.itemAnimation = 2;
                player.itemRotation = (float)Math.Atan2(diff.Y * dir, diff.X * dir);
                Projectile.soundDelay--;
                #endregion
            }
 
 
            #region Charging process
            if (!player.channel)
            {
                Projectile.Kill();
            }
            else
            {
                if (Main.time % 10 < 1 && !player.CheckMana(player.inventory[player.selectedItem].mana, true))
                {
                    Projectile.Kill();
                }
                Vector2 offset = mousePos - player.Center;
                offset.Normalize();
                offset *= _moveDist - 20;
                Vector2 dustPos = player.Center + offset - new Vector2(10, 10);
                if (_charge < 100)
                {
                    _charge++;
                }
                int chargeFact = _charge / 20;
                Vector2 dustVelocity = Vector2.UnitX * 18f;
                dustVelocity = dustVelocity.RotatedBy(Projectile.rotation - 1.57f, default(Vector2));
                Vector2 spawnPos = Projectile.Center + dustVelocity;
                for (int k = 0; k < chargeFact + 1; k++)
                {
                    Vector2 spawn = spawnPos + ((float)Main.rand.NextDouble() * 6.28f).ToRotationVector2() * (12f - (chargeFact * 2));
                    Dust dust = Main.dust[Dust.NewDust(dustPos, 30, 30, DustID.LifeDrain, Projectile.velocity.X / 2f,
                        Projectile.velocity.Y / 2f, 0, default(Color), 18f)];
                    dust.velocity = Vector2.Normalize(spawnPos - spawn) * 1.5f * (10f - chargeFact * 2f) / 10f;
                    dust.noGravity = true;
                    dust.scale = Main.rand.Next(10, 20) * 0.05f;
                }
            }
            #endregion
 
 
            #region Set laser tail position and dusts
            if (_charge < 100) return;
            Vector2 start = player.Center;
            Vector2 unit = (player.Center - mousePos);
            unit.Normalize();
            unit *= -1;
            for (_moveDist = 95f; _moveDist <= 1600; _moveDist += 5)
            {
                start = player.Center + unit * _moveDist;
                if (!Collision.CanHit(player.Center, 1, 1, start, 1, 1))
                {
                    _moveDist -= 5f;
                    break;
                }
 
                if (Projectile.soundDelay <= 0)
                {
                    SoundEngine.PlaySound(2, (int)Projectile.Center.X, (int)Projectile.Center.Y, 15);
                    Projectile.soundDelay = 40;
                }
 
            }
            _targetPos = player.Center + unit * _moveDist;
 
            for (int i = 0; i < 2; ++i)
            {
                float num1 = Projectile.velocity.ToRotation() + (Main.rand.Next(2) == 1 ? -1.0f : 1.0f) * 1.57f;
                float num2 = (float)(Main.rand.NextDouble() * 0.8f + 1.0f);
                Vector2 dustVel = new Vector2((float)Math.Cos(num1) * num2, (float)Math.Sin(num1) * num2);
                Dust dust = Main.dust[Dust.NewDust(_targetPos, 0, 0, DustID.LifeDrain, dustVel.X, dustVel.Y, 0, new Color(), 18f)];
                Dust dust2 = Main.dust[Dust.NewDust(_targetPos, 0, 0, DustID.LifeDrain, dustVel.X, dustVel.Y, 0, new Color(), 18f)];
                dust.noGravity = true;
                dust.scale = 1.2f;
            }
       
            #endregion
        }
        public override bool ShouldUpdatePosition()
        {
            return false;
        }
    }
}
Thanks in advance,
Radical
 
PreDraw has changed in 1.4 and no longer provides a spriteBatch. Here's a 1.4 example of using PreDraw and Main.EntitySpriteDraw. There's no example laser yet to reference but I'd recommend going on the 1.4 modding help discord channel if you can't get it to work.

ExampleBullet
 
Back
Top Bottom