Пример #1
0
        //angle from 0f to 1f
        public ProceduralSpellProj CreateProjectile(Player player, Vector2 velocity, float angle = 0f, Vector2?position = null, Entity caster = null)
        {
            if (caster == null)
            {
                caster = player;
            }
            Projectile projectile =
                Main.projectile[
                    Projectile.NewProjectile(position ?? caster.Center, velocity.RotatedBy(Constants.Tau * angle), ModContent.ProjectileType <ProceduralSpellProj>(),
                                             ProjectileDamage(player.GetModPlayer <PlayerCharacter>()), 3f, player.whoAmI)];
            ProceduralSpellProj ps = (ProceduralSpellProj)projectile.modProjectile;

            ps.Origin = projectile.position;
            foreach (Item item in Glyphs)
            {
                Glyph glyph = (Glyph)item.modItem;
                if (glyph.GetAiAction() != null)
                {
                    ps.Ai.Add(glyph.GetAiAction());
                }
                if (glyph.GetInitAction() != null)
                {
                    ps.Inits.Add(glyph.GetInitAction());
                }
                if (glyph.GetImpactAction() != null)
                {
                    ps.Impacts.Add(glyph.GetImpactAction());
                }
                if (glyph.GetKillAction() != null)
                {
                    ps.Kills.Add(glyph.GetKillAction());
                }
            }

            foreach (GlyphModifier modifier in Modifiers)
            {
                if (modifier.Impact != null)
                {
                    ps.Impacts.Add(modifier.Impact);
                }
                if (modifier.Draw != null)
                {
                    ps.SpellDraw.Add(modifier.Draw);
                }
                if (modifier.Init != null)
                {
                    ps.Inits.Add(modifier.Init);
                }
            }

            ps.Caster            = caster;
            ps.projectile.minion = Minion;

            /*if (minion)
             * {
             *  ps.projectile.melee = false;
             *  ps.projectile.ranged = false;
             *  ps.projectile.magic = false;
             * }*/
            ps.Source = this;
            ps.Initialize();
            CreateProjectilePacket.Write(player.whoAmI, ps.projectile.whoAmI, Glyphs[(byte)GlyphType.Star].type, Glyphs[(byte)GlyphType.Cross].type, Glyphs[(byte)GlyphType.Moon].type, ps.projectile.damage, Minion, caster.whoAmI, Modifiers);
            return(ps);
        }