Exemplo n.º 1
0
        public override void PlaceInWorld(int i, int j, Item item)
        {
            Tile tile = Main.tile[i, j];

            tile.frameX = ManaCrystalShardTile.PickFrameX(i, j);
            tile.frameY = ManaCrystalShardTile.PickFrameY(i, j);
        }
Exemplo n.º 2
0
        public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
        {
            ManaCrystalShardTile.RemoveIlluminationAt(i, j);

            if (!fail && !effectOnly && !noItem)
            {
                Item.NewItem((i << 4), (j << 4), 16, 16, ModContent.ItemType <ManaCrystalShardItem>());
            }
        }
Exemplo n.º 3
0
        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            float illum;

            ManaCrystalShardTile.GetIlluminationAt(i, j, out illum);

            r = illum * 0.32f;
            g = illum * 0.32f;
            b = illum;
        }
Exemplo n.º 4
0
        public static void UpdateLightAversionForTile(int tileX, int tileY, float tolerance, float brightness)
        {
            if (tolerance == 0)
            {
                return;
            }

            float rand = TmlLibraries.SafelyGetRand().NextFloat();

            rand *= tolerance;

            if (rand < brightness)
            {
                ManaCrystalShardTile.TeleportTile(tileX, tileY);
            }
        }
Exemplo n.º 5
0
        ////////////////

        private void UpdateDrawnTileSlow(int i, int j)
        {
            var config        = FMCConfig.Instance;
            var projSingleton = ModContent.GetInstance <FMCProjectile>();

            string manaTileEntry    = nameof(config.ManaCrystalShardMagicResonanceTileRange);
            int    resonanceDistSqr = config.Get <int>(manaTileEntry) * 16;

            resonanceDistSqr *= resonanceDistSqr;

            int tileWldX = i * 16;
            int tileWldY = j * 16;

            foreach (int projWho in projSingleton.GetAllMagicProjectiles())
            {
                Vector2 pos   = Main.projectile[projWho].Center;
                int     distX = ((int)pos.X) - tileWldX;
                int     distY = ((int)pos.Y) - tileWldY;

                int distSqr = (distX * distX) + (distY * distY);
                if (distSqr < resonanceDistSqr)
                {
                    ManaCrystalShardTile.SetIlluminationAt(i, j, 1f);
                    break;
                }
            }

            if (config.DebugModeCheatReveal)
            {
                var  pos  = new Vector2((i << 4) + 8, (j << 4) + 8);
                Dust dust = Dust.NewDustPerfect(
                    Position: pos,
                    Type: 61,
                    Velocity: default(Vector2),
                    Alpha: 0,
                    newColor: Color.Blue,
                    Scale: 3f
                    );
                dust.noGravity = true;
                dust.noLight   = true;
            }
        }
Exemplo n.º 6
0
        ////

        public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
        {
            Tile  tile   = Main.tile[i, j];
            short frameY = ManaCrystalShardTile.PickFrameY(i, j);

            if (tile.frameY != frameY)
            {
                if (frameY == -1)
                {
                    TileLibraries.KillTileSynced(i, j, false, true, true);
                }
                else
                {
                    tile.frameY = frameY;
                    resetFrame  = true;
                }
            }

            return(false);
        }
Exemplo n.º 7
0
        ////

        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            this.UpdateDrawnTileSlow(i, j);
            ManaCrystalShardTile.UpdateIlluminationAt(i, j);

            float illum;

            ManaCrystalShardTile.GetIlluminationAt(i, j, out illum);

            if (illum <= 0f)
            {
                return(false);
            }
            else if (illum >= 0.9f)
            {
                Dust.NewDust(
                    Position: new Vector2(i << 4, j << 4),
                    Width: 16,
                    Height: 16,
                    Type: 20,
                    SpeedX: 0f,
                    SpeedY: 0f,
                    Alpha: 0,
                    newColor: new Color(255, 255, 255),
                    Scale: 0.5f
                    );
            }

            SpriteEffects effects = SpriteEffects.None;

            this.SetSpriteEffects(i, j, ref effects);

            Tile      tile    = Main.tile[i, j];
            Texture2D texture = Main.tileTexture[this.Type];

            /*if (Main.canDrawColorTile(i, j)) {
             *      texture = Main.tileAltTexture[Type, (int)tile.color()];
             * }
             * else {
             *      texture = Main.tileTexture[Type];
             * }*/

            Vector2 zero = !Main.drawToScreen
                                ? new Vector2(Main.offScreenRange, Main.offScreenRange)
                                : Vector2.Zero;

            int   x     = (i << 4) - (int)Main.screenPosition.X;
            int   y     = (j << 4) - (int)Main.screenPosition.Y;
            Color color = Lighting.GetColor(i, j) * illum * 0.75f;

            if (tile.frameX >= texture.Width)
            {
                tile.frameX = ManaCrystalShardTile.PickFrameX(i, j);
            }
            if (tile.frameY >= texture.Height)
            {
                tile.frameY = ManaCrystalShardTile.PickFrameY(i, j);
            }

            spriteBatch.Draw(
                texture: texture,
                position: new Vector2(x, y) + zero,
                sourceRectangle: new Rectangle(tile.frameX, tile.frameY, 16, 16),
                color: color,
                rotation: 0f,
                origin: default(Vector2),
                scale: 1f,
                effects: effects,
                layerDepth: 0f
                );

            return(false);            // return false to stop vanilla draw.
        }
Exemplo n.º 8
0
        ////////////////

        public override bool CanPlace(int i, int j)
        {
            int frameY = ManaCrystalShardTile.PickFrameY(i, j);

            return(frameY != -1);
        }