Beispiel #1
0
        public void PostEffectsDraw(SpriteBatch spriteBatch, float drawScale = 2f)
        {
            int framesTotal = 20;
            int frame       = 0;

            Texture2D texHead = Main.playerTextures[0, 0];
            Texture2D texBody = Main.playerTextures[0, 3];
            Texture2D texlegs = Main.playerTextures[0, 10];

            Vector2 drawPos = ((npc.Center - Main.screenPosition));

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);

            Texture2D[] texes = new Texture2D[] { texlegs, texBody, texHead };

            Terraria.Utilities.UnifiedRandom rand = new Terraria.Utilities.UnifiedRandom(npc.whoAmI);

            float trans  = MathHelper.Clamp(npc.localAI[0] / 64f, 0f, 1f);
            float smooth = MathHelper.SmoothStep(128f, 0f, trans);

            for (int i = 0; i < 3; i += 1)
            {
                Vector2   loc   = Vector2.UnitX.RotatedBy((rand.NextFloat(0.30f, 0.65f) * Main.GlobalTime * (rand.NextBool() ? 1f : -1f)) + rand.NextFloat(MathHelper.TwoPi)) * (rand.NextFloat(1f, 2f)) * (smooth);
                Texture2D tex   = texes[i];
                Rectangle rect  = new Rectangle(0, 0, tex.Width, tex.Height / 20);
                Rectangle rect2 = new Rectangle(0, frame * rect.Height, tex.Width, rect.Height);

                spriteBatch.Draw(tex, (drawPos + loc) / 2, rect2, Color.Black * trans, 0, rect.Size() / 2f, npc.scale / 2, SpriteEffects.FlipHorizontally, 0f);
            }

            Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);
        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            StandoPlayer pl = player.GetModPlayer <StandoPlayer>();

            if (!pl.HaveStand)
            {
                return(false);
            }

            Terraria.Utilities.UnifiedRandom rand = Main.rand;

            if (rand.Next(1000) == 239 && !player.HasBuff(ModContent.BuffType <Buffs.StarPlatinumRequiemStand>()))
            {
                pl.DeleteStand();
                player.AddBuff(ModContent.BuffType <Buffs.StarPlatinumRequiemStand>(), 239);

                return(true);
            }
            else
            {
                int k = rand.Next(stands.Length);

                while (player.HasBuff(mod.BuffType(stands[k])))
                {
                    k = rand.Next(stands.Length);
                }

                pl.DeleteStand();

                player.AddBuff(mod.BuffType(stands[k]), 239);

                return(true);
            }
        }
Beispiel #3
0
        public override bool UseItem(Player player)
        {
            if (player.GetModPlayer <StandoPlayer>().HaveStand)
            {
                return(true);
            }

            switch (player.name)
            {
            case "Avdol":
            case "avdol":
                player.AddBuff(ModContent.BuffType <Buffs.MagicianRedStand>(), 239);
                return(true);

            case "Jotaro":
            case "jotaro":
                player.AddBuff(ModContent.BuffType <Buffs.StarPlatinumStand>(), 239);
                return(true);

            case "Joseph":
            case "joseph":
                player.AddBuff(ModContent.BuffType <Buffs.HermitPurpleStand>(), 239);
                return(true);

            case "Kakyoin":
            case "kakyoin":
                player.AddBuff(ModContent.BuffType <Buffs.HierophantGreenStand>(), 239);
                return(true);

            ///case "Froloh":
            ///case "froloh":
            ///    player.AddBuff(ModContent.BuffType<Buffs.StarPlatinumRequiemStand>(), 239);
            ///    return true;

            case "Pornoleff":
            case "Polnoreff":
            case "Polnoref":
            case "polnoreff":
            case "polnoref":
                player.AddBuff(ModContent.BuffType <Buffs.SilverChariotStand>(), 239);
                return(true);
            }

            Terraria.Utilities.UnifiedRandom rand = Main.rand;

            if (rand.Next(1000) == 239)
            {
                player.AddBuff(ModContent.BuffType <Buffs.StarPlatinumRequiemStand>(), 239);
            }
            else
            {
                player.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(player.name + " died because was stupid"), 99, 1);
                player.AddBuff(mod.BuffType(stands[rand.Next(stands.Length)]), 239);
            }
            /// add cut scene

            return(true);
        }
Beispiel #4
0
        public override int ChoosePrefix(Terraria.Utilities.UnifiedRandom rand)
        {
            switch (rand.Next(24))
            {
            case 1:
                return(PrefixID.Agile);

            case 2:
                return(PrefixID.Annoying);

            case 3:
                return(PrefixID.Broken);

            case 4:
                return(PrefixID.Damaged);

            case 5:
                return(PrefixID.Deadly2);

            case 6:
                return(PrefixID.Demonic);

            case 7:
                return(PrefixID.Forceful);

            case 8:
                return(PrefixID.Godly);

            case 9:
                return(PrefixID.Hurtful);

            case 10:
                return(PrefixID.Keen);

            case 11:
                return(PrefixID.Lazy);

            case 12:
                return(PrefixID.Murderous);

            case 13:
                return(PrefixID.Nasty);

            case 14:
                return(PrefixID.Nimble);

            case 15:
                return(PrefixID.Quick);

            case 16:
                return(PrefixID.Ruthless);

            case 17:
                return(PrefixID.Shoddy);

            case 18:
                return(PrefixID.Slow);

            case 19:
                return(PrefixID.Sluggish);

            case 20:
                return(PrefixID.Strong);

            case 21:
                return(PrefixID.Superior);

            case 22:
                return(PrefixID.Unpleasant);

            case 23:
                return(PrefixID.Weak);

            default:
                return(PrefixID.Zealous);
            }
        }
Beispiel #5
0
        public static void DrawToRenderTarget()
        {
            if (Main.dedServ || shadowParticlesDrawTime < 1)
            {
                return;
            }

            RenderTargetBinding[] binds = Main.graphics.GraphicsDevice.GetRenderTargets();


            //Draw additive white particles

            Main.graphics.GraphicsDevice.SetRenderTarget(shadowSurface);
            Main.graphics.GraphicsDevice.Clear(Color.Transparent);

            //Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix);

            //Gains a different look when the Hellion Core spawns it
            int fogtype = NPC.CountNPCS(ModContent.NPCType <HellionCore>()) > 0 ? 0 : 1;

            Color fogTo      = Color.DarkMagenta;
            Color fogFrom    = Color.Black;
            float edging     = 0.10f;
            int   smokecount = fogtype == 0 ? 16 : 32;


            foreach (ShadowParticle particle in particles)
            {
                Vector2 size  = particle.CloudTexture.Size();
                float   alpha = (float)Math.Sin((particle.timeLeft / (float)particle.maxTimeLeft) * MathHelper.Pi);
                Main.spriteBatch.Draw(particle.CloudTexture, (particle.position - Main.screenPosition) / 2f, null, Color.White * MathHelper.Clamp(alpha * particle.alpha * particle.fadePercent, 0f, 1f), particle.rotation, size / 2f, particle.scale / 2f, SpriteEffects.None, 0f);
            }

            Main.spriteBatch.End();

            //Now, draw the interior effect using the above as texture mask

            Main.graphics.GraphicsDevice.SetRenderTarget(shadowSurfaceShaderApplied);
            Main.graphics.GraphicsDevice.Clear(Color.Transparent);

            //Main.spriteBatch.End();
            Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);

            ShadowEffect.Parameters["overlayTexture"].SetValue(shadowSurface);
            ShadowEffect.Parameters["colorAmmount"].SetValue(smokecount);
            ShadowEffect.Parameters["screenSize"].SetValue(shadowSurface.Size());
            //Color.DarkMagenta
            //Color.Black
            ShadowEffect.Parameters["colorFrom"].SetValue((fogTo).ToVector4() * (fogtype == 0 ? 1f : 0.01f));
            ShadowEffect.Parameters["colorTo"].SetValue((fogFrom).ToVector4() * 1f);
            ShadowEffect.Parameters["colorOutline"].SetValue((Color.Transparent).ToVector4() * 1f);

            ShadowEffect.Parameters["edgeSmooth"].SetValue(edging);
            ShadowEffect.Parameters["noiseTexture"].SetValue(shadowHellion);
            ShadowEffect.Parameters["invertLuma"].SetValue(false);
            ShadowEffect.Parameters["alpha"].SetValue(1f);


            //Show through
            float percent = 1f;

            ShadowEffect.Parameters["noisePercent"].SetValue(percent);
            ShadowEffect.Parameters["noiseScalar"].SetValue(new Vector4(0, 0, 1f, 1f));

            ShadowEffect.CurrentTechnique.Passes["ColorFilter"].Apply();

            Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.PointClamp;
            Main.spriteBatch.Draw(shadowSurface, Vector2.Zero, new Rectangle(0, 0, Main.screenWidth / 2, Main.screenHeight / 2), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            Main.spriteBatch.End();

            if (percent > 0)
            {
                Main.graphics.GraphicsDevice.SetRenderTarget(shadowHellion);
                Main.graphics.GraphicsDevice.Clear(Color.Transparent);

                //Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.Identity);

                Vector2 parallex = new Vector2(0, 0);

                Effect effect = SGAmod.TrailEffect;

                Terraria.Utilities.UnifiedRandom rando = new Terraria.Utilities.UnifiedRandom(1);

                float timer = rando.NextFloat(MathHelper.TwoPi);

                for (int i = 0; i < 12; i += 1)
                {
                    //Used to pulse in and out, didn't think it was needed in the end thou
                    float alpha = 1f * starAlpha;
                    #region oldcode
                    // MathHelper.Clamp(0.40f + (float)Math.Sin(((SGAWorld.modtimer / 35f) + rando.NextFloat(MathHelper.TwoPi)) * rando.NextFloat(0.25f, 0.75f))*0.80f, 0f, 1f);
                    //if (alpha <= 0 && i > 0)
                    //    continue;
                    #endregion

                    Matrix rotation  = Matrix.CreateRotationZ(timer);
                    Matrix rotation2 = Matrix.CreateRotationZ((-timer));
                    Matrix rotation3 = Matrix.CreateRotationZ((timer - MathHelper.Pi));

                    Matrix rotationOffset = Matrix.CreateTranslation(-shadowSurface.Width / 2, -shadowSurface.Height / 2, 0) * Matrix.CreateScale(3, 3f, 1f) * rotation * Matrix.CreateTranslation(shadowSurface.Width / 2, shadowSurface.Height / 2, 0);

                    if (i > 0)
                    {
                        Vector2 pos2            = ((Main.screenPosition / ((8000f + (i * 4000f))) * 1f) + new Vector2(rando.NextFloat(1f), rando.NextFloat(1f)));
                        Vector2 pos             = -Vector2.One + new Vector2(pos2.X % 1f, pos2.Y % 1f) * 2f;
                        Matrix  rotationOffset2 = Matrix.CreateTranslation(pos.X, pos.Y, 0) * rotation2;
                        parallex = Vector2.Transform(Vector2.One / 2f, rotationOffset2);
                    }
                    if (fogtype == 1)
                    {
                        effect.Parameters["rainbowCoordOffset"].SetValue(new Vector2(rando.NextFloat(1f), rando.NextFloat(1f)));
                        effect.Parameters["rainbowCoordMultiplier"].SetValue(new Vector2(1f, 1f));
                        effect.Parameters["rainbowColor"].SetValue(new Vector3(SGAWorld.modtimer / 300f, 1f, 0.75f));
                        effect.Parameters["rainbowScale"].SetValue(1f);
                        effect.Parameters["rainbowTexture"].SetValue(SGAmod.Instance.GetTexture("TiledPerlin"));
                    }

                    effect.Parameters["WorldViewProjection"].SetValue(WVP.View(Vector2.One) * WVP.Projection());
                    effect.Parameters["imageTexture"].SetValue(i < 1 ? SGAmod.Instance.GetTexture("TiledPerlin") : SGAmod.Instance.GetTexture("Space"));
                    effect.Parameters["coordOffset"].SetValue(parallex);
                    effect.Parameters["coordMultiplier"].SetValue(i < 1 ? new Vector2(2f, 1.5f) * 3f : (new Vector2(3f, 2f) + new Vector2(rando.NextFloat(-0.5f, 0.5f), rando.NextFloat(-0.5f, 0.5f))) * 3f);
                    effect.Parameters["strength"].SetValue(i == 0 ? 0.50f : (1.75f * alpha) / (1f + (i / 4f)));

                    VertexPositionColorTexture[] vertices = new VertexPositionColorTexture[6];
                    VertexBuffer vertexBuffer;

                    Vector3 screenPos = new Vector3(-16, 0, 0);

                    Color colorsa = fogtype == 0 ? Color.Lerp(fogFrom, fogTo, 0.50f) : Color.White;

                    if (i > 0)
                    {
                        colorsa = fogtype == 0 ? Color.Lerp(fogTo, fogFrom, (float)i / 16f) : Color.White * (1f - ((float)i / 48f));
                    }

                    vertices[0] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(-16, -16, 0), rotationOffset), colorsa, new Vector2(0, 0));
                    vertices[1] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(-16, Main.screenHeight + 16, 0), rotationOffset), colorsa, new Vector2(0, 1));
                    vertices[2] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(Main.screenWidth + 16, -16, 0), rotationOffset), colorsa, new Vector2(1, 0));

                    vertices[3] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(Main.screenWidth + 16, Main.screenHeight + 16, 0), rotationOffset), colorsa, new Vector2(1, 1));
                    vertices[4] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(-16, Main.screenHeight + 16, 0), rotationOffset), colorsa, new Vector2(0, 1));
                    vertices[5] = new VertexPositionColorTexture(Vector3.Transform(screenPos + new Vector3(Main.screenWidth + 16, -16, 0), rotationOffset), colorsa, new Vector2(1, 0));

                    vertexBuffer = new VertexBuffer(Main.graphics.GraphicsDevice, typeof(VertexPositionColorTexture), vertices.Length, BufferUsage.WriteOnly);
                    vertexBuffer.SetData <VertexPositionColorTexture>(vertices);

                    Main.graphics.GraphicsDevice.SetVertexBuffer(vertexBuffer);

                    RasterizerState rasterizerState = new RasterizerState();
                    rasterizerState.CullMode = CullMode.None;
                    Main.graphics.GraphicsDevice.RasterizerState = rasterizerState;

                    effect.CurrentTechnique.Passes[i < 1 ? (fogtype == 1 ? "RainbowEffectPass" : "BasicEffectPass") : (fogtype == 1 ? "RainbowEffectAlphaPass" : "BasicEffectAlphaPass")].Apply();
                    Main.graphics.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                }


                Main.spriteBatch.End();
                Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix);

                //originally, the worms were drawn INSIDE the rendertarget, but this has since been changed
                #region oldcode

                /*foreach(NPC hellionarm in Main.npc.Where(testby => testby.active && (testby.type == ModContent.NPCType<HellionCore>() || testby.type == ModContent.NPCType<HellionMonolog>())))
                 * {
                 *  Hellion.HellionTeleport(Main.spriteBatch, (Main.screenPosition+hellionarm.Center)/2f, 0.5f, 48);
                 *  //((HellionWorm)(hellionarm.modNPC as HellionWorm)).DrawMe(Main.spriteBatch,Color.White,0.5f);
                 * }*/

                //Main.spriteBatch.Draw(hellionTex, -reallyHellion.velocity + new Vector2(0, 10) + (reallyHellion.Center - Main.screenPosition) / 2f, null, Color.White * (settings != null ? settings.HelliontransparencyRate : 0.15f), 0, hellionTex.Size() / 2f, 0.50f, SpriteEffects.None, 0f);
                #endregion

                Main.spriteBatch.End();
            }

            Main.graphics.GraphicsDevice.SetRenderTargets(binds);
        }
Beispiel #6
0
        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            if (Main.tile[i, j].type == base.Type)
            {
                string texstr = "SGAmod/Items/Placeable/Relics/Tiles/RelicBase";                //"SGAmod/Tiles/BiomassBarTile"


                Texture2D tex = ModContent.GetTexture(texstr);

                Vector2 zerooroffset = Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange);
                Vector2 location     = (new Vector2(i, j) * 16) + zerooroffset + new Vector2(0, 2);

                if (Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY == 0)
                {
                    Main.spriteBatch.End();
                    Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(1, 1, 1));

                    //SGAmod.FadeInEffect.Parameters["fadeColor"].SetValue(Color.Goldenrod.ToVector3());
                    //SGAmod.FadeInEffect.CurrentTechnique.Passes["ColorToAlphaPass"].Apply();

                    //Action<SpriteBatch, Vector2> drawCode = delegate (SpriteBatch spriteBatch2, Vector2 location2)
                    //{
                    Texture2D star = ModContent.GetTexture("SGAmod/Extra_57b");

                    Terraria.Utilities.UnifiedRandom rando = new Terraria.Utilities.UnifiedRandom(i + j);

                    Vector2 starterloc = location + new Vector2(24, 32);

                    Vector2 sizeStar = star.Size() / 2f;

                    List <(Vector2, float, float)> entries = new List <(Vector2, float, float)>();

                    for (float ix = 0; ix < 1f; ix += 1 / 30f)
                    {
                        float   shiftOut    = -1f + ix * 2f;
                        float   timePercent = (Main.GlobalTime + (ix)) % 1f;
                        Vector2 newLoc      = new Vector2(rando.NextFloat(-8f, 8f) + shiftOut * 4f, -rando.NextFloat(6f, 28f)) * timePercent;
                        Vector2 newLoc2     = new Vector2(rando.NextFloat(-12f, 12f) + shiftOut * 8f, 4);
                        float   rotation    = Main.GlobalTime * (rando.NextFloat(-1f, 1f) * (rando.NextBool() ? 1f : -1f) * 0.025f);

                        entries.Add((newLoc + newLoc2, timePercent, rotation));
                    }

                    foreach ((Vector2, float, float)tuple in entries.OrderBy(testby => testby.Item1.Y))
                    {
                        spriteBatch.Draw(star, starterloc + tuple.Item1 - Main.screenPosition, null, Color.Goldenrod * (1f - tuple.Item2), tuple.Item3, sizeStar, new Vector2(1f, 1f) * 0.25f, SpriteEffects.None, 0f);
                    }

                    //Main.spriteBatch.End();
                    //Main.spriteBatch.Begin(SpriteSortMode.Texture, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(1, 1, 1));

                    Texture2D tex2 = ModContent.GetTexture("SGAmod/Extra_60b");
                    spriteBatch.Draw(tex2, starterloc - Main.screenPosition, null, Color.Goldenrod, 0f, tex2.Size() / 2f, new Vector2(0.80f, 1f), SpriteEffects.None, 0f);
                    //};

                    //CustomSpecialDrawnTiles cdt = new CustomSpecialDrawnTiles(location);
                    //cdt.CustomDraw = drawCode;
                    //SGAmod.BeforeTilesAdditive.Add(cdt);

                    Main.spriteBatch.End();
                    Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.CreateScale(1, 1, 1));
                }

                spriteBatch.Draw(tex, location - Main.screenPosition, new Rectangle(Main.tile[i, j].frameX, Main.tile[i, j].frameY + 18, 16, 16), Lighting.GetColor(i, j), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }
            return(true);
        }
Beispiel #7
0
 internal static bool Chance(this Terraria.Utilities.UnifiedRandom random, float chance) => chance >= 1f || random.NextFloat() < chance;
Beispiel #8
0
        private void HookBeeType(HookIL il)
        {
            // Start the Cursor at the start
            var c = il.At(0);

            // Try to find where 566 is placed onto the stack
            if (!c.TryGotoNext(i => i.MatchLdcI4(566)))
            {
                return;                 // Patch unable to be applied
            }
            // Choose a random implementation of the patch. This is just to show different patch approaches.
            var random = new Terraria.Utilities.UnifiedRandom();
            int choice = random.Next(3);             // Main.rand is null during mod loading.

            if (choice == 0)
            {
                // Move the cursor after 566 and onto the ret op.
                c.Index++;
                // Push the Player instance onto the stack
                c.Emit(Ldarg_0);
                // Call a delegate using the int and Player from the stack.
                c.EmitDelegate <Func <int, Player, int> >((returnValue, player) =>
                {
                    // Regular c# code
                    if (player.GetModPlayer <ExamplePlayer>().strongBeesUpgrade&& Main.rand.NextBool(10) && Main.ProjectileUpdateLoopIndex == -1)
                    {
                        return(ProjectileID.Beenade);
                    }
                    return(returnValue);
                });
            }
            else if (choice == 1)
            {
                // Make a label to use later
                var label = il.DefineLabel();
                // Push the Player instance onto the stack
                c.Emit(Ldarg_0);
                // Call a delegate popping the Player from the stack and pushing a bool
                c.EmitDelegate <Func <Player, bool> >(player => player.GetModPlayer <ExamplePlayer>().strongBeesUpgrade&& Main.rand.NextBool(10) && Main.ProjectileUpdateLoopIndex == -1);
                // if the bool on the stack is false, jump to label
                c.Emit(Brfalse, label);
                // Otherwise, push ProjectileID.Beenade and return
                c.Emit(Ldc_I4, ProjectileID.Beenade);
                c.Emit(Ret);
                // Set the label to the current cursor, which is still the instruction pushing 566 (which is followed by Ret)
                c.MarkLabel(label);
            }
            else
            {
                var label = il.DefineLabel();

                // Here we simply adapt the dnSpy output. This approach is tedious but easier if you don't understand IL instructions.
                c.Emit(Ldarg_0);
                // We need to make sure to pass in FieldInfo or MethodInfo into Call instructions.
                // Here we show how to retrieve a generic version of a MethodInfo
                c.Emit(Call, typeof(Player).GetMethod("GetModPlayer", new Type[] { }).MakeGenericMethod(typeof(ExamplePlayer)));
                // nameof helps avoid spelling mistakes
                c.Emit(Ldfld, typeof(ExamplePlayer).GetField(nameof(ExamplePlayer.strongBeesUpgrade)));
                c.Emit(Brfalse_S, label);
                c.Emit(Ldsfld, typeof(Main).GetField(nameof(Main.rand)));
                // Ldc_I4_S expects an int8, aka an sbyte. Failure to cast correctly will crash the game
                c.Emit(Ldc_I4_S, (sbyte)10);
                c.Emit(Call, typeof(Utils).GetMethod("NextBool", new Type[] { typeof(Terraria.Utilities.UnifiedRandom), typeof(int) }));
                c.Emit(Brfalse_S, label);
                // You may be tempted to write c.Emit(Ldsfld, Main.ProjectileUpdateLoopIndex);, this won't work and will simply use the value of the field at patch time. That will crash.
                c.Emit(Ldsfld, typeof(Main).GetField(nameof(Main.ProjectileUpdateLoopIndex)));
                c.Emit(Ldc_I4_M1);
                c.Emit(Bne_Un_S, label);
                c.Emit(Ldc_I4, ProjectileID.Beenade);
                c.Emit(Ret);
                // As Emit has been inserting and advancing the cursor index, we are still pointing at the 566 instruction.
                // All the branches in the dnspy output jumped to this instruction, so we set the label to this instruction.
                c.MarkLabel(label);
            }
        }