53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
|
|
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ReLogic.Content;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Utilities;
|
|
namespace CalamityMod.Walls
|
|
{
|
|
[LegacyName("AstralGrassWallSafe")]
|
|
public class AstralGrassWall : ModWall
|
|
{
|
|
public static Asset<Texture2D> leafTexture = null;
|
|
|
|
public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
// TODO -- Change this dust to be one more befitting Astral Grass.
|
|
DustType = DustID.Shadowflame;
|
|
|
|
WallID.Sets.Conversion.Grass[Type] = true;
|
|
|
|
Main.wallHouse[Type] = true;
|
|
|
|
AddMapEntry(new Color(60, 48, 64));
|
|
|
|
if (!Main.dedServ)
|
|
{
|
|
leafTexture = ModContent.Request<Texture2D>("CalamityMod/Walls/AstralGrassWallLeaves");
|
|
}
|
|
}
|
|
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
|
{
|
|
if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16)
|
|
{
|
|
Texture2D tex = leafTexture.Value;
|
|
var rand = new FastRandom(i + (j * 100000));
|
|
|
|
float offset = i * j % 6.28f + rand.NextFloat() / 8f;
|
|
float sin = MathF.Sin(Main.GameUpdateCount / 45f + offset);
|
|
|
|
spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition,
|
|
new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0);
|
|
}
|
|
}
|
|
|
|
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
|
|
}
|
|
}
|