Files
CalamityModPublic/Walls/AstralGrassWallSafe.cs
T
GinYuH ddcc4e7fc1 Astral Grass Wall consistency changes
Natural walls no longer drop when broken
Player placed walls are now valid for housing

Also some texture caching stuff for other walls
2024-08-21 19:04:50 -07:00

45 lines
1.8 KiB
C#

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Walls
{
public class AstralGrassWallSafe : ModWall
{
public override string Texture => "CalamityMod/Walls/AstralGrassWall";
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));
}
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 = AstralGrassWall.leafTexture.Value;
var rand = new Random(i + (j * 100000));
float offset = i * j % 6.28f + (float)rand.NextDouble() / 8f;
float sin = (float)Math.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;
}
}