Simplified ModifyLight condition check in certain tiles
This commit is contained in:
1 parent
e12ec21a9f
commit
6d3d33fac5
4 files changed
+64
-44
No files matched your search
+45
-35
@@ -55,50 +55,60 @@ namespace CalamityMod.Tiles.Ores
|
||||
num = fail ? 1 : 3;
|
||||
}
|
||||
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
var tile = Main.tile[i, j];
|
||||
var frameX = tile.TileFrameX;
|
||||
var frameY = tile.TileFrameY;
|
||||
|
||||
bool hasFlowerInFrame = false;
|
||||
switch (frameX)
|
||||
{
|
||||
case 0 when frameY == 0:
|
||||
hasFlowerInFrame = true;
|
||||
break;
|
||||
|
||||
case 18 when frameY == 18:
|
||||
hasFlowerInFrame = true;
|
||||
break;
|
||||
|
||||
case 36 when frameY == 0 || frameY == 36:
|
||||
hasFlowerInFrame = true;
|
||||
break;
|
||||
|
||||
case 54 when frameY == 18:
|
||||
hasFlowerInFrame = true;
|
||||
break;
|
||||
}
|
||||
|
||||
tile.Get<TileSpecialDrawData>().Flag0 = hasFlowerInFrame;
|
||||
}
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
// The base green color glow
|
||||
r = 0.08f;
|
||||
g = 0.2f;
|
||||
b = 0.04f;
|
||||
var tile = Main.tile[i, j];
|
||||
var pos = new Vector2(tile.TileFrameX, tile.TileFrameY);
|
||||
|
||||
Vector2[] positionsFlower = new Vector2[]
|
||||
// Flower color glow
|
||||
if (Main.tile[i, j].Get<TileSpecialDrawData>().Flag0)
|
||||
{
|
||||
// Top row (always y = 0 on tile sheets)
|
||||
new Vector2(0, 0),
|
||||
new Vector2(36, 0),
|
||||
float timeScalar = Main.GameUpdateCount * 0.017f;
|
||||
float jDiv14 = j / 14f;
|
||||
float iDiv14 = i / 14f;
|
||||
float brightness = 0.7f;
|
||||
brightness *= (float)MathF.Sin(jDiv14 + timeScalar);
|
||||
brightness *= (float)MathF.Sin(iDiv14 + timeScalar);
|
||||
brightness += 0.3f;
|
||||
float flowerPosBrightnessR = 0.83f * brightness;
|
||||
float flowerPosBrightnessG = 0.16f * brightness;
|
||||
float flowerPosBrightnessB = 0.31f * brightness;
|
||||
|
||||
// Second row (always y = 18 on tile sheets)
|
||||
new Vector2(18, 18),
|
||||
new Vector2(54, 18),
|
||||
|
||||
// Third row (always y = 36 on tile sheets)
|
||||
new Vector2(36, 36),
|
||||
|
||||
};
|
||||
|
||||
foreach (var positionFlower in positionsFlower)
|
||||
{
|
||||
if (pos == positionFlower)
|
||||
{
|
||||
float timeScalar = Main.GameUpdateCount * 0.017f;
|
||||
float jDiv14 = j / 14f;
|
||||
float iDiv14 = i / 14f;
|
||||
float brightness = 0.7f;
|
||||
brightness *= (float)MathF.Sin(jDiv14 + timeScalar);
|
||||
brightness *= (float)MathF.Sin(iDiv14 + timeScalar);
|
||||
brightness += 0.3f;
|
||||
float flowerPosBrightnessR = 0.83f * brightness;
|
||||
float flowerPosBrightnessG = 0.16f * brightness;
|
||||
float flowerPosBrightnessB = 0.31f * brightness;
|
||||
|
||||
// Adjust brightness for flowers
|
||||
r = flowerPosBrightnessR;
|
||||
g = flowerPosBrightnessG;
|
||||
b = flowerPosBrightnessB;
|
||||
}
|
||||
// Adjust brightness for flowers
|
||||
r = flowerPosBrightnessR;
|
||||
g = flowerPosBrightnessG;
|
||||
b = flowerPosBrightnessB;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,11 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
|
||||
}
|
||||
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile;
|
||||
}
|
||||
|
||||
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
//IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's
|
||||
@@ -109,9 +114,7 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
// figure out if the tile is exposed - taken from the coral tiles
|
||||
if (Main.tile[i, j] == null ||
|
||||
(Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile))
|
||||
if (!Main.tile[i, j].Get<TileSpecialDrawData>().Flag0)
|
||||
return;
|
||||
|
||||
// get in-game lighting color at this tile
|
||||
|
||||
@@ -65,6 +65,11 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
|
||||
}
|
||||
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile;
|
||||
}
|
||||
|
||||
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
//IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's
|
||||
@@ -109,11 +114,10 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
// figure out if the tile is exposed - taken from the coral tiles
|
||||
if (Main.tile[i, j] == null ||
|
||||
(Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile))
|
||||
if (!Main.tile[i, j].Get<TileSpecialDrawData>().Flag0)
|
||||
return;
|
||||
|
||||
// get in-game lighting color at this tile
|
||||
|
||||
@@ -66,6 +66,11 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
|
||||
}
|
||||
|
||||
public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight)
|
||||
{
|
||||
Main.tile[i, j].Get<TileSpecialDrawData>().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile;
|
||||
}
|
||||
|
||||
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
||||
{
|
||||
//IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's
|
||||
@@ -107,9 +112,7 @@ namespace CalamityMod.Tiles.SunkenSea
|
||||
|
||||
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
||||
{
|
||||
// figure out if the tile is exposed - taken from the coral tiles
|
||||
if (Main.tile[i, j] == null ||
|
||||
(Main.tile[i - 1, j].HasTile && Main.tile[i + 1, j].HasTile && Main.tile[i, j - 1].HasTile && Main.tile[i, j + 1].HasTile))
|
||||
if (!Main.tile[i, j].Get<TileSpecialDrawData>().Flag0)
|
||||
return;
|
||||
|
||||
// get in-game lighting color at this tile
|
||||
|
||||
Reference in new issue
Block a user