ExtraGrass Tiles are now use Cached HasSpecialPoint condition
This commit is contained in:
1 parent
d9bb3be6e2
commit
1cd8fcb686
4 files changed
+85
-56
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Drawing;
|
||||
|
||||
namespace CalamityMod.Systems
|
||||
{
|
||||
@@ -6,10 +7,22 @@ namespace CalamityMod.Systems
|
||||
{
|
||||
private byte Data;
|
||||
|
||||
/// <summary>
|
||||
/// Used for <see cref="TileBlendMergeSystem"/>
|
||||
/// </summary>
|
||||
public bool HasBlendMergeData
|
||||
{
|
||||
get => TileDataPacking.GetBit(Data, offset: 0);
|
||||
set => TileDataPacking.SetBit(value, Data, offset: 0);
|
||||
set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for Tiles that have complicated conditions for <see cref="TileDrawing.AddSpecialPoint(int, int, Terraria.GameContent.Drawing.TileDrawing.TileCounterType)"/>
|
||||
/// </summary>
|
||||
public bool HasSpecialPoint
|
||||
{
|
||||
get => TileDataPacking.GetBit(Data, offset: 1);
|
||||
set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Systems;
|
||||
using CalamityMod.Tiles.Crags.Lily;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
@@ -11,6 +13,8 @@ namespace CalamityMod.Tiles.Crags
|
||||
{
|
||||
public class ScorchedRemainsGrass : ModTile
|
||||
{
|
||||
public Asset<Texture2D> GrassTexture;
|
||||
|
||||
private const short subsheetWidth = 234;
|
||||
private const short subsheetHeight = 90;
|
||||
private int extraFrameHeight = 36;
|
||||
@@ -18,6 +22,8 @@ namespace CalamityMod.Tiles.Crags
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
GrassTexture = ModContent.Request<Texture2D>("CalamityMod/Tiles/Crags/CinderBlossomGrassGrass");
|
||||
|
||||
Main.tileSolid[Type] = true;
|
||||
Main.tileBlockLight[Type] = true;
|
||||
Main.tileLighted[Type] = true;
|
||||
@@ -119,6 +125,19 @@ namespace CalamityMod.Tiles.Crags
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type ||
|
||||
Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type)
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
|
||||
{
|
||||
bool isPlayerNear = WorldGen.PlayerLOS(i, j);
|
||||
@@ -133,26 +152,22 @@ namespace CalamityMod.Tiles.Crags
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type ||
|
||||
Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type)
|
||||
if (Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j);
|
||||
}
|
||||
catch { }
|
||||
Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
if (Main.tile[i, j].IsTileActuallyInvisible())
|
||||
Tile tile = Main.tile[i, j];
|
||||
if (tile.IsTileActuallyInvisible())
|
||||
return;
|
||||
|
||||
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
|
||||
Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j));
|
||||
Texture2D leaves = ModContent.Request<Texture2D>("CalamityMod/Tiles/Crags/CinderBlossomGrassGrass").Value;
|
||||
Color drawColour = CalamityUtils.ApplyPaint(tile.TileColor, Lighting.GetColor(i, j));
|
||||
Texture2D leaves = GrassTexture.Value;
|
||||
|
||||
DrawExtraTop(i, j, leaves, drawOffset, drawColour);
|
||||
DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour);
|
||||
|
||||
@@ -68,44 +68,33 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
{
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
|
||||
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type ||
|
||||
Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type)
|
||||
{
|
||||
try
|
||||
{
|
||||
Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j);
|
||||
}
|
||||
catch { }
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint = false;
|
||||
}
|
||||
}
|
||||
private Color GetDrawColour(int i, int j)
|
||||
|
||||
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
|
||||
{
|
||||
int colType = Main.tile[i, j].TileColor;
|
||||
Color paintCol = WorldGen.paintColor(colType);
|
||||
if (colType < 13)
|
||||
if (Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint)
|
||||
{
|
||||
paintCol.R = (byte)((paintCol.R / 2f) + 128);
|
||||
paintCol.G = (byte)((paintCol.G / 2f) + 128);
|
||||
paintCol.B = (byte)((paintCol.B / 2f) + 128);
|
||||
Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j);
|
||||
}
|
||||
if (colType == 29)
|
||||
{
|
||||
paintCol = Color.Black;
|
||||
}
|
||||
Color col = Lighting.GetColor(i, j);
|
||||
col.R = (byte)(paintCol.R / 255f * col.R);
|
||||
col.G = (byte)(paintCol.G / 255f * col.G);
|
||||
col.B = (byte)(paintCol.B / 255f * col.B);
|
||||
return col;
|
||||
}
|
||||
|
||||
public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
|
||||
Color drawColour = GetDrawColour(i, j);
|
||||
Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j));
|
||||
Texture2D leaves = GrassTexture.Value;
|
||||
|
||||
DrawExtraTop(i, j, leaves, drawOffset, drawColour);
|
||||
@@ -124,6 +113,7 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
g = 0f;
|
||||
b = 0.1f;
|
||||
}
|
||||
|
||||
public override void RandomUpdate(int i, int j)
|
||||
{
|
||||
Tile tile = Main.tile[i, j];
|
||||
|
||||
+33
-22
@@ -1,5 +1,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.Systems;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
@@ -11,10 +13,15 @@ namespace CalamityMod.Tiles
|
||||
{
|
||||
public class VernalSoil : ModTile
|
||||
{
|
||||
public Asset<Texture2D> GrassTexture;
|
||||
|
||||
private int extraFrameHeight = 36;
|
||||
private int extraFrameWidth = 90;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
GrassTexture = ModContent.Request<Texture2D>("CalamityMod/Tiles/VernicFernGrass");
|
||||
|
||||
Main.tileSolid[Type] = true;
|
||||
Main.tileBlockLight[Type] = false;
|
||||
TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Organic"]);
|
||||
@@ -32,16 +39,24 @@ namespace CalamityMod.Tiles
|
||||
this.RegisterBlendMergeWith(TileID.Mud);
|
||||
}
|
||||
|
||||
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type ||
|
||||
Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type)
|
||||
{
|
||||
try
|
||||
{
|
||||
Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j);
|
||||
}
|
||||
catch { }
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
|
||||
{
|
||||
if (Main.tile[i, j].Get<TileSpecialDrawData>().HasSpecialPoint)
|
||||
{
|
||||
Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,26 +178,22 @@ namespace CalamityMod.Tiles
|
||||
|
||||
public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
if (Main.tile[i, j].IsTileActuallyInvisible())
|
||||
Tile tile = Main.tile[i, j];
|
||||
if (tile.IsTileActuallyInvisible())
|
||||
return;
|
||||
|
||||
Tile uptile = Main.tile[i, j - 1];
|
||||
if (uptile.HasTile && uptile.IsTileFull())
|
||||
return;
|
||||
|
||||
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
||||
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
|
||||
Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j));
|
||||
Texture2D leaves = ModContent.Request<Texture2D>("CalamityMod/Tiles/VernicFernGrass").Value;
|
||||
Color drawColour = CalamityUtils.ApplyPaint(tile.TileColor, Lighting.GetColor(i, j));
|
||||
Texture2D leaves = GrassTexture.Value;
|
||||
|
||||
if (uptile.HasTile && uptile.IsTileFull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
DrawExtraTop(i, j, leaves, drawOffset, drawColour);
|
||||
//DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour);
|
||||
DrawExtraDrapes(i, j, leaves, drawOffset, drawColour);
|
||||
}
|
||||
DrawExtraTop(i, j, leaves, drawOffset, drawColour);
|
||||
//DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour);
|
||||
DrawExtraDrapes(i, j, leaves, drawOffset, drawColour);
|
||||
}
|
||||
|
||||
#region 'Extra Drapes' Drawing
|
||||
|
||||
Reference in new issue
Block a user