/// <summary>
        /// Gets a shader for the provided PaintingItem. Possible results are the GSPainted and PaintedNegative shaders.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public static MiscShaderData getShader(PaintingItem item, Player player)
        {
            if (player == null)
            {
                return(null);
            }
            if (item == null)
            {
                return(null);
            }
            WoMDPlayer modPlayer = player.GetModPlayer <WoMDPlayer>();

            if (modPlayer == null)
            {
                return(null);
            }
            PaintData data = modPlayer.paintData.clone();

            data.paintMethod = item.overridePaintMethod(modPlayer);
            if (data.paintMethod == PaintMethods.RemovePaint)
            {
                return(null);
            }
            if (data.PaintColor == PaintID.Negative || data.CustomPaint is NegativeSprayPaint)
            {
                return(getNegativeShader());
            }
            return(getGSShader(data.RenderColor));
        }
        /// <summary>
        /// Gets a shader for the provided WoMDNPC. Possible results are the Painted, SprayPainted, and PaintedNegative shaders.
        /// </summary>
        /// <param name="globalNpc"></param>
        /// <param name="drawData">This is necessary for the SprayPainted shader to work</param>
        /// <returns></returns>
        public static MiscShaderData getShader(WoMDNPC globalNpc, PaintData data, out bool needsDrawData)
        {
            needsDrawData = false;
            if (globalNpc == null)
            {
                return(null);
            }
            if (!globalNpc.painted)
            {
                return(null);
            }
            if (data.PaintColor == -1 && data.CustomPaint == null)
            {
                return(null);
            }
            if (data.PaintColor == PaintID.Negative || data.CustomPaint is NegativeSprayPaint)
            {
                return(getNegativeShader());
            }
            Color color = getColor(data);

            if (data.CustomPaint != null && data.sprayPaint)
            {
                needsDrawData = true;
                return(getSprayPaintedShader(color));
            }
            return(getPaintedShader(color));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a splatter of paint
        /// </summary>
        /// <param name="pos">The position of the center of the splatter. Expects values in world coordinates</param>
        /// <param name="radius">The length of the spokes coming out of the center of the splatter. Uses world distance</param>
        /// <param name="spokes">The number of spokes to create</param>
        /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
        /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
        public static void splatter(Vector2 pos, float radius, int spokes, PaintData data, bool useWorldGen = false)
        {
            explode(pos, 48f, data, useWorldGen);
            float angle = Main.rand.NextFloat((float)Math.PI);

            float[] angles = new float[spokes];
            float[] radii  = new float[spokes];
            for (int s = 0; s < spokes; s++)
            {
                angles[s] = angle;
                angle    += Main.rand.NextFloat((float)Math.PI / 6, (float)(Math.PI * 2) / 3);
                radii[s]  = radius - (Main.rand.NextFloat(4) * 8);
            }
            for (int offset = 0; offset < radius; offset += 8)
            {
                for (int s = 0; s < spokes; s++)
                {
                    if (offset <= radii[s])
                    {
                        Point newPos = new Point(
                            (int)Math.Floor((pos.X + Math.Cos(angles[s]) * offset) / 16f),
                            (int)Math.Floor((pos.Y + Math.Sin(angles[s]) * offset) / 16f)
                            );
                        paint(newPos.X, newPos.Y, data, useWorldGen);
                    }
                }
            }
        }
        protected PaintData getPaintData()
        {
            if (_overridePaintData != null)
            {
                return(_overridePaintData);
            }
            PaintData data = new PaintData(paintCyclingTimeScale, -1, null, false, 0);

            if (npcOwner != -1)
            {
                NPC npc = getNPC(npcOwner);
                if (npc == null)
                {
                    return(data);
                }
                WoMDNPC gNpc = npc.GetGlobalNPC <WoMDNPC>();
                return(gNpc.paintData);
            }
            WoMDPlayer player = getModPlayer(projectile.owner);

            if (player == null)
            {
                return(data);
            }
            return(player.paintData);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Paints tiles between the 2 provided world coordinates
        /// </summary>
        /// <param name="start">The starting position of the line to paint. Expects values in world coordinates</param>
        /// <param name="end">The ending position of the line to paint. Expects values in world coordinates</param>
        /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
        /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
        /// <param name="paintedTiles">A list of all the tiles that were updated in this function</param>
        public static void paintBetweenPoints(Vector2 start, Vector2 end, PaintData data, List <Point> paintedTiles = null, bool useWorldGen = false)
        {
            if (!(data.blocksAllowed || data.wallsAllowed))
            {
                return;
            }
            Vector2 unitVector = end - start;
            float   distance   = unitVector.Length();

            unitVector.Normalize();
            int iterations = (int)Math.Ceiling(distance / 8f);
            int count      = 0;

            for (int i = 0; i < iterations; i++)
            {
                Vector2 pos = start + (unitVector * i * 8);
                if (paint(pos, data, useWorldGen))
                {
                    count++;
                    if (paintedTiles != null)
                    {
                        Point tPos = pos.ToTileCoordinates();
                        if (!paintedTiles.Contains(tPos))
                        {
                            paintedTiles.Add(tPos);
                        }
                    }
                }
            }
        }
 public void setOverridePaintData(PaintData data)
 {
     _overridePaintData = data;
     if (multiplayer())
     {
         sendPPOverrideDataPacket(this);
     }
 }
 /// <summary>
 /// Gets a shader for the provided WoMDItem. Possible results are the GSPainted and NegativePainted shaders.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="player"></param>
 /// <returns></returns>
 public static MiscShaderData getShader(WoMDItem item, PaintData data)
 {
     if (data.PaintColor == PaintID.Negative || data.CustomPaint is NegativeSprayPaint)
     {
         return(getNegativeShader());
     }
     return(getGSShader(data.RenderColor));
 }
Exemplo n.º 8
0
        public static void explodeColored(Vector2 pos, IEnumerable <byte> colors, PaintData data, bool useWorldGen = false)
        {
            for (int currentLevel = 0; currentLevel < colors.Count(); currentLevel++)
            {
                if (currentLevel == 0)
                {
                    data.PaintColor = colors.ElementAt(currentLevel);
                    paint(pos, data, useWorldGen);
                }
                else
                {
                    for (int i = 0; i <= currentLevel * 2; i++)
                    {
                        float xOffset;
                        float yOffset;
                        if (i <= currentLevel)
                        {
                            xOffset = currentLevel;
                            yOffset = i;
                        }
                        else
                        {
                            xOffset = (currentLevel * 2 - i + 1);
                            yOffset = (currentLevel + 1);
                        }
                        Vector2 offsetVector = new Vector2(xOffset * 16f, yOffset * 16f);
                        if (offsetVector.Length() <= colors.Count() * 16f)
                        {
                            for (int dir = 0; dir < 4; dir++)
                            {
                                Vector2 transform;
                                switch (dir)
                                {
                                case 0:
                                default:
                                    transform = offsetVector;
                                    break;

                                case 1:
                                    transform = new Vector2(offsetVector.Y, offsetVector.X * -1);
                                    break;

                                case 2:
                                    transform = offsetVector * -1;
                                    break;

                                case 3:
                                    transform = new Vector2(offsetVector.Y * -1, offsetVector.X);
                                    break;
                                }
                                Point p = (pos + transform).ToTileCoordinates();
                                paint(p.X, p.Y, colors.ElementAt(currentLevel), data, useWorldGen);
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Updates the colorFrame property
 /// </summary>
 public void updateColorFrame(PaintMethods method)
 {
     if (npcOwner == -1)
     {
         WoMDPlayer player = getModPlayer(projectile.owner);
         if (player != null)
         {
             if (player.paintData.PaintColor == -1 && player.paintData.CustomPaint == null)
             {
                 colorFrame = 0;
             }
             else if (player.paintData.CustomPaint == null)
             {
                 colorFrame = (byte)player.paintData.PaintColor;
             }
             else
             {
                 colorFrame = player.paintData.CustomPaint.getPaintID(player.paintData);
             }
         }
     }
     else
     {
         NPC npc = getNPC(npcOwner);
         if (npc == null)
         {
             return;
         }
         WoMDNPC gNpc = npc.GetGlobalNPC <WoMDNPC>();
         if (gNpc == null)
         {
             return;
         }
         PaintData data = gNpc.paintData;
         if (data == null)
         {
             colorFrame = 0;
         }
         else
         {
             if (data.PaintColor == -1 && data.CustomPaint == null)
             {
                 colorFrame = 0;
             }
             else if (data.CustomPaint == null)
             {
                 colorFrame = (byte)data.PaintColor;
             }
             else
             {
                 colorFrame = data.CustomPaint.getPaintID(data);
             }
         }
     }
     updateFrame(method);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a circle of paint
        /// </summary>
        /// <param name="pos">The position of the center of the circle. Expects values in world coordinates</param>
        /// <param name="radius">The radiues of the circle. 16 for each tile</param>
        /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
        /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
        public static void explode(Vector2 pos, float radius, PaintData data, bool useWorldGen = false)
        {
            for (int currentLevel = 0; currentLevel < Math.Ceiling(radius / 16f); currentLevel++)
            {
                if (currentLevel == 0)
                {
                    paint(pos, data, useWorldGen);
                }
                else
                {
                    for (int i = 0; i <= currentLevel * 2; i++)
                    {
                        float xOffset;
                        float yOffset;
                        if (i <= currentLevel)
                        {
                            xOffset = currentLevel;
                            yOffset = i;
                        }
                        else
                        {
                            xOffset = (currentLevel * 2 - i + 1);
                            yOffset = (currentLevel + 1);
                        }
                        Vector2 offsetVector = new Vector2(xOffset * 16f, yOffset * 16f);
                        if (offsetVector.Length() <= radius)
                        {
                            for (int dir = 0; dir < 4; dir++)
                            {
                                Vector2 transform;
                                switch (dir)
                                {
                                case 0:
                                default:
                                    transform = offsetVector;
                                    break;

                                case 1:
                                    transform = new Vector2(offsetVector.Y, offsetVector.X * -1);
                                    break;

                                case 2:
                                    transform = offsetVector * -1;
                                    break;

                                case 3:
                                    transform = new Vector2(offsetVector.Y * -1, offsetVector.X);
                                    break;
                                }
                                paint(pos + transform, data, useWorldGen);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Applies a shader for the provided WoMDNPC. Possible results are the Painted, SprayPainted, and PaintedNegative shaders.
        /// </summary>
        /// <param name="globalNpc"></param>
        /// <param name="drawData">This is necessary for the SprayPainted shader to work</param>
        /// <returns></returns>
        public static MiscShaderData applyShader(WoMDNPC globalNpc, PaintData data, DrawData?drawData = null)
        {
            MiscShaderData shader = getShader(globalNpc, data, out bool needsDrawData);

            if (shader != null)
            {
                shader.Apply(needsDrawData ? drawData : null);
            }
            return(shader);
        }
 public override bool PreAI()
 {
     _paintData  = null;
     oldRotation = projectile.rotation;
     if (startPosition.X == 0 && startPosition.Y == 0)
     {
         startPosition = projectile.position;
     }
     return(true);
 }
        /// <summary>
        /// Applies a shader for the provided PaintingProjectile. Possible results are the Painted, GSPainted, and PaintedNegative shaders.
        /// </summary>
        /// <param name="projectile"></param>
        /// <returns></returns>
        public static MiscShaderData applyShader(PaintingProjectile projectile, PaintData data)
        {
            MiscShaderData shader = getShader(projectile, data);

            if (shader != null)
            {
                shader.Apply();
            }
            return(shader);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Paints the tile at the given position
 /// </summary>
 /// <param name="x">The x coordinate of the tile. Expects values in tile coordinates</param>
 /// <param name="y">The y coordinate of the tile. Expects values in tile coordinates</param>
 /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
 /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
 /// <returns>Whether or not the tile was updated</returns>
 public static bool paint(int x, int y, PaintData data, bool useWorldGen = false)
 {
     if (!WorldGen.InWorld(x, y, 10))
     {
         return(false);
     }
     if (data.PaintColor == -1 && data.CustomPaint == null)
     {
         return(false);
     }
     return(paint(x, y, data.TruePaintColor, data, useWorldGen));
 }
        public static Color getColor(PaintData data)
        {
            if (data == null)
            {
                return(Color.White);
            }
            return(data.RenderColor);

            /*if((data.PaintColor == -1 && data.CustomPaint == null) || data.paintMethod == PaintMethods.RemovePaint)
             *      return Color.White;
             * if(data.CustomPaint == null)
             *      return PaintColors.list[data.PaintColor];
             * return data.CustomPaint.getColor(data);*/
        }
        /// <summary>
        /// Gets a shader for the provided WoMDProjectile. Possible results are the Painted and PaintedNegative shaders.
        /// </summary>
        /// <param name="gProjectile"></param>
        /// <returns></returns>
        public static MiscShaderData getShader(WoMDProjectile gProjectile, PaintData data)
        {
            if (gProjectile == null)
            {
                return(null);
            }
            if (!gProjectile.painted)
            {
                return(null);
            }
            if (data.PaintColor == PaintID.Negative || data.CustomPaint is NegativeSprayPaint)
            {
                return(getNegativeShader());
            }
            Color color = getColor(data);

            return(getPaintedShader(color));
        }
 public override bool PreKill(int timeLeft)
 {
     if (server() || singlePlayer() || (multiplayer() && projectile.owner == Main.myPlayer))
     {
         if (dropsOnDeath)
         {
             createDrops(dropCount, projectile.Center, projectile.oldVelocity * -1, dropCone, dropVelocity);
         }
         if (explodesOnDeath)
         {
             PaintData d = getPaintData();
             if (d != null)
             {
                 explode(projectile.Center, explosionRadius, d);
             }
         }
     }
     return(base.PreKill(timeLeft));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Gets the name for a type of paint, provided a paintColor and customPaint
 /// </summary>
 /// <param name="paintColor">Specifies a value from PaintID. -1 for custom paints</param>
 /// <param name="customPaint">Specifies an instance of CustomPaint to use. null for vanilla paints</param>
 /// <returns></returns>
 public static string getPaintColorName(PaintData paintData)
 {
     //TODO: Make this get the display names from the vanilla paints instead of hardcoded values. Maybe add in translations for custom paints
     if (paintData.PaintColor == -1 && paintData.CustomPaint == null)
     {
         return("None");
     }
     if (paintData.CustomPaint != null)
     {
         return(paintData.CustomPaint.displayName);
     }
     else
     {
         if (paintData.PaintColor < ColorNames.list.Length)
         {
             return(ColorNames.list[paintData.PaintColor]);
         }
     }
     return("None");
 }
 /// <summary>
 /// Gets a shader for the provided PaintingProjectile. Possible results are the Painted, GSPainted, and PaintedNegative shaders.
 /// </summary>
 /// <param name="projectile"></param>
 /// <returns></returns>
 public static MiscShaderData getShader(PaintingProjectile projectile, PaintData data)
 {
     if (projectile == null)
     {
         return(null);
     }
     if ((data.PaintColor == -1 && data.CustomPaint == null) || data.paintMethod == PaintMethods.RemovePaint)
     {
         return(null);
     }
     if (data.PaintColor == PaintID.Negative || data.CustomPaint is NegativeSprayPaint)
     {
         return(getNegativeShader());
     }
     if (projectile.usesGSShader)
     {
         return(getGSShader(data.RenderColor));
     }
     return(getPaintedShader(data.RenderColor));
 }
Exemplo n.º 20
0
        /// <summary>
        /// Applies the painted buff to the provided npc, based on the paintColor and customPaint provided
        /// </summary>
        /// <param name="npc">The npc to apply the buff to</param>
        /// <param name="paintColor">The PaintID to use for painting the npc. Should be -1 when using a CustomPaint</param>
        /// <param name="customPaint">The CustomPaint to use for painting the npc. Should be null when using a vanilla paint</param>
        /// <param name="handledNpcs">Should not be provided</param>
        /// <param name="preventRecursion">Should not be provided</param>
        public static void applyPaintedToNPC(NPC npc, PaintData data, List <NPC> handledNpcs = null, bool preventRecursion = false)
        {
            switch (npc.type)
            {
            //cultist fight
            case NPCID.CultistDragonBody1:
            case NPCID.CultistDragonBody2:
            case NPCID.CultistDragonBody3:
            case NPCID.CultistDragonBody4:
            case NPCID.CultistDragonHead:
            case NPCID.CultistDragonTail:
            case NPCID.CultistBossClone:
            case NPCID.CultistBoss:
            case NPCID.AncientCultistSquidhead:
            //destroyer
            case NPCID.TheDestroyer:
            case NPCID.TheDestroyerBody:
            case NPCID.TheDestroyerTail:
            //pillars
            case NPCID.LunarTowerNebula:
            case NPCID.NebulaBeast:
            case NPCID.LunarTowerSolar:
            case NPCID.LunarTowerStardust:
            case NPCID.StardustWormTail:
            case NPCID.StardustWormBody:
            case NPCID.StardustWormHead:
            case NPCID.LunarTowerVortex:
            //martian saucer
            case NPCID.MartianSaucer:
            case NPCID.MartianSaucerCannon:
            case NPCID.MartianSaucerCore:
            case NPCID.MartianSaucerTurret:
            //misc bosses
            case NPCID.Pumpking:
            case NPCID.PumpkingBlade:
            //misc random mobs
            case NPCID.DungeonSpirit:
            case NPCID.Tumbleweed:
            case NPCID.DesertDjinn:
            case NPCID.Ghost:
            case NPCID.Poltergeist:
                return;
            }
            if (preventRecursion)
            {
                return;
            }

            npc.AddBuff(ModContent.BuffType <Painted>(), paintedBuffDuration);

            WoMDNPC globalNpc = npc.GetGlobalNPC <WoMDNPC>();

            if (data.CustomPaint != null)
            {
                data.CustomPaint.modifyPaintDataForNpc(ref data);
            }

            if (globalNpc.painted)
            {
                PaintData existingData = globalNpc.paintData;
                if (existingData.PaintColor == data.PaintColor &&
                    (existingData.CustomPaint == null) == (data.CustomPaint == null) &&                //either both or neither are null
                    existingData.CustomPaint.GetType().Equals(data.CustomPaint.GetType()) &&
                    existingData.sprayPaint == data.sprayPaint)
                {
                    return;                     //nothing needs to be updated
                }
            }

            globalNpc.setPaintData(npc, data);

            if (singlePlayer())
            {
                //TODO: do this whole section better
                if (handledNpcs == null)
                {
                    handledNpcs = new List <NPC>();
                }
                handledNpcs.Add(npc);
                switch (npc.type)
                {
                case NPCID.MoonLordHead:
                case NPCID.MoonLordHand:
                case NPCID.MoonLordCore:
                case NPCID.MoonLordLeechBlob:
                    for (int i = 0; i < Main.npc.Length; i++)
                    {
                        if (Main.npc[i].TypeName == "")
                        {
                            break;
                        }
                        switch (Main.npc[i].type)
                        {
                        case NPCID.MoonLordHead:
                        case NPCID.MoonLordHand:
                        case NPCID.MoonLordCore:
                            applyPaintedToNPC(Main.npc[i], data, null, true);
                            break;
                        }
                    }
                    break;

                case NPCID.EaterofWorldsBody:
                case NPCID.DevourerBody:
                case NPCID.WyvernBody:
                case NPCID.WyvernBody2:
                case NPCID.WyvernBody3:
                case NPCID.WyvernLegs:
                case NPCID.GiantWormBody:
                case NPCID.DiggerBody:
                case NPCID.SeekerBody:                         //world feeder
                case NPCID.TombCrawlerBody:
                case NPCID.DuneSplicerBody:
                case NPCID.SolarCrawltipedeBody:
                case NPCID.BoneSerpentBody:
                    if (npc.ai[0] == Math.Round(npc.ai[0]))
                    {
                        NPC prevSection = getNPC((int)npc.ai[0]);
                        if (prevSection != null && !handledNpcs.Contains(prevSection))
                        {
                            if (prevSection.ai[1] == Math.Round(prevSection.ai[1]))
                            {
                                NPC thisSection = getNPC((int)prevSection.ai[1]);
                                if (thisSection != null && thisSection.Equals(npc))
                                {
                                    applyPaintedToNPC(prevSection, data, handledNpcs);
                                }
                            }
                        }
                    }
                    goto case NPCID.EaterofWorldsTail;

                case NPCID.EaterofWorldsHead:
                case NPCID.DevourerHead:
                case NPCID.WyvernHead:
                case NPCID.GiantWormHead:
                case NPCID.DiggerHead:
                case NPCID.SeekerHead:                         //world feeder
                case NPCID.TombCrawlerHead:
                case NPCID.DuneSplicerHead:
                case NPCID.SolarCrawltipedeHead:
                case NPCID.BoneSerpentHead:
                    if (npc.ai[0] == Math.Round(npc.ai[0]))
                    {
                        NPC prevSection = getNPC((int)npc.ai[0]);
                        if (prevSection != null && !handledNpcs.Contains(prevSection))
                        {
                            if (prevSection.ai[1] == Math.Round(prevSection.ai[1]))
                            {
                                NPC thisSection = getNPC((int)prevSection.ai[1]);
                                if (thisSection != null && thisSection.Equals(npc))
                                {
                                    applyPaintedToNPC(prevSection, data, handledNpcs);
                                }
                            }
                        }
                    }
                    break;

                case NPCID.EaterofWorldsTail:
                case NPCID.DevourerTail:
                case NPCID.WyvernTail:
                case NPCID.GiantWormTail:
                case NPCID.DiggerTail:
                case NPCID.SeekerTail:                         //world feeder
                case NPCID.TombCrawlerTail:
                case NPCID.DuneSplicerTail:
                case NPCID.SolarCrawltipedeTail:
                case NPCID.BoneSerpentTail:
                    if (npc.ai[1] == Math.Round(npc.ai[1]))
                    {
                        NPC nextSection = getNPC((int)npc.ai[1]);
                        if (nextSection != null && !handledNpcs.Contains(nextSection))
                        {
                            if (nextSection.ai[0] == Math.Round(nextSection.ai[0]))
                            {
                                NPC thisSection = getNPC((int)nextSection.ai[0]);
                                if (thisSection != null && thisSection.Equals(npc))
                                {
                                    applyPaintedToNPC(nextSection, data, handledNpcs);
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 21
0
        public static void splatterColored(Vector2 pos, int spokes, IEnumerable <byte> colors, PaintData data, bool useWorldGen = false)
        {
            explodeColored(pos, new List <byte> {
                colors.ElementAt(0), colors.ElementAt(1), colors.ElementAt(2)
            }, data, useWorldGen);
            float radius = 16 * colors.Count();
            float angle  = Main.rand.NextFloat((float)Math.PI);

            float[] angles = new float[spokes];
            float[] radii  = new float[spokes];
            for (int s = 0; s < spokes; s++)
            {
                angles[s] = angle;
                angle    += Main.rand.NextFloat((float)Math.PI / 6, (float)(Math.PI * 2) / 3);
                radii[s]  = radius - (Main.rand.NextFloat(4) * 8);
            }
            for (int offset = 0; offset < radius; offset += 8)
            {
                for (int s = 0; s < spokes; s++)
                {
                    if (offset <= radii[s])
                    {
                        Point newPos = new Point(
                            (int)Math.Floor((pos.X + Math.Cos(angles[s]) * offset) / 16f),
                            (int)Math.Floor((pos.Y + Math.Sin(angles[s]) * offset) / 16f)
                            );
                        paint(newPos.X, newPos.Y, colors.ElementAt((int)Math.Floor(offset / 16f)), data, useWorldGen);
                    }
                }
            }
        }
 /// <summary>
 /// Paints tiles along the old velocity of the projectile. Must be used for projectiles controlled by the player to ensure that paint is properly consumed, and colors are properly changed if the player runs out of a color mid operation
 /// </summary>
 /// <param name="oldVelocity">The old velocity of the projectile</param>
 /// <param name="blocksAllowed">Can be set to false to prevent painting walls regardless of paint method</param>
 /// <param name="wallsAllowed">Can be set to false to prevent painting tiles regardless of paint method</param>
 /// <param name="useWorldGen">Can be set to true to use WorldGen.paintTile and WorldGen.paintWall instead of modifying the tile directly. Using WorldGen causes additional visuals to be created when changing a tile's color</param>
 /// <returns>The number of tiles that were updated</returns>
 public void paintAlongOldVelocity(Vector2 oldVelocity, PaintData paintData)
 {
     paintBetweenPoints(projectile.Center - oldVelocity, projectile.Center, paintData);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Paints the tile at the given position
 /// </summary>
 /// <param name="pos">The position of the tile. Expects values in tile coordinates</param>
 /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
 /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
 /// <returns>Whether or not the tile was updated</returns>
 public static bool paint(Point pos, PaintData data, bool useWorldGen = false) => paint(pos.X, pos.Y, data, useWorldGen);
Exemplo n.º 24
0
        /// <summary>
        /// Paints the tile at the given position
        /// </summary>
        /// <param name="pos">The position of the tile. Expects values in world coordinates</param>
        /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
        /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
        /// <returns>Whether or not the tile was updated</returns>
        public static bool paint(Vector2 pos, PaintData data, bool useWorldGen = false)
        {
            Point p = pos.ToTileCoordinates();

            return(paint(p.X, p.Y, data, useWorldGen));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Paints the tile at the given position
        /// </summary>
        /// <param name="x">The x coordinate of the tile. Expects values in tile coordinates</param>
        /// <param name="y">The y coordinate of the tile. Expects values in tile coordinates</param>
        /// <param name="color">The PaintID of the color to use</param>
        /// <param name="data">An instance of PaintData used to specify various settings for how painting should function</param>
        /// <param name="useWorldGen">Whether or not WorldGen.paintTile and WorldGen.paintWall should be used, or if the tile should just be modified directly. Using WorldGen causes additional visual effects</param>
        /// <returns>Whether or not the tile was updated</returns>
        private static bool paint(int x, int y, byte color, PaintData data, bool useWorldGen = false)
        {
            if (data.paintMethod == PaintMethods.None)
            {
                return(false);
            }

            if (data.sprayPaint)
            {
                if (WorldGen.genRand.NextFloat() < .6f)
                {
                    return(false);
                }
            }

            if (!WorldGen.InWorld(x, y, 10))
            {
                return(false);
            }
            Tile t = Main.tile[x, y];

            if (t == null)
            {
                return(false);
            }

            if (data.paintMethod == PaintMethods.RemovePaint)
            {
                color = 0;
            }

            bool updated = false;

            if (data.paintMethod != PaintMethods.Walls && data.blocksAllowed && t.active() && t.color() != color && (color != 0 || data.paintMethod == PaintMethods.RemovePaint))
            {
                if (useWorldGen)
                {
                    WorldGen.paintTile(x, y, color, false);
                }
                else
                {
                    t.color(color);
                }
                updated = true;
            }
            if (data.paintMethod != PaintMethods.Blocks && data.wallsAllowed && t.wall > 0 && t.wallColor() != color && (color != 0 || data.paintMethod == PaintMethods.RemovePaint))
            {
                if (useWorldGen)
                {
                    WorldGen.paintWall(x, y, color, false);
                }
                else
                {
                    t.wallColor(color);
                }
                updated = true;
            }
            if (updated)
            {
                if (data.paintMethod != PaintMethods.RemovePaint && data.player != null && data.consumePaint)
                {
                    WoMDPlayer player = data.player.GetModPlayer <WoMDPlayer>();
                    if (player != null)
                    {
                        player.consumePaint(data);
                    }
                }
                if (server() || multiplayer())
                {
                    sendTileFrame(x, y);
                }
            }
            return(updated);
        }