Final merge commit of Flowaria's water and Lion8Cake's lava

Cherry-picked Liquid Edit PR / Cleaned up graphics code on tiles and such
This commit is contained in:
Cameron Ewell authored and GitHub committed 2024-09-05 19:11:18 -04:00
commit bcbd797d1a
150 files changed
+4366 -3747

No files matched your search

+34 -2
View File
@@ -5,10 +5,42 @@ namespace CalamityMod.Backgrounds
{
public class AstralUndergroundBGStyle : ModUndergroundBackgroundStyle
{
private int AUBG0;
private int AUBG1;
private int AUBG2;
private int AUBG3;
private int AUBG4_0;
private int AUBG4_1;
private int AUBG4_2;
public override void SetStaticDefaults()
{
if (Main.dedServ)
return;
AUBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG0");
AUBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG1");
AUBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG2");
AUBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG3");
AUBG4_0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG4_0");
AUBG4_1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG4_1");
AUBG4_2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG4_2");
}
public override void FillTextureArray(int[] textureSlots)
{
for (int i = 0; i <= 4; i++)
textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot(i == 4 ? "CalamityMod/Backgrounds/AstralUG" + i.ToString() + "_" + Main.hellBackStyle : "CalamityMod/Backgrounds/AstralUG" + i.ToString());
textureSlots[0] = AUBG0;
textureSlots[1] = AUBG1;
textureSlots[2] = AUBG2;
textureSlots[3] = AUBG3;
textureSlots[4] = Main.hellBackStyle switch
{
0 => AUBG4_0,
1 => AUBG4_1,
_ => AUBG4_2
};
}
}
}
+20 -5
View File
@@ -5,13 +5,28 @@ namespace CalamityMod.Backgrounds
{
public class SunkenSeaBGStyle : ModUndergroundBackgroundStyle
{
private int SSBG0;
private int SSBG1;
private int SSBG2;
private int SSBG3;
public override void SetStaticDefaults()
{
if (Main.dedServ)
return;
SSBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG0");
SSBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG1");
SSBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG2");
SSBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG3");
}
public override void FillTextureArray(int[] textureSlots)
{
for (int i = 0; i <= 3; i++)
{
textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel");
//textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG" + i.ToString());
}
textureSlots[0] = SSBG0;
textureSlots[1] = SSBG1;
textureSlots[2] = SSBG2;
textureSlots[3] = SSBG3;
}
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Placeables.FurnitureAbyss;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
@@ -46,7 +47,7 @@ namespace CalamityMod.BiomeManagers
}
// Temporarily use sulphur for now
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/SulphuricDepthsWater");
public override ModWaterStyle WaterStyle => SulphuricDepthsWater.Instance;
public override int BiomeTorchItemType => ModContent.ItemType<AbyssTorch>();
public override SceneEffectPriority Priority => SceneEffectPriority.Environment;
public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer1Icon";
+2 -1
View File
@@ -1,6 +1,7 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Placeables.FurnitureAbyss;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using Terraria;
using Terraria.ID;
@@ -20,7 +21,7 @@ namespace CalamityMod.BiomeManagers
}
}
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/UpperAbyssWater");
public override ModWaterStyle WaterStyle => UpperAbyssWater.Instance;
public override int BiomeTorchItemType => ModContent.ItemType<AbyssTorch>();
public override SceneEffectPriority Priority => SceneEffectPriority.Environment;
public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer2Icon";
+2 -1
View File
@@ -1,6 +1,7 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Placeables.FurnitureAbyss;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using Terraria;
using Terraria.ID;
@@ -20,7 +21,7 @@ namespace CalamityMod.BiomeManagers
}
}
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/MiddleAbyssWater");
public override ModWaterStyle WaterStyle => MiddleAbyssWater.Instance;
public override int BiomeTorchItemType => ModContent.ItemType<AbyssTorch>();
public override SceneEffectPriority Priority => SceneEffectPriority.Environment;
public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer3Icon";
+2 -1
View File
@@ -1,6 +1,7 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Placeables.FurnitureAbyss;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using Terraria;
using Terraria.ID;
@@ -20,7 +21,7 @@ namespace CalamityMod.BiomeManagers
}
}
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/VoidWater");
public override ModWaterStyle WaterStyle => VoidWater.Instance;
public override int BiomeTorchItemType => ModContent.ItemType<AbyssTorch>();
public override SceneEffectPriority Priority => SceneEffectPriority.Environment;
public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer4Icon";
+2 -1
View File
@@ -1,5 +1,6 @@
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Systems;
using CalamityMod.Waters;
using Terraria;
using Terraria.GameContent.Events;
using Terraria.ID;
@@ -9,7 +10,7 @@ namespace CalamityMod.BiomeManagers
{
public class AstralInfectionBiome : ModBiome
{
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/AstralWater");
public override ModWaterStyle WaterStyle => AstralWater.Instance;
public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle
{
+2 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Systems;
using CalamityMod.Waters;
using Terraria;
using Terraria.ModLoader;
@@ -6,7 +7,7 @@ namespace CalamityMod.BiomeManagers
{
public class FloralParadiseBiome : ModBiome
{
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/FloralParadiseWater");
public override ModWaterStyle WaterStyle => FloralParadiseWater.Instance;
public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find<ModUndergroundBackgroundStyle>("CalamityMod/FloralParadiseBGStyle");
public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh;
+2 -1
View File
@@ -3,6 +3,7 @@ using CalamityMod.CalPlayer;
using CalamityMod.Events;
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
@@ -14,7 +15,7 @@ namespace CalamityMod.BiomeManagers
{
public class SulphurousSeaBiome : ModBiome
{
public override ModWaterStyle WaterStyle => Main.zenithWorld ? ModContent.Find<ModWaterStyle>("CalamityMod/PissWater") : ModContent.Find<ModWaterStyle>("CalamityMod/SulphuricWater");
public override ModWaterStyle WaterStyle => Main.zenithWorld ? PissWater.Instance : SulphuricWater.Instance;
public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle => Main.zenithWorld ? ModContent.Find<ModSurfaceBackgroundStyle>("CalamityMod/PissSeaSurfaceBGStyle") : ModContent.Find<ModSurfaceBackgroundStyle>("CalamityMod/SulphurSeaSurfaceBGStyle");
public override int BiomeTorchItemType => ModContent.ItemType<SulphurousTorch>();
public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh;
+2 -1
View File
@@ -1,5 +1,6 @@
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Systems;
using CalamityMod.Waters;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,7 +9,7 @@ namespace CalamityMod.BiomeManagers
{
public class SunkenSeaBurrowsBiome : ModBiome
{
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/SunkenSeaBurrowsWater");
public override ModWaterStyle WaterStyle => SunkenSeaBurrowsWater.Instance;
public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find<ModUndergroundBackgroundStyle>("CalamityMod/SunkenSeaBGStyle");
public override int BiomeTorchItemType => ModContent.ItemType<NavyPrismTorch>();
public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight;
+2 -1
View File
@@ -1,5 +1,6 @@
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Systems;
using CalamityMod.Waters;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,7 +9,7 @@ namespace CalamityMod.BiomeManagers
{
public class SunkenSeaPolypBiome : ModBiome
{
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/SunkenSeaPolypWater");
public override ModWaterStyle WaterStyle => SunkenSeaPolypWater.Instance;
public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find<ModUndergroundBackgroundStyle>("CalamityMod/SunkenSeaBGStyle");
public override int BiomeTorchItemType => ModContent.ItemType<NavyPrismTorch>();
public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight;
+2 -1
View File
@@ -1,5 +1,6 @@
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Systems;
using CalamityMod.Waters;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,7 +9,7 @@ namespace CalamityMod.BiomeManagers
{
public class SunkenSeaReefsBiome : ModBiome
{
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/SunkenSeaReefsWater");
public override ModWaterStyle WaterStyle => SunkenSeaReefsWater.Instance;
public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find<ModUndergroundBackgroundStyle>("CalamityMod/SunkenSeaBGStyle");
public override int BiomeTorchItemType => ModContent.ItemType<NavyPrismTorch>();
public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight;
+2 -1
View File
@@ -1,5 +1,6 @@
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Systems;
using CalamityMod.Waters;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,7 +9,7 @@ namespace CalamityMod.BiomeManagers
{
public class SunkenSeaShoresBiome : ModBiome
{
public override ModWaterStyle WaterStyle => ModContent.Find<ModWaterStyle>("CalamityMod/SunkenSeaShoresWater");
public override ModWaterStyle WaterStyle => SunkenSeaShoresWater.Instance;
public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find<ModUndergroundBackgroundStyle>("CalamityMod/SunkenSeaBGStyle");
public override int BiomeTorchItemType => ModContent.ItemType<NavyPrismTorch>();
public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight;
+4
View File
@@ -45,11 +45,15 @@ using CalamityMod.Projectiles.Ranged;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Projectiles.Summon;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Systems;
using CalamityMod.Waters;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.GameContent.Liquid;
using Terraria.GameInput;
using Terraria.Graphics.Shaders;
using Terraria.ID;
+1 -7
View File
@@ -1020,13 +1020,7 @@ namespace CalamityMod.CalPlayer
}
}
// Extra DoT in the lava of the crags. Negated by Flame-licked Shell.
if (Player.lavaWet)
{
if (ZoneCalamity && !flameLickedShell)
Player.AddBuff(ModContent.BuffType<SearingLava>(), 2, false);
}
else
if (!Player.lavaWet)
{
if (Player.lavaImmune)
{
+33 -3
View File
@@ -51,6 +51,7 @@ using CalamityMod.Projectiles;
using CalamityMod.Projectiles.BaseProjectiles;
using CalamityMod.Schematics;
using CalamityMod.Skies;
using CalamityMod.Systems;
using CalamityMod.UI;
using CalamityMod.UI.CalamitasEnchants;
using CalamityMod.UI.DraedonsArsenal;
@@ -62,6 +63,7 @@ using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.Dyes;
using Terraria.GameContent.Liquid;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
@@ -114,6 +116,21 @@ namespace CalamityMod
// Probe glowmask
public static Asset<Texture2D> ProbeGlowmask;
// Holds the Texture Arrays for all the lava textures.
// These are used for the lava styles. They are seperate from Textureasset.Instance._liquidTexture as they will conflict with ModWaterStyle
// Can hold up to 255 lava styles (more than enough) (excluding the normal lava texture which is liquidTexture 1)
public struct LavaTextures
{
public static Asset<Texture2D>[] liquid = new Asset<Texture2D>[1];
public static Asset<Texture2D>[] slope = new Asset<Texture2D>[1];
public static Asset<Texture2D>[] block = new Asset<Texture2D>[1];
public static Asset<Texture2D>[] fall = new Asset<Texture2D>[1];
}
public static int LavaStyle;
public static float[] lavaAlpha = new float[1];
// Wall of Flesh glowmasks
public static Asset<Texture2D> WallOfFleshEyeGlowmask;
public static Asset<Texture2D> WallOfFleshDemonSickleTexture;
@@ -158,6 +175,7 @@ namespace CalamityMod
// Please keep this in alphabetical order so it's easy to read
internal Mod ancientsAwakened = null;
internal Mod biomeLava = null;
internal Mod bossChecklist = null;
internal Mod coloredDamageTypes = null;
internal Mod crouchMod = null;
@@ -192,6 +210,8 @@ namespace CalamityMod
ancientsAwakened = null;
ModLoader.TryGetMod("AAMod", out ancientsAwakened);
biomeLava = null;
ModLoader.TryGetMod("BiomeLava", out biomeLava);
bossChecklist = null;
ModLoader.TryGetMod("BossChecklist", out bossChecklist);
coloredDamageTypes = null;
@@ -265,7 +285,11 @@ namespace CalamityMod
SetupVanillaDR();
SetupBossKillTimes();
SchematicManager.Load();
CustomLavaManagement.Load();
//lava
LavaRendering.instance = new LavaRendering();
WeakReferenceSupport.LavaStytleToBiomeLava();
Attunement.Load();
BalancingChangesManager.Load();
BaseIdleHoldoutProjectile.LoadAll();
@@ -300,6 +324,13 @@ namespace CalamityMod
DestroyerGlowmasks[1] = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VanillaBossGlowmasks/DestroyerBodyGlow", AssetRequestMode.AsyncLoad);
DestroyerGlowmasks[2] = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VanillaBossGlowmasks/DestroyerTailGlow", AssetRequestMode.AsyncLoad);
// Lava Texture
LavaTextures.liquid[0] = LiquidRenderer.Instance._liquidTextures[1];
LavaTextures.slope[0] = TextureAssets.LiquidSlope[1];
LavaTextures.block[0] = TextureAssets.Liquid[1];
var waterfallTexture = (Asset<Texture2D>[])typeof(WaterfallManager).GetField("waterfallTexture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Main.instance.waterfallManager);
LavaTextures.fall[0] = waterfallTexture[1];
// Probe glowmask
ProbeGlowmask = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/VanillaBossGlowmasks/ProbeGlow", AssetRequestMode.AsyncLoad);
@@ -424,6 +455,7 @@ namespace CalamityMod
vcmm = null;
ancientsAwakened = null;
biomeLava = null;
bossChecklist = null;
coloredDamageTypes = null;
crouchMod = null;
@@ -455,13 +487,11 @@ namespace CalamityMod
NPCStats.Unload();
CalamityGlobalItem.UnloadTweaks();
CalamityGlobalProjectile.UnloadTweaks();
FramedGlowMask.UnloadTexCache();
PopupGUIManager.UnloadGUIs();
InvasionProgressUIManager.UnloadGUIs();
BossRushEvent.Unload();
SchematicManager.Unload();
CustomLavaManagement.Unload();
CooldownRegistry.Unload();
PlayerDashManager.Unload();
+9
View File
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class AstralSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

+178
View File
@@ -0,0 +1,178 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics.PackedVector;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class CragsLavaSplash : ModDust
{
public override void OnSpawn(Dust dust)
{
dust.velocity *= 0.1f;
dust.velocity.Y = -0.5f;
}
public override bool Update(Dust dust)
{
if (dust.scale > 10f)
{
dust.active = false;
}
Dust.lavaBubbles++;
dust.position += dust.velocity;
if (!dust.noGravity)
{
dust.velocity.Y += 0.1f;
}
if (dust.noGravity)
{
dust.scale += 0.03f;
if (dust.scale < 1f)
{
dust.velocity.Y += 0.075f;
}
dust.velocity.X *= 1.08f;
if (dust.velocity.X > 0f)
{
dust.rotation += 0.01f;
}
else
{
dust.rotation -= 0.01f;
}
float num109 = dust.scale * 0.6f;
if (num109 > 1f)
{
num109 = 1f;
}
Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f + 1f), num109 * (2.5f / 4), num109 * (1.1f / 4), num109 * (0.1f / 4));
}
else
{
if (!Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y - 8f), 4, 4))
{
dust.scale = 0f;
}
else
{
dust.alpha += Main.rand.Next(2);
if (dust.alpha > 255)
{
dust.scale = 0f;
}
dust.velocity.Y = -0.5f;
dust.alpha++;
dust.scale -= 0.01f;
dust.velocity.Y = -0.2f;
dust.velocity.X += (float)Main.rand.Next(-10, 10) * 0.002f;
if ((double)dust.velocity.X < -0.25)
{
dust.velocity.X = -0.25f;
}
if ((double)dust.velocity.X > 0.25)
{
dust.velocity.X = 0.25f;
}
}
float num3 = dust.scale * 0.3f + 0.4f;
if (num3 > 1f)
{
num3 = 1f;
}
Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num3 * (2.5f / 4), num3 * (1.1f / 4), num3 * (0.1f / 4));
}
dust.rotation += dust.velocity.X * 0.5f;
if (dust.fadeIn > 0f && dust.fadeIn < 100f)
{
dust.scale += 0.03f;
if (dust.scale > dust.fadeIn)
{
dust.fadeIn = 0f;
}
}
dust.scale -= 0.01f;
if (dust.noGravity)
{
dust.velocity *= 0.92f;
if (dust.fadeIn == 0f)
{
dust.scale -= 0.04f;
}
}
if (dust.position.Y > Main.screenPosition.Y + (float)Main.screenHeight)
{
dust.active = false;
}
float num17 = 0.1f;
if ((double)Dust.dCount == 0.5)
{
dust.scale -= 0.001f;
}
if ((double)Dust.dCount == 0.6)
{
dust.scale -= 0.0025f;
}
if ((double)Dust.dCount == 0.7)
{
dust.scale -= 0.005f;
}
if ((double)Dust.dCount == 0.8)
{
dust.scale -= 0.01f;
}
if ((double)Dust.dCount == 0.9)
{
dust.scale -= 0.02f;
}
if ((double)Dust.dCount == 0.5)
{
num17 = 0.11f;
}
if ((double)Dust.dCount == 0.6)
{
num17 = 0.13f;
}
if ((double)Dust.dCount == 0.7)
{
num17 = 0.16f;
}
if ((double)Dust.dCount == 0.8)
{
num17 = 0.22f;
}
if ((double)Dust.dCount == 0.9)
{
num17 = 0.25f;
}
if (dust.scale < num17)
{
dust.active = false;
}
return false;
}
public override Color? GetAlpha(Dust dust, Color lightColor)
{
float num = (float)(255 - dust.alpha) / 255f;
int num4;
int num3;
int num2;
num = (num + 3f) / 4f;
num4 = (int)((int)lightColor.R * num);
num3 = (int)((int)lightColor.G * num);
num2 = (int)((int)lightColor.B * num);
int num6 = lightColor.A - dust.alpha;
if (num6 < 0)
{
num6 = 0;
}
if (num6 > 255)
{
num6 = 255;
}
return new Color(num4, num3, num2, num6);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

+9
View File
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class MiddleAbyssSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

+20
View File
@@ -0,0 +1,20 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public abstract class SplashDust : ModDust
{
public override void SetStaticDefaults()
{
UpdateType = 33;
}
public override void OnSpawn(Dust dust)
{
dust.alpha = 170;
dust.velocity *= 0.5f;
dust.velocity.Y += 1f;
}
}
}
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class SulphuricDepthsSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

+9
View File
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class SulphuricSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

+9
View File
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class SunkenSeaSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

+9
View File
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class UpperAbyssSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

+9
View File
@@ -0,0 +1,9 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts.WaterSplash
{
public class VoidSplash : SplashDust
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

-167
View File
@@ -1,167 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.GameContent.Shaders;
using Terraria.Graphics.Effects;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Gores
{
public class AstralWaterDroplet : ModGore
{
public override void SetStaticDefaults()
{
ChildSafety.SafeGore[Type] = true;
}
public override void OnSpawn(Gore gore, IEntitySource source)
{
gore.numFrames = 15;
gore.behindTiles = true;
gore.timeLeft = Gore.goreTime * 3;
}
public override bool Update(Gore gore)
{
if ((double)gore.position.Y < Main.worldSurface * 16.0 + 8.0)
{
gore.alpha = 0;
}
else
{
gore.alpha = 100;
}
int goreFrameDelay = 4;
gore.frameCounter++;
if (gore.frame <= 4)
{
int goreXPos = (int)(gore.position.X / 16f);
int goreYPos = (int)(gore.position.Y / 16f) - 1;
if (WorldGen.InWorld(goreXPos, goreYPos, 0) && !Main.tile[goreXPos, goreYPos].HasTile)
{
gore.active = false;
}
if (gore.frame == 0)
{
goreFrameDelay = 24 + Main.rand.Next(256);
}
if (gore.frame == 1)
{
goreFrameDelay = 24 + Main.rand.Next(256);
}
if (gore.frame == 2)
{
goreFrameDelay = 24 + Main.rand.Next(256);
}
if (gore.frame == 3)
{
goreFrameDelay = 24 + Main.rand.Next(96);
}
if (gore.frame == 5)
{
goreFrameDelay = 16 + Main.rand.Next(64);
}
if ((int)gore.frameCounter >= goreFrameDelay)
{
gore.frameCounter = 0;
gore.frame += 1;
if (gore.frame == 5 && Main.netMode != NetmodeID.Server)
{
int astralWater = Gore.NewGore(new EntitySource_Misc("0"), gore.position, gore.velocity, gore.type, 1f);
Main.gore[astralWater].frame = 9;
Main.gore[astralWater].velocity *= 0f;
}
}
}
else if (gore.frame <= 6)
{
goreFrameDelay = 8;
if ((int)gore.frameCounter >= goreFrameDelay)
{
gore.frameCounter = 0;
gore.frame += 1;
if (gore.frame == 7)
{
gore.active = false;
}
}
}
else if (gore.frame <= 9)
{
goreFrameDelay = 6;
gore.velocity.Y += 0.2f;
if ((double)gore.velocity.Y < 0.5)
{
gore.velocity.Y = 0.5f;
}
if (gore.velocity.Y > 12f)
{
gore.velocity.Y = 12f;
}
if ((int)gore.frameCounter >= goreFrameDelay)
{
gore.frameCounter = 0;
gore.frame += 1;
}
if (gore.frame > 9)
{
gore.frame = 7;
}
}
else
{
gore.velocity.Y += 0.1f;
if ((int)gore.frameCounter >= goreFrameDelay)
{
gore.frameCounter = 0;
gore.frame += 1;
}
gore.velocity *= 0f;
if (gore.frame > 14)
{
gore.active = false;
}
}
Vector2 goreVelCheck = gore.velocity;
gore.velocity = Collision.TileCollision(gore.position, gore.velocity, 16, 14, false, false, 1);
if (gore.velocity != goreVelCheck)
{
if (gore.frame < 10)
{
gore.frame = 10;
gore.frameCounter = 0;
if (gore.type != 716 && gore.type != 717 && gore.type != 943)
{
SoundEngine.PlaySound(SoundID.Drip, gore.position + Vector2.One * 8);
}
}
}
else if (Collision.WetCollision(gore.position + gore.velocity, 16, 14))
{
if (gore.frame < 10)
{
gore.frame = 10;
gore.frameCounter = 0;
if (gore.type != 716 && gore.type != 717 && gore.type != 943)
{
SoundEngine.PlaySound(SoundID.Drip, gore.position + Vector2.One * 8);
}
((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(gore.position + new Vector2(8f, 8f), 1f, RippleShape.Square, 0f);
}
int goreTileX = (int)(gore.position.X + 8f) / 16;
int goreTileY = (int)(gore.position.Y + 14f) / 16;
if (Main.tile[goreTileX, goreTileY] != null && Main.tile[goreTileX, goreTileY].LiquidAmount > 0)
{
gore.velocity *= 0f;
gore.position.Y = (float)(goreTileY * 16 - (int)(Main.tile[goreTileX, goreTileY].LiquidAmount / 16));
}
}
return true;
}
}
}
+6
View File
@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class AstralWaterDroplet : LiquidDropletGore
{
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 696 B

+11
View File
@@ -0,0 +1,11 @@
using Microsoft.Xna.Framework;
namespace CalamityMod.Gores.WaterDroplet
{
public class CragsLavaDroplet : LiquidDropletGore
{
public override bool lavaDroplet => true;
public override Vector3 lavaColor => new Vector3(2.5f, 1.1f, 0.1f);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

+201
View File
@@ -0,0 +1,201 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Gores.WaterDroplet
{
public abstract class LiquidDropletGore : ModGore
{
public virtual bool lavaDroplet => false;
public virtual Vector3 lavaColor => new Vector3(0, 0, 0);
public override void SetStaticDefaults()
{
ChildSafety.SafeGore[Type] = true;
}
public override void OnSpawn(Gore gore, IEntitySource source)
{
gore.numFrames = 15;
gore.behindTiles = true;
gore.timeLeft = Gore.goreTime * 3;
}
public override bool Update(Gore gore)
{
gore.alpha = gore.position.Y < (Main.worldSurface * 16.0) + 8.0
? 0
: 100;
int frameDuration = 4;
gore.frameCounter += 1;
if (gore.frame <= 4)
{
int tileX = (int)(gore.position.X / 16f);
int tileY = (int)(gore.position.Y / 16f) - 1;
if (WorldGen.InWorld(tileX, tileY) && !Main.tile[tileX, tileY].HasTile)
{
gore.active = false;
}
if (gore.frame == 0 || gore.frame == 1 || gore.frame == 2)
{
frameDuration = 24 + Main.rand.Next(256);
}
if (gore.frame == 3)
{
frameDuration = 24 + Main.rand.Next(96);
}
if (gore.frameCounter >= frameDuration)
{
gore.frameCounter = 0;
gore.frame += 1;
if (gore.frame == 5)
{
int droplet = Gore.NewGore(new EntitySource_Misc("0"), gore.position, gore.velocity, gore.type);
Main.gore[droplet].frame = 9;
Main.gore[droplet].velocity *= 0f;
}
}
}
else if (gore.frame <= 6)
{
frameDuration = 8;
if (gore.frameCounter >= frameDuration)
{
gore.frameCounter = 0;
gore.frame += 1;
if (gore.frame == 7)
{
gore.active = false;
}
}
}
else if (gore.frame <= 9)
{
frameDuration = 6;
gore.velocity.Y += 0.2f;
if (gore.velocity.Y < 0.5f)
{
gore.velocity.Y = 0.5f;
}
if (gore.velocity.Y > 12f)
{
gore.velocity.Y = 12f;
}
if (gore.frameCounter >= frameDuration)
{
gore.frameCounter = 0;
gore.frame += 1;
}
if (gore.frame > 9)
{
gore.frame = 7;
}
}
else
{
gore.velocity.Y += 0.1f;
if (gore.frameCounter >= frameDuration)
{
gore.frameCounter = 0;
gore.frame += 1;
}
gore.velocity *= 0f;
if (gore.frame > 14)
{
gore.active = false;
}
}
if (lavaDroplet)
{
float num24 = 1f;
float num25 = 1f;
float num26 = 1f;
float num27 = 0.6f;
num27 *= gore.frame switch
{
0 => 0.1f,
1 => 0.2f,
2 => 0.3f,
3 => 0.4f,
4 => 0.5f,
5 => 0.4f,
6 => 0.2f,
7 => 0.5f,
8 => 0.5f,
9 => 0.5f,
10 => 0.5f,
11 => 0.4f,
12 => 0.3f,
13 => 0.2f,
14 => 0.1f,
_ => 0.0f,
};
num24 = (lavaColor.X / 4) * num27; //R
num25 = (lavaColor.Y / 4) * num27; //G
num26 = (lavaColor.Z / 4) * num27; //B
Lighting.AddLight(gore.position + new Vector2(8f, 8f), num24, num25, num26);
}
Vector2 oldVelocity = gore.velocity;
gore.velocity = Collision.TileCollision(gore.position, gore.velocity, 16, 14);
if (gore.velocity != oldVelocity)
{
if (gore.frame < 10)
{
gore.frame = 10;
gore.frameCounter = 0;
if (!lavaDroplet)
{
SoundEngine.PlaySound(SoundID.Drip, gore.position + new Vector2(8, 8));
}
}
}
else if (Collision.WetCollision(gore.position + gore.velocity, 16, 14))
{
if (gore.frame < 10)
{
gore.frame = 10;
gore.frameCounter = 0;
if (!lavaDroplet)
{
SoundEngine.PlaySound(SoundID.Drip, gore.position + new Vector2(8, 8));
}
}
int tileX = (int)(gore.position.X + 8f) / 16;
int tileY = (int)(gore.position.Y + 14f) / 16;
if (Main.tile[tileX, tileY] != null && Main.tile[tileX, tileY].LiquidAmount > 0)
{
gore.velocity *= 0f;
gore.position.Y = (tileY * 16) - (Main.tile[tileX, tileY].LiquidAmount / 16);
}
}
gore.position += gore.velocity;
return false;
}
public override Color? GetAlpha(Gore gore, Color lightColor)
{
if (lavaDroplet)
{
return new Color(255, 255, 255, 200);
}
return null;
}
}
}
@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class MiddleAbyssWaterDroplet : LiquidDropletGore
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class SulphuricDepthsWaterDroplet : LiquidDropletGore
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class SulphuricWaterDroplet : LiquidDropletGore
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class SunkenSeaWaterDroplet : LiquidDropletGore
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class UpperAbyssWaterDroplet : LiquidDropletGore
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

+6
View File
@@ -0,0 +1,6 @@
namespace CalamityMod.Gores.WaterDroplet
{
public class VoidWaterDroplet : LiquidDropletGore
{
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

+40 -6
View File
@@ -44,12 +44,6 @@ namespace CalamityMod.ILEditing
On_Main.DrawCursor += UseCoolFireCursorEffect;
On_Main.SortDrawCacheWorms += DrawFusableParticles;
On_Main.DrawInfernoRings += DrawForegroundParticles;
On_TileDrawing.DrawPartialLiquid += DrawCustomLava;
On_WaterfallManager.DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects += DrawCustomLavafalls;
On_Main.RenderWater += CacheLavaStyle;
IL_LiquidRenderer.DrawNormalLiquids += ChangeWaterQuadColors;
IL_Main.oldDrawWater += DrawCustomLava3;
On_TileLightScanner.GetTileLight += MakeSulphSeaWaterBetter;
On_TileDrawing.PreDrawTiles += ClearForegroundStuff;
On_TileDrawing.Draw += ClearTilePings;
On_CommonCode.ModifyItemDropFromNPC += ColorBlightedGel;
@@ -90,10 +84,50 @@ namespace CalamityMod.ILEditing
On_NPC.SpawnBoss += TripletsSpawnTextOverride;
On_NPC.DoDeathEvents_BeforeLoot += PreventFoveanatorDefeatMessageIfNotKilledLast;
On_NPC.DoDeathEvents_CelebrateBossDeath += TripletsDefeatTextOverride;
On_TileDrawing.DrawSingleTile += GlowMaskTileRender;
// Mana Burn (Chaos Stone) and Chalice of the Blood God
IL_Player.ApplyLifeAndOrMana += ManaSicknessAndChaliceBufferHeal;
//LavaStyles
if (CalamityMod.Instance.biomeLava == null)
{
//Rendering/Drawing
IL_Main.DoDraw += DoDrawLavas;
IL_Main.RenderWater += RenderLavas;
IL_Main.RenderBackground += RenderLavaBackgrounds;
IL_Main.DrawCapture += DrawLavatoCapture;
IL_TileDrawing.Draw += AddTileLiquidDrawing;
//Blocking
IL_LiquidRenderer.DrawNormalLiquids += BlockLavaDrawing;
On_TileDrawing.DrawTile_LiquidBehindTile += BlockLavaDrawingForSlopes;
On_TileDrawing.DrawPartialLiquid += BlockLavaDrawingForSlopes2;
On_WaterfallManager.DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects += LavafallRemover;
IL_Main.oldDrawWater += BlockRetroLightingLava;
//Replacing
IL_LiquidRenderer.InternalPrepareDraw += LavaBubbleReplacer;
IL_TileDrawing.EmitLiquidDrops += LavaDropletReplacer;
IL_NPC.Collision_WaterCollision += SplashEntityLava;
IL_Projectile.Update += SplashEntityLava;
IL_Item.MoveInWorld += SplashEntityLava;
IL_Player.Update += SplashEntityLava;
IL_Player.Update += PlayerDebuffEdit;
//Other
On_WaterfallManager.Draw += LavaFallRedrawer;
On_WaterfallManager.StylizeColor += WaterfallGlowmaskEditor;
//Waterfall light
On_WaterfallManager.AddLight += LavafallLightEditor;
}
// Liquid Lighting and alpha (Liquid Viusuals)
IL_TileLightScanner.GetTileLight += ApplyLiquidEmit;
IL_LiquidRenderer.DrawNormalLiquids += LiquidDrawColors; //Liquid Light
IL_TileDrawing.DrawTile_LiquidBehindTile += LiquidSlopeDrawColors;
// Custom grappling
On_Player.GrappleMovement += CustomGrappleMovementCheck;
On_Player.UpdatePettingAnimal += CustomGrapplePreDefaultMovement;
+15 -74
View File
@@ -64,77 +64,8 @@ namespace CalamityMod.ILEditing
SoundEngine.PlaySound(SoundID.DoorClosed, new Vector2(doorX * 16, doorY * 16));
return true;
}
private static Texture2D SelectLavaTexture(Texture2D initialTexture, LiquidTileType type)
{
// Use the initial texture if it isn't lava.
if (initialTexture != CustomLavaManagement.LavaTexture &&
initialTexture != CustomLavaManagement.LavaBlockTexture &&
initialTexture != CustomLavaManagement.LavaSlopeTexture)
return initialTexture;
if (cachedLavaStyle == default)
return initialTexture;
switch (type)
{
case LiquidTileType.Block:
return cachedLavaStyle.BlockTexture;
case LiquidTileType.Waterflow:
return cachedLavaStyle.LavaTexture;
case LiquidTileType.Slope:
return cachedLavaStyle.SlopeTexture;
}
return initialTexture;
}
private static VertexColors SelectLavaQuadColor(Texture2D initialTexture, ref VertexColors initialColor, bool forceTrue = false)
{
// We should handle the 'forceTrue' flag at this level to prevent us from checking the same thing four times.
if (!forceTrue)
{
if (initialTexture != CustomLavaManagement.LavaTexture &&
initialTexture != CustomLavaManagement.LavaBlockTexture &&
initialTexture != CustomLavaManagement.LavaSlopeTexture)
return initialColor;
}
// No lava style to draw? Then skip.
if (cachedLavaStyle == default)
return initialColor;
cachedLavaStyle.SelectLightColor(ref initialColor.TopLeftColor);
cachedLavaStyle.SelectLightColor(ref initialColor.TopRightColor);
cachedLavaStyle.SelectLightColor(ref initialColor.BottomLeftColor);
cachedLavaStyle.SelectLightColor(ref initialColor.BottomRightColor);
return initialColor;
}
private static Color SelectLavaColor(Texture2D initialTexture, Color initialLightColor, bool forceTrue = false)
{
// Use the initial color if it isn't lava.
if (!forceTrue)
{
if (initialTexture != CustomLavaManagement.LavaTexture &&
initialTexture != CustomLavaManagement.LavaBlockTexture &&
initialTexture != CustomLavaManagement.LavaSlopeTexture)
return initialLightColor;
}
foreach (CustomLavaStyle lavaStyle in CustomLavaManagement.CustomLavaStyles)
{
if (lavaStyle.ChooseLavaStyle())
{
lavaStyle.SelectLightColor(ref initialLightColor);
return initialLightColor;
}
}
return initialLightColor;
}
private static void SelectSulphuricWaterColor(int x, int y, ref VertexColors initialColor)
public static void SelectSulphuricWaterColor(int x, int y, ref VertexColors initialColor, bool isSlope)
{
if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1)
{
@@ -177,10 +108,20 @@ namespace CalamityMod.ILEditing
}
}
initialColor.TopLeftColor *= 0.4f;
initialColor.TopRightColor *= 0.4f;
initialColor.BottomLeftColor *= 0.4f;
initialColor.BottomRightColor *= 0.4f;
if (isSlope)
{
initialColor.TopLeftColor *= 1f / 3;
initialColor.TopRightColor *= 1f / 3;
initialColor.BottomLeftColor *= 1f / 3;
initialColor.BottomRightColor *= 1f / 3;
}
else
{
initialColor.TopLeftColor *= 0.4f;
initialColor.TopRightColor *= 0.4f;
initialColor.BottomLeftColor *= 0.4f;
initialColor.BottomRightColor *= 0.4f;
}
}
public static void DumpToLog(ILContext il) => CalamityMod.Instance.Logger.Debug(il.ToString());
+561 -324
View File
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using CalamityMod.Balancing;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.CalPlayer;
@@ -22,6 +24,7 @@ using CalamityMod.Particles;
using CalamityMod.Projectiles;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Systems;
using CalamityMod.Tiles;
using CalamityMod.Tiles.Abyss;
using CalamityMod.Walls;
using CalamityMod.Waterfalls;
@@ -43,6 +46,7 @@ using Terraria.GameContent.Liquid;
using Terraria.GameContent.UI.Elements;
using Terraria.GameInput;
using Terraria.Graphics;
using Terraria.Graphics.Capture;
using Terraria.Graphics.Light;
using Terraria.Graphics.Shaders;
using Terraria.ID;
@@ -51,6 +55,7 @@ using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.UI.Gamepad;
using static Terraria.WaterfallManager;
namespace CalamityMod.ILEditing
{
@@ -62,14 +67,12 @@ namespace CalamityMod.ILEditing
private static int aLabDoorClosed = -1;
private static int exoDoorOpen = -1;
private static int exoDoorClosed = -1;
// Cached for use in ChangeWaterQuadColors.
private static CustomLavaStyle cachedLavaStyle = default;
// Holds the vanilla game function which spawns town NPCs, wrapped in a delegate for reflection purposes.
// This function is (optionally) invoked manually in an IL edit to enable NPCs to spawn at night.
private static Action VanillaSpawnTownNPCs;
private static readonly MethodInfo textureGetValueMethod = typeof(Asset<Texture2D>).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance);
//private static readonly MethodInfo textureGetValueMethod = typeof(Asset<Texture2D>).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance);
public static event Func<VertexColors, int, Point, VertexColors> ExtraColorChangeConditions;
@@ -828,365 +831,542 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Custom Lava Visuals
#region Lava Style Edits
//Nine Layers of Hell brought to you by LIONEIGHTCAKE!!
//All new liquid rendering for lava can be found in Systems/LavaRendering.cs
private static void CacheLavaStyle(Terraria.On_Main.orig_RenderWater orig, Main self)
{
// Immediately cache the lava drawing style.
// This will pay off in SPADES when we go to draw the tiles.
foreach (CustomLavaStyle style in CustomLavaManagement.CustomLavaStyles)
{
if (style.ChooseLavaStyle())
{
cachedLavaStyle = style;
orig(self);
return;
}
}
//To save on time, a LOT of the edits are from the BiomeLava mod (owned by myself, lion8cake). Obv every edit has been changed to reflect
//Calamity's style of IL edits and to remove any unnessesary edits not relivant to calamity. In the loading of the detours and edits
//BiomeLava is a check for whether they load or not. If BiomeLava is active all ModLavaStyles will be turned into ModCalls for BiomeLava.
cachedLavaStyle = default;
orig(self);
}
private static void DrawCustomLava(Terraria.GameContent.Drawing.On_TileDrawing.orig_DrawPartialLiquid orig, TileDrawing self, bool behindBlocks, Tile tileCache, ref Vector2 position, ref Rectangle liquidSize, int liquidType, ref VertexColors colors)
{
if (liquidType != 1)
{
orig(self, behindBlocks, tileCache, ref position, ref liquidSize, liquidType, ref colors);
return;
}
int slope = (int)tileCache.Slope;
colors = SelectLavaQuadColor(TextureAssets.LiquidSlope[liquidType].Value, ref colors, true);
if (!TileID.Sets.BlocksWaterDrawingBehindSelf[tileCache.TileType] || behindBlocks || slope == 0)
{
Texture2D liquidTexture = SelectLavaTexture(liquidType == 1 ? CustomLavaManagement.LavaBlockTexture : TextureAssets.Liquid[liquidType].Value, LiquidTileType.Block);
Main.tileBatch.Draw(liquidTexture, position, liquidSize, colors, default(Vector2), 1f, SpriteEffects.None);
return;
}
Texture2D slopeTexture = SelectLavaTexture(liquidType == 1 ? CustomLavaManagement.LavaSlopeTexture : TextureAssets.LiquidSlope[liquidType].Value, LiquidTileType.Slope);
liquidSize.X += 18 * (slope - 1);
switch (slope)
{
case 1:
Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None);
break;
case 2:
Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None);
break;
case 3:
Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None);
break;
case 4:
Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None);
break;
}
}
private static void ChangeWaterQuadColors(ILContext il)
#region Lava Rendering
private static void DoDrawLavas(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(c => c.MatchLdfld<LiquidRenderer>("_liquidTextures")))
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdsfld<Main>("drawToScreen"), i => i.MatchBrfalse(out _), i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchCall<Main>("DrawWaters")))
{
LogFailure("Custom Lava Drawing", "Could not locate the liquid texture array load.");
LogFailure("DoDraw Lava", "Could not locate the drawing of Background Waters");
return;
}
// Move to the end of the get_Value() call and then use the resulting texture to check if a new one should replace it.
// Adding to the index directly would seem like a simple, direct way of achieving this since the operation is incredibly light, but
// it also unsafe due to the potential for NOP operations to appear.
if (!cursor.TryGotoNext(MoveType.After, c => c.MatchCallvirt(textureGetValueMethod)))
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLavas(isBackground: true);
});
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdsfld<Main>("drawToScreen"), i => i.MatchBrfalse(out _), i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchCall<Main>("DrawWaters")))
{
LogFailure("Custom Lava Drawing", "Could not locate the liquid texture Value call.");
LogFailure("DoDraw Lava", "Could not locate the drawing of Waters");
return;
}
cursor.EmitDelegate<Func<Texture2D, Texture2D>>(initialTexture => SelectLavaTexture(initialTexture, LiquidTileType.Waterflow));
if (!cursor.TryGotoNext(MoveType.After, c => c.MatchLdloc(9)))
{
LogFailure("Custom Lava Drawing", "Could not locate the liquid light color.");
return;
}
// Pass the texture in so that the method can ensure it is not messing around with non-lava textures.
cursor.Emit(OpCodes.Ldarg_0);
cursor.Emit(OpCodes.Ldfld, typeof(LiquidRenderer).GetField("_liquidTextures"));
cursor.Emit(OpCodes.Ldloc, 8);
cursor.Emit(OpCodes.Ldelem_Ref);
cursor.Emit(OpCodes.Ldloc, 8);
cursor.Emit(OpCodes.Ldloc, 3);
cursor.Emit(OpCodes.Ldloc, 4);
// Caching these values can save a LOT of overhead at runtime.
ModWaterStyle basaltWater = ModContent.GetInstance<BasaltGullyWater>();
ModWaterStyle burrowsWater = ModContent.GetInstance<SunkenSeaBurrowsWater>();
ModWaterStyle polypWater = ModContent.GetInstance<SunkenSeaPolypWater>();
ModWaterStyle reefsWater = ModContent.GetInstance<SunkenSeaReefsWater>();
ModWaterStyle shoresWater = ModContent.GetInstance<SunkenSeaShoresWater>();
ModWaterStyle sulphuricWater = ModContent.GetInstance<SulphuricWater>();
ModWaterStyle sulphuricDepthsWater = ModContent.GetInstance<SulphuricDepthsWater>();
ModWaterStyle upperAbyssWater = ModContent.GetInstance<UpperAbyssWater>();
ModWaterStyle middleAbyssWater = ModContent.GetInstance<MiddleAbyssWater>();
ModWaterStyle voidWater = ModContent.GetInstance<VoidWater>();
cursor.EmitDelegate<Func<VertexColors, Texture2D, int, int, int, VertexColors>>((initialColor, initialTexture, liquidType, x, y) =>
{
// Don't bother changing the color if the cached drawing style is null.
if (cachedLavaStyle != default)
{
initialColor = SelectLavaQuadColor(initialTexture, ref initialColor, liquidType == 1);
}
if (liquidType == burrowsWater.Slot ||
liquidType == basaltWater.Slot ||
liquidType == polypWater.Slot ||
liquidType == shoresWater.Slot ||
liquidType == reefsWater.Slot ||
liquidType == sulphuricWater.Slot ||
liquidType == sulphuricDepthsWater.Slot ||
liquidType == upperAbyssWater.Slot ||
liquidType == middleAbyssWater.Slot ||
liquidType == voidWater.Slot)
{
SelectSulphuricWaterColor(x, y, ref initialColor);
}
// Apply any extra color conditions.
initialColor = ExtraColorChangeConditions?.Invoke(initialColor, liquidType, new(x, y)) ?? initialColor;
return initialColor;
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLavas();
});
}
private static void DrawCustomLava3(ILContext il)
private static void RenderLavas(ILContext il)
{
ILCursor cursor = new ILCursor(il);
// Locate the local index for the liquid color and tile coordinates.
int xCoordLocalIndex = 0;
int yCoordLocalIndex = 0;
int liquidColorLocalIndex = 0;
MethodInfo lightingGetColorMethod = typeof(Lighting).GetMethod("GetColor", new Type[] { typeof(int), typeof(int) });
if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchCallOrCallvirt(lightingGetColorMethod)))
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchCall<Main>("DrawWaters")))
{
LogFailure("Custom Lava Drawing", "Could not lighting GetColor call.");
LogFailure("Render Lava", "Could not locate the drawing of Waters");
return;
}
if (!cursor.TryGotoPrev(c => c.MatchLdloc(out xCoordLocalIndex)))
{
LogFailure("Custom Lava Drawing", "Could not X coordinate local variable index.");
return;
}
if (!cursor.TryGotoPrev(c => c.MatchLdloc(out yCoordLocalIndex)))
{
LogFailure("Custom Lava Drawing", "Could not Y coordinate local variable index.");
return;
}
if (!cursor.TryGotoNext(c => c.MatchStloc(out liquidColorLocalIndex)))
{
LogFailure("Custom Lava Drawing", "Could not lighting GetColor local variable index.");
return;
}
// Shortly after the liquid color local is the liquid type integer. Locate it.
int liquidTypeLocalIndex = 0;
if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchLdcI4(0)))
{
LogFailure("Custom Lava Drawing", "Could not default value for the liquid type.");
return;
}
if (!cursor.TryGotoNext(c => c.MatchStloc(out liquidTypeLocalIndex)))
{
LogFailure("Custom Lava Drawing", "Could not liquid type local variable index.");
return;
}
// Select the lava color.
if (!cursor.TryGotoNext(MoveType.After, c => c.MatchCallOrCallvirt<Lighting>("get_NotRetro")))
{
LogFailure("Custom Lava Drawing", "Could not locate the retro style check.");
return;
}
// Pass the texture in so that the method can ensure it is not messing around with non-lava textures.
cursor.Emit(OpCodes.Ldloc, liquidColorLocalIndex);
cursor.Emit(OpCodes.Ldsfld, typeof(TextureAssets).GetField("Liquid"));
cursor.Emit(OpCodes.Ldloc, liquidTypeLocalIndex);
cursor.Emit(OpCodes.Ldelem_Ref);
cursor.Emit(OpCodes.Call, textureGetValueMethod);
cursor.Emit(OpCodes.Ldloc, xCoordLocalIndex);
cursor.Emit(OpCodes.Ldloc, yCoordLocalIndex);
cursor.EmitDelegate<Func<Color, Texture2D, int, int, Color>>((initialColor, initialTexture, x, y) =>
{
Color c = SelectLavaColor(initialTexture, initialColor);
if (ExtraColorChangeConditions is not null)
c = ExtraColorChangeConditions(new(c), Main.waterStyle, new(x, y)).TopLeftColor;
return c;
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLavas();
});
cursor.Emit(OpCodes.Stloc, liquidColorLocalIndex);
// Go back to the start and change textures as necessary.
cursor.Index = 0;
while (cursor.TryGotoNext(c => c.MatchLdsfld(typeof(TextureAssets).GetField("Liquid"))))
{
// Move to the end of the get_Value() call and then use the resulting texture to check if a new one should replace it.
// Adding to the index directly would seem like a simple, direct way of achieving this since the operation is incredibly light, but
// it is unsafe due to the potential for NOP operations to appear.
if (!cursor.TryGotoNext(MoveType.After, c => c.MatchCallvirt(textureGetValueMethod)))
{
LogFailure("Custom Lava Drawing", "Could not locate the liquid texture Value call.");
return;
}
cursor.EmitDelegate<Func<Texture2D, Texture2D>>(initialTexture => SelectLavaTexture(initialTexture, LiquidTileType.Block));
}
}
private static void DrawCustomLavafalls(Terraria.On_WaterfallManager.orig_DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects orig, WaterfallManager self, int waterfallType, int x, int y, float opacity, Vector2 position, Rectangle sourceRect, Color color, SpriteEffects effects)
private static void RenderLavaBackgrounds(ILContext il)
{
waterfallType = CustomLavaManagement.SelectLavafallStyle(waterfallType);
color = CustomLavaManagement.SelectLavafallColor(waterfallType, color);
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchCall<Main>("DrawWaters")))
{
LogFailure("Render Lava Backgroumds", "Could not locate the drawing of Background Waters");
return;
}
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLavas(isBackground: true);
});
}
orig(self, waterfallType, x, y, opacity, position, sourceRect, color, effects);
private static void DrawLavatoCapture(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdsfld<Main>("liquidAlpha"), i => i.MatchCall(out _), i => i.MatchStloc2()))
{
LogFailure("Draw lavas to captures", "Could not locate the saving of water alphas");
return;
}
cursor.EmitDelegate(() => {
LavaRendering.alphaSave = CalamityMod.lavaAlpha.ToArray();
});
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(0), i => i.MatchStloc(34), i => i.MatchBr(out _), i => i.MatchLdloc(34), i => i.MatchLdcI4(1), i => i.MatchBeq(out _)))
{
LogFailure("Draw lavas to captures", "Could not locate the resetting of water alphas");
return;
}
cursor.EmitLdloc(8);
cursor.EmitDelegate((CaptureBiome biome) => {
for (int i = 0; i < 1; i++)
{
CalamityMod.lavaAlpha[i] = ((i == CalamityMod.LavaStyle) ? 1f : 0f);
}
});
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchLdsfld<Main>("waterStyle"), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall<Main>("DrawLiquid")))
{
LogFailure("Draw lavas to captures", "Could not locate the background of liquid capture drawing");
return;
}
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLiquid(bg: true, CalamityMod.LavaStyle);
});
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchLdsfld<Main>("bloodMoon"), i => i.MatchBrtrue(out _), i => i.MatchLdloc(8), i => i.MatchLdfld<CaptureBiome>("WaterStyle"), i => i.MatchBr(out _), i => i.MatchLdcI4(9), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall<Main>("DrawLiquid")))
{
LogFailure("Draw lavas to captures", "Could not locate the second background of liquid capture drawing");
return;
}
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLiquid(bg: true, CalamityMod.LavaStyle);
});
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchLdsfld<Main>("waterStyle"), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall<Main>("DrawLiquid")))
{
LogFailure("Draw lavas to captures", "Could not locate the liquid capture drawing");
return;
}
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLiquid(bg: false, CalamityMod.LavaStyle);
});
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchLdloc(8), i => i.MatchLdfld<CaptureBiome>("WaterStyle"), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall<Main>("DrawLiquid")))
{
LogFailure("Draw lavas to captures", "Could not locate the second liquid capture drawing");
return;
}
cursor.EmitDelegate(() => {
LavaRendering.instance.DrawLiquid(bg: false, CalamityMod.LavaStyle);
});
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdloc2(), i => i.MatchStsfld<Main>("liquidAlpha")))
{
LogFailure("Draw lavas to captures", "Could not locate water style value returner");
return;
}
cursor.EmitDelegate(() => {
CalamityMod.lavaAlpha = LavaRendering.alphaSave;
});
}
private void AddTileLiquidDrawing(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdarg1(), i => i.MatchLdcI4(0), i => i.MatchLdarg(out _), i => i.MatchLdloc1(), i => i.MatchLdloc2(), i => i.MatchLdloc(12), i => i.MatchLdloc(13), i => i.MatchLdloc(14), i => i.MatchCall<TileDrawing>("DrawTile_LiquidBehindTile")))
{
LogFailure("Tile Lava Drawing", "Could not locate the drawing of Liquid Behind Tile drawing");
return;
}
cursor.EmitLdloc1();
cursor.EmitLdloc2();
cursor.EmitLdloc(12);
cursor.EmitLdloc(13);
cursor.EmitLdloc(14);
cursor.EmitDelegate((Vector2 unscaledPosition, Vector2 vector, int j, int i, Tile tile) => {
LavaRendering.instance.DrawTile_LiquidBehindTile(solidLayer: false, inFrontOfPlayers: false, -1, unscaledPosition, vector, j, i, tile);
});
}
#endregion
#region Lava Blocking
private void BlockLavaDrawing(ILContext il)
{
//This edit to DrawNormalLiquids makes lavas in normal and white lighting draw with an alpha and with new textures
//If the parameter for the waterstyle is more than the max waterstyles then its subtracted by the max water style count and thats the lava style ID
ILCursor cursor = new ILCursor(il);
//Continue if statement, basically
//if the liquid being drawn is lava and the water style is greater than the max water styles or if the liquid is water and less than the max water styles then the draw code is ran
//otherwise the loop/s are continued for the next liquid
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(4), i => i.MatchBr(out _), i => i.MatchLdloc(2), i => i.MatchLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic), "IsVisible")))
{
LogFailure("Liquid Renderer Drawing", "Could not locate the IsVisible boolean check");
return;
}
cursor.EmitLdarg3();
cursor.EmitLdloc2(); //Initiated Liquid Draw Cache (needed for the Type parameter)
cursor.EmitLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type"));
cursor.EmitDelegate<Func<bool, int, int, bool>>((IsVisible, style, type) => IsVisible && ((type == 1 && style >= LavaRendering.instance.WaterStyleMaxCount + 1) || (type != 1 && style <= LavaRendering.instance.WaterStyleMaxCount)));
//Lava alpha color, if the liquid drawn is lava, multiply num by the water alpha
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdloc(2), i => i.MatchLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type")), i => i.MatchStloc(8)))
{
LogFailure("Liquid Renderer Drawing", "Could not locate creation of the local variable num2 (the liquid type holder variable)");
return;
}
cursor.EmitLdloc(8);
cursor.EmitLdloca(7);
cursor.EmitLdarg(4);
cursor.EmitDelegate((int num2, ref float num, float globalAlpha) =>
{
if (num2 == LiquidID.Lava)
{
num *= globalAlpha;
}
});
//Conditionally replace the liquid texture whether the liquid is lava or water
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCallvirt(typeof(Asset<Texture2D>).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance))))
{
LogFailure("Liquid Renderer Drawing", "Could not locate the Texture2D array of liquids");
return;
}
cursor.EmitLdarg3();
cursor.EmitLdloc2(); //Initiated Liquid Draw Cache (needed for the Type parameter)
cursor.EmitLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type"));
cursor.EmitDelegate<Func<Texture2D, int, int, Texture2D>>((initialTexture, style, type) => (style >= LavaRendering.instance.WaterStyleMaxCount + 1 && type == LiquidID.Lava) ? CalamityMod.LavaTextures.liquid[style - LavaRendering.instance.WaterStyleMaxCount - 1].Value : initialTexture);
}
private void BlockLavaDrawingForSlopes(On_TileDrawing.orig_DrawTile_LiquidBehindTile orig, TileDrawing self, bool solidLayer, bool inFrontOfPlayers, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY, Tile tileCache)
{
if (tileCache.LiquidType == LiquidID.Lava)
return;
Tile tile = Main.tile[tileX + 1, tileY];
if (tile.LiquidType == LiquidID.Lava)
return;
Tile tile2 = Main.tile[tileX - 1, tileY];
if (tile2.LiquidType == LiquidID.Lava)
return;
Tile tile3 = Main.tile[tileX, tileY - 1];
if (tile3.LiquidType == LiquidID.Lava)
return;
Tile tile4 = Main.tile[tileX, tileY + 1];
if (tile4.LiquidType == LiquidID.Lava)
return;
orig.Invoke(self, solidLayer, inFrontOfPlayers, waterStyleOverride, screenPosition, screenOffset, tileX, tileY, tileCache);
}
private void BlockLavaDrawingForSlopes2(On_TileDrawing.orig_DrawPartialLiquid orig, TileDrawing self, bool behindBlocks, Tile tileCache, ref Vector2 position, ref Rectangle liquidSize, int liquidType, ref VertexColors colors)
{
if (liquidType == 1)
{
return;
}
orig.Invoke(self, behindBlocks, tileCache, ref position, ref liquidSize, liquidType, ref colors);
}
private void LavafallRemover(On_WaterfallManager.orig_DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects orig, WaterfallManager self, int waterfallType, int x, int y, float opacity, Vector2 position, Rectangle sourceRect, Color color, SpriteEffects effects)
{
if (waterfallType == 1)
{
return;
}
orig.Invoke(self, waterfallType, x, y, opacity, position, sourceRect, color, effects);
}
private void BlockRetroLightingLava(ILContext il)
{
ILCursor cursor = new ILCursor(il);
ILLabel target = cursor.DefineLabel();
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCgt(), i => i.MatchLdarg1(), i => i.MatchOr(), i => i.MatchBrfalse(out target)))
{
LogFailure("old Drawing Waters", "Could not locate the if statement that contains the check for liquid types, amounts and wether the liquid has a bg (arg1) or not");
return;
}
if (target == null)
{
LogFailure("old Drawing Waters", "The BrFalse returned null, the boolean check getting was unsuccessful");
return;
}
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdindU1(), i => i.MatchSub(), i => i.MatchConvR4(), i => i.MatchStloc(14)))
{
LogFailure("old Drawing Waters", "Could not locate the num3 local variable creation to put the if check after");
return;
}
cursor.EmitLdloc(12);
cursor.EmitLdloc(11);
cursor.EmitDelegate((int i, int j) => {
return Main.tile[i, j].LiquidType == LiquidID.Lava;
});
cursor.EmitBrtrue(target);
}
#endregion
#region Lava Replacing
private void LavaBubbleReplacer(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(16), i => i.MatchLdcI4(16), i => i.MatchLdcI4(35)))
{
LogFailure("Ambient lava bubble replacer", "Could not locate the bubble newdust parameters");
return;
}
cursor.EmitDelegate<Func<int, int>>(type => LavaRendering.dustLava());
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(16), i => i.MatchLdcI4(8), i => i.MatchLdcI4(35)))
{
LogFailure("Ambient lava bubble replacer", "Could not locate the surface bubble newdust parameters");
return;
}
cursor.EmitDelegate<Func<int, int>>(type2 => LavaRendering.dustLava());
}
private void LavaDropletReplacer(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg(out _), i => i.MatchLdcI4(374), i => i.MatchBneUn(out _), i => i.MatchLdcI4(716)))
{
LogFailure("Ambient lava droplet replacer", "Could not locate the lava droplet newgore parameters");
return;
}
cursor.EmitDelegate<Func<int, int>>(type => LavaRendering.goreLava());
}
private void SplashEntityLava(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Entity>("width"), i => i.MatchLdcI4(12), i => i.MatchAdd(), i => i.MatchLdcI4(24), i => i.MatchLdcI4(35)))
{
LogFailure("Entity Lava Splashing (Item, Projectile, NPC, Player)", "Could not locate the first lava bubble splashing");
return;
}
cursor.EmitDelegate<Func<int, int>>(type => LavaRendering.dustLava());
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Entity>("width"), i => i.MatchLdcI4(12), i => i.MatchAdd(), i => i.MatchLdcI4(24), i => i.MatchLdcI4(35)))
{
LogFailure("Entity Lava Splashing (Item, Projectile, NPC, Player)", "Could not locate the second lava bubble splashing");
return;
}
cursor.EmitDelegate<Func<int, int>>(type2 => LavaRendering.dustLava());
}
private void PlayerDebuffEdit(ILContext il)
{
//Injects code directly at the position where the OnFire debuff is handled
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdarg0(), i => i.MatchLdcI4(24), i => i.MatchLdloc(161), i => i.MatchLdcI4(1), i => i.MatchLdcI4(0), i => i.MatchCall<Player>("AddBuff")))
{
LogFailure("Player Update Lava Debuff", "Could not locate the infliction of the On Fire! debuff inside the Player Update code");
return;
}
cursor.EmitLdarg0();
cursor.EmitLdloc(161);
cursor.EmitDelegate((Player player, int onFiretime) =>
{
LavaStylesLoader.InflictDebuff(player, CalamityMod.LavaStyle, onFiretime);
});
}
#endregion
#region Water Visuals
private static void MakeSulphSeaWaterBetter(Terraria.Graphics.Light.On_TileLightScanner.orig_GetTileLight orig, TileLightScanner self, int x, int y, out Vector3 outputColor)
#region Other
private Color WaterfallGlowmaskEditor(On_WaterfallManager.orig_StylizeColor orig, float alpha, int maxSteps, int waterfallType, int y, int s, Tile tileCache, Color aColor)
{
orig(self, x, y, out outputColor);
if (outputColor == Vector3.One || outputColor == new Vector3(0.25f, 0.25f, 0.25f) || outputColor == new Vector3(0.5f, 0.5f, 0.5f))
return;
Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y);
if (tile.LiquidAmount <= 0 || tile.HasTile || tile.Get<LiquidData>().LiquidType != LiquidID.Water || (Main.waterStyle != SulphuricWater.Type &&
Main.waterStyle != SulphuricDepthsWater.Type && Main.waterStyle != SunkenSeaBurrowsWater.Type && Main.waterStyle != SunkenSeaPolypWater.Type &&
Main.waterStyle != SunkenSeaReefsWater.Type && Main.waterStyle != SunkenSeaShoresWater.Type && Main.waterStyle != BasaltGullyWater.Type))
return;
Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1);
if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && Main.waterStyle == SulphuricWater.Type)
if (CalamityMod.LavaStyle != 0 && !LavaStylesLoader.Get(CalamityMod.LavaStyle).LavafallGlowmask())
{
MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f);
GeneralParticleHandler.SpawnParticle(acidFoam);
return aColor;
}
else
{
return orig.Invoke(alpha, maxSteps, waterfallType, y, s, tileCache, aColor);
}
}
private void LavaFallRedrawer(On_WaterfallManager.orig_Draw orig, WaterfallManager self, SpriteBatch spriteBatch)
{
orig.Invoke(self, spriteBatch);
LavaRendering.instance.InitialDrawLavafall(self);
}
#endregion
#endregion
#region Liquid Visuals
//Contains all liquid light and liquid alpha (seethrough-ability)
private static void ApplyLiquidEmit(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchRet()))
{
LogFailure("Liquid Light Emit", "ret instruction is missing????? how is this even possible?????");
return;
}
if (tile.TileType != (ushort)ModContent.TileType<RustyChestTile>())
cursor.EmitLdloc0(); // This should be tile
cursor.EmitLdarg1(); // x
cursor.EmitLdarg2(); // y
cursor.EmitLdarg3(); // ref OutputColor
cursor.EmitDelegate((Tile tile, int x, int y, ref Vector3 lightColor) =>
{
if (Main.waterStyle == SulphuricWater.Type && Main.dayTime && !Main.raining)
if (tile.HasTile || tile.LiquidAmount <= 0)
return;
if (tile.LiquidType == LiquidID.Water)
{
float brightness = MathHelper.Clamp(0.2f - (y / 680), 0f, 0.2f);
if (y > 580)
brightness *= 1f - (y - 580) / 100f;
float R = 0f;
float G = 0f;
float B = 0f;
CalamityWaterLoader.ModifyLightSetup(in tile, x, y, Main.waterStyle, ref R, ref G, ref B);
float waveScale1 = Main.GameUpdateCount * 0.014f;
float waveScale2 = Main.GameUpdateCount * 0.1f;
int scalar = x + (-y / 2);
float wave1 = waveScale1 * -50 + scalar * 15;
float wave2 = waveScale2 * -10 + scalar * 14;
float wave3 = waveScale1 * -100 + scalar * 13;
float wave4 = waveScale2 * 10 + scalar * 25;
float wave5 = waveScale1 * -70 + scalar * 5;
float wave1angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave1));
float wave2angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave2));
float wave3angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave3));
float wave4angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave4));
float wave5angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave5));
outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle);
outputColor *= brightness;
lightColor.X = Math.Max(lightColor.X, R);
lightColor.Y = Math.Max(lightColor.Y, G);
lightColor.Z = Math.Max(lightColor.Z, B);
}
if (Main.waterStyle == SulphuricWater.Type && !Main.dayTime && !Main.raining)
else if (tile.LiquidType == LiquidID.Lava && CalamityMod.Instance.biomeLava == null)
{
float brightness = MathHelper.Clamp(0.17f - (y / 680), 0f, 0.17f);
if (y > 580)
brightness *= 1f - (y - 580) / 100f;
Vector3 lavaLight = new Vector3(0.55f, 0.33f, 0.11f);
float waveScale1 = Main.GameUpdateCount * 0.014f;
float waveScale2 = Main.GameUpdateCount * 0.1f;
int scalar = x + (-y / 2);
float wave1 = waveScale1 * -50 + scalar * 15;
float wave2 = waveScale2 * -10 + scalar * 14;
float wave3 = waveScale1 * -100 + scalar * 13;
float wave4 = waveScale2 * 10 + scalar * 25;
float wave5 = waveScale1 * -70 + scalar * 5;
float wave1angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave1));
float wave2angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave2));
float wave3angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave3));
float wave4angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave4));
float wave5angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave5));
outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle);
outputColor *= brightness;
float R = CalamityMod.LavaStyle == 0 ? lavaLight.X : 0f;
float G = CalamityMod.LavaStyle == 0 ? lavaLight.Y : 0f;
float B = CalamityMod.LavaStyle == 0 ? lavaLight.Z : 0f;
LavaStylesLoader.ModifyLightSetup(x, y, CalamityMod.LavaStyle, ref R, ref G, ref B);
for (int styleIndex = 0; styleIndex < LavaStylesLoader.TotalCount; styleIndex++)
{
if (CalamityMod.lavaAlpha[styleIndex] > 0f && styleIndex != CalamityMod.LavaStyle)
{
float r = styleIndex == 0 ? lavaLight.X : 0f;
float g = styleIndex == 0 ? lavaLight.Y : 0f;
float b = styleIndex == 0 ? lavaLight.Z : 0f;
LavaStylesLoader.ModifyLightSetup(x, y, styleIndex, ref r, ref g, ref b);
float r2 = CalamityMod.LavaStyle == 0 ? lavaLight.X : 0f;
float g2 = CalamityMod.LavaStyle == 0 ? lavaLight.Y : 0f;
float b2 = CalamityMod.LavaStyle == 0 ? lavaLight.Z : 0f;
LavaStylesLoader.ModifyLightSetup(x, y, CalamityMod.LavaStyle, ref r2, ref g2, ref b2);
R = float.Lerp(r, r2, CalamityMod.lavaAlpha[CalamityMod.LavaStyle]);
G = float.Lerp(g, g2, CalamityMod.lavaAlpha[CalamityMod.LavaStyle]);
B = float.Lerp(b, b2, CalamityMod.lavaAlpha[CalamityMod.LavaStyle]);
}
}
if (R != 0.0f || G != 0.0f || B != 0.0f)
{
float colorManipulator = (float)(270 - Main.mouseTextColor) / 900f;
R += colorManipulator;
G += colorManipulator;
B += colorManipulator;
}
lightColor.X = Math.Max(lightColor.X, R);
lightColor.Y = Math.Max(lightColor.Y, G);
lightColor.Z = Math.Max(lightColor.Z, B);
}
});
}
if (Main.waterStyle == SulphuricWater.Type && Main.raining)
private static void LavafallLightEditor(On_WaterfallManager.orig_AddLight orig, int waterfallType, int x, int y)
{
if (waterfallType == 1)
{
float r = 0.55f;
float g = 0.33f;
float b = 0.11f;
LavaStylesLoader.ModifyLightSetup(x, y, CalamityMod.LavaStyle, ref r, ref g, ref b);
if (!(r == 0 && g == 0 && b == 0))
{
float brightness = MathHelper.Clamp(1f - (y / 680), 0f, 1f);
if (y > 580)
brightness *= 1f - (y - 580) / 100f;
outputColor = Vector3.Lerp(outputColor, Color.LightSeaGreen.ToVector3(), 0.41f);
outputColor *= brightness;
}
if (Main.waterStyle == SulphuricDepthsWater.Type)
outputColor = Vector3.Lerp(outputColor, Color.MediumSeaGreen.ToVector3(), 0.18f);
if (Main.waterStyle == SunkenSeaBurrowsWater.Type || Main.waterStyle == SunkenSeaPolypWater.Type || Main.waterStyle == SunkenSeaReefsWater.Type ||
Main.waterStyle == SunkenSeaShoresWater.Type || Main.waterStyle == BasaltGullyWater.Type)
{
//default to white
Color waterGlowColor = Color.White;
//set the glow colors for each sunken sea biome water style
if (Main.waterStyle == SunkenSeaShoresWater.Type)
{
waterGlowColor = new Color(233, 170, 184);
}
if (Main.waterStyle == SunkenSeaPolypWater.Type)
{
waterGlowColor = new Color(213, 185, 178);
}
if (Main.waterStyle == SunkenSeaReefsWater.Type)
{
waterGlowColor = new Color(140, 222, 239);
}
if (Main.waterStyle == SunkenSeaBurrowsWater.Type)
{
waterGlowColor = new Color(76, 211, 231);
}
if (Main.waterStyle == BasaltGullyWater.Type)
{
waterGlowColor = new Color(144, 174, 200);
}
float brightness = MathHelper.Clamp(0.07f, 0f, 0.07f);
float waveScale1 = Main.GameUpdateCount * 0.028f;
float waveScale2 = Main.GameUpdateCount * 0.1f;
int yScale = -y / 2;
int xScale = x / 15;
float wave1 = Main.GameUpdateCount * 0.024f * -50 + ((-x / 30) + (y / 30)) * 25;
float wave2 = waveScale2 * -10 + ((-xScale) + yScale) * 45;
float wave3 = waveScale1 * -100 + ((x / 7) + (y / 50)) * 25;
float wave4 = Main.GameUpdateCount * 0.15f * 10 + ((x / 3) + yScale) * 45;
float wave5 = waveScale1 * -70 + ((-x / 25) + (-y / 25)) * 20;
float wave6 = waveScale2 * -10 + (xScale + yScale) * 45;
float bigwave = Main.GameUpdateCount * 0.01f * -70 + ((-x / 2) + (-y / 40)) * 5;
float wave1angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave1));
float wave2angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave2));
float wave3angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave3));
float wave4angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave4));
float wave5angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave5));
float wave6angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave6));
float bigwaveangle = 0.55f + 0.80f * (float)Math.Sin(MathHelper.ToRadians(bigwave));
outputColor = Vector3.Lerp(outputColor, Color.DarkSlateGray.ToVector3(), 0.07f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle + wave6angle + bigwaveangle);
outputColor *= brightness * 6f;
float r8;
float num3 = (r8 = (r + (float)(270 - Main.mouseTextColor) / 900f) * 0.4f);
float g8 = num3 * g;
float b8 = num3 * b;
Lighting.AddLight(x, y, r8, g8, b8);
}
return;
}
orig.Invoke(waterfallType, x, y);
}
private static void LiquidDrawColors(ILContext il)
{
ILCursor cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchLdarg2(), c => c.MatchLdloc3(), c => c.MatchLdloc(4), c => c.MatchCall<Main>("DrawTileInWater")))
{
LogFailure("Liquid Draw Colors", "Could not locate the liquid vertex colors for drawing");
return;
}
cursor.Emit(OpCodes.Ldloc_3);
cursor.Emit(OpCodes.Ldloc, 4);
cursor.Emit(OpCodes.Ldloc_2);
cursor.Emit(OpCodes.Ldfld, typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type"));
cursor.Emit(OpCodes.Ldloca, 9);
cursor.EmitDelegate((int x, int y, int liquidType, ref VertexColors initialColor) =>
{
if (liquidType == LiquidID.Water)
{
CalamityWaterLoader.DrawColorSetup(x, y, Main.waterStyle, ref initialColor);
}
else if (liquidType == LiquidID.Lava && CalamityMod.Instance.biomeLava == null)
{
LavaStylesLoader.DrawColorSetup(x, y, CalamityMod.LavaStyle, ref initialColor);
}
});
}
private static void LiquidSlopeDrawColors(ILContext il)
{
ILCursor cursor = new ILCursor(il);
var loaderGetMethod = typeof(LoaderManager)
.GetMethod(nameof(LoaderManager.Get))
.MakeGenericMethod([typeof(WaterStylesLoader)]);
if (loaderGetMethod is null)
{
LogFailure("Liquid Slope Draw Colors", "Cannot find \"LoaderManager.Get<WaterStylesLoader>\" Method");
return;
}
var getTotalCountGetter = typeof(Loader)
.GetProperty("TotalCount", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
.GetMethod;
if (getTotalCountGetter is null)
{
LogFailure("Liquid Slope Draw Colors", "Cannot find \"Loader.TotalCount (internal)\" Method");
return;
}
if (!cursor.TryGotoNext(MoveType.After,
c => c.MatchCall(loaderGetMethod),
c => c.MatchCallOrCallvirt(getTotalCountGetter)))
{
LogFailure("Liquid Slope Draw Colors", "Could not locate the liquid slope vertex colors for drawing");
return;
}
// callvirt Loader.TotalCount
// [We are here]
// stloc.s totalCount
// Starts from callvirt (ret: int)
// Stack now have TotalCount and about to pop by local variable, so:
cursor.EmitLdarg(8); // Push tileCache
cursor.EmitLdarg(6); // Push tileX
cursor.EmitLdarg(7); // Push tileY
cursor.EmitLdloca(14); // Push Color*
cursor.EmitDelegate((Tile tileCache, int x, int y, ref VertexColors initialColor) =>
{
// TODO: Properly handle Transition between styles
// That will require extra il injection to achieve
if (tileCache.LiquidType == LiquidID.Water)
CalamityWaterLoader.DrawColorSetup(x, y, Main.waterStyle, ref initialColor, true);
// Known Issue: Sloped Lava Rendering actually does not work on here! (It's been a case even before edited in 2024/08/30)
// Reason: Flag6 is "IsWater" flag, and since we don't modified that behaviour "yet" it will never be triggered here
// Fix this when there will be new lava style with dynamic color changes
else if (tileCache.LiquidType == LiquidID.Lava)
LavaStylesLoader.DrawColorSetup(x, y, CalamityMod.LavaStyle, ref initialColor);
});
// And now remaining TotalCount is now could pass to local variable
#region Intended Result for Reference
// callvirt Loader.TotalCount push 1
//
// ldarg 8 (tileCache) push 1
// ldarg 6 (tileX) push 1
// ldarg 7 (tileY) push 1
// ldloca 14 (vertices) push 1
// call ModdedDelegate pop 4
//
// stloc.s totalCount pop 1
#endregion
}
#endregion
@@ -1306,7 +1486,7 @@ namespace CalamityMod.ILEditing
ForegroundManager.DrawTiles();
}
private static void ClearForegroundStuff(Terraria.GameContent.Drawing.On_TileDrawing.orig_PreDrawTiles orig, Terraria.GameContent.Drawing.TileDrawing self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets)
private static void ClearForegroundStuff(On_TileDrawing.orig_PreDrawTiles orig, TileDrawing self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets)
{
orig(self, solidLayer, forRenderTargets, intoRenderTargets);
@@ -1316,7 +1496,7 @@ namespace CalamityMod.ILEditing
#endregion
#region Tile ping overlay
private static void ClearTilePings(Terraria.GameContent.Drawing.On_TileDrawing.orig_Draw orig, Terraria.GameContent.Drawing.TileDrawing self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride)
private static void ClearTilePings(On_TileDrawing.orig_Draw orig, TileDrawing self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride)
{
//Retro & Trippy light modes are fine. Just reset the cache before every time stuff gets drawn.
if (Lighting.UpdateEveryFrame)
@@ -1465,7 +1645,7 @@ namespace CalamityMod.ILEditing
{
return;
}
// Go through the World Selection Difficulty System's World Difficulty list backwards and choose the latest difficulty that applies
for (int i = WorldSelectionDifficultySystem.WorldDifficulties.Count - 1; i >= 0; i--)
{
@@ -1615,5 +1795,62 @@ namespace CalamityMod.ILEditing
}
}
#endregion
#region Optimized GlowMask Rendering on Tile
private static void GlowMaskTileRender(On_TileDrawing.orig_DrawSingleTile orig, TileDrawing self, TileDrawInfo drawData, bool solidLayer, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY)
{
orig(self, drawData, solidLayer, waterStyleOverride, screenPosition, screenOffset, tileX, tileY);
var type = drawData.typeCache;
if (type < 0 || type >= GlowMaskTile.LookupLength)
return;
var glowMaskTile = GlowMaskTile.InstanceLookup[type];
if (glowMaskTile is null)
return;
var glowMask = glowMaskTile.GlowMask;
int xPos = drawData.tileFrameX + drawData.addFrX;
int yPos = drawData.tileFrameY + drawData.addFrY;
if (glowMask.HasContentInFramePos(xPos, yPos))
{
ref Tile tileCache = ref drawData.tileCache;
int colType = tileCache.TileColor;
Color drawColor = glowMaskTile.GetGlowMaskColor(tileX, tileY, drawData);
Color tileLight = drawData.tileLight;
if (tileLight.R > drawColor.R) drawColor.R = tileLight.R;
if (tileLight.G > drawColor.G) drawColor.G = tileLight.G;
if (tileLight.B > drawColor.B) drawColor.B = tileLight.B;
drawColor = glowMaskTile.GlowMaskPaintInteraction switch
{
GlowMaskTile.PaintColorTint.OnlyByDeepPaint => GlowMaskTile.ApplyPaint(colType, drawColor, deepPaintOnly: true),
GlowMaskTile.PaintColorTint.ByEveryPaint => GlowMaskTile.ApplyPaint(colType, drawColor, deepPaintOnly: false),
_ => drawColor
};
// Cull no lit and too dark colors
if (drawColor.R <= 1 && drawColor.G <= 1 && drawColor.B <= 1)
return;
drawColor.A = 255;
if (Main.tileSolid[type])
{
var drawRect = new Rectangle(xPos, yPos, 16, 16);
TileFramingSystem.SlopedGlowmask(in tileCache, tileX, tileY, glowMask.Texture, drawRect, drawColor, default);
}
else
{
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
Vector2 drawPos = new Vector2(tileX * 16, tileY * 16 + 2) - Main.screenPosition + zero;
Rectangle drawRect = new Rectangle(xPos, yPos, 16, 16);
Main.spriteBatch.Draw(glowMask.Texture, drawPos, drawRect, drawColor, 0.0f, default, 1.0f, drawData.tileSpriteEffect, 0.0f);
}
}
}
#endregion
}
}
+48
View File
@@ -205,6 +205,54 @@ namespace CalamityMod
}
}
#region BiomeLava
public static void LavaStytleToBiomeLava()
{
CalamityMod calamity = GetInstance<CalamityMod>();
Mod biomelava = calamity.biomeLava;
if (biomelava == null)
return;
foreach (ModLavaStyle item in LavaStylesLoader.Content)
{
int type = item.Slot;
ModLavaStyle lavaStyle = LavaStylesLoader.Get(type);
if (lavaStyle != null)
{
Func<int> GetSplashDust = lavaStyle.GetSplashDust;
Func<int> GetDropletGore = lavaStyle.GetDropletGore;
Func<int, int, float, float, float, Vector3> ModifyLightFunc = ModifyLight;
Func<bool> IsLavaActive = lavaStyle.IsLavaActive;
Func<bool> lavafallGlowmask = lavaStyle.LavafallGlowmask;
Func<Player, NPC, int, Action> InflictDebuffFunc = InflictDebuff;
Func<bool> yes = InflictsOnFire;
Vector3 ModifyLight(int x, int y, float r, float g, float b)
{
lavaStyle.ModifyLight(x, y, ref r, ref g, ref b);
return new Vector3(r, g, b);
}
Action InflictDebuff(Player player, NPC npc, int onfireDuration)
{
if (player != null && npc == null)
{
lavaStyle.InflictDebuff(player, onfireDuration);
}
return null;
}
bool InflictsOnFire()
{
return true;
}
biomelava.Call("ModLavaStyle", calamity, lavaStyle.Name, lavaStyle.Texture, lavaStyle.BlockTexture, lavaStyle.SlopeTexture, lavaStyle.WaterfallTexture, GetSplashDust, GetDropletGore, ModifyLightFunc, IsLavaActive, lavafallGlowmask, InflictDebuffFunc, yes);
}
}
}
#endregion
#region WikiThis
// This is a separate function because it only runs clientside
public static void WikiThisSupport()
+57
View File
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Terraria;
using Terraria.Graphics;
using Terraria.ModLoader;
namespace CalamityMod.Systems
{
public abstract class CalamityModWaterStyle : ModWaterStyle
{
/// <summary>
/// Allows water styles to manipulate what color the liquid is drawn to, this can allow waters to be see-throughable to see backgrounds (surface and underground backgrounds not walls)
/// </summary>
/// <param name="x">X position of the water</param>
/// <param name="y">Y position of the water</param>
/// <param name="liquidColor">The vertexColor of the water color, this is both used to get the current color and to set the color of the water</param>
public virtual void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope)
{
}
/// <summary>
/// Allows you to determine how much light this water emits.<br />
/// It can also let you light up the block in front of this water.<br />
/// See <see cref="M:Terraria.Graphics.Light.TileLightScanner.ApplyLiquidLight(Terraria.Tile,Microsoft.Xna.Framework.Vector3@)" /> for vanilla tile light values to use as a reference.<br />
/// </summary>
/// <param name="i">The x position in tile coordinates.</param>
/// <param name="j">The y position in tile coordinates.</param>
/// <param name="r">The red component of light, usually a value between 0 and 1</param>
/// <param name="g">The green component of light, usually a value between 0 and 1</param>
/// <param name="b">The blue component of light, usually a value between 0 and 1</param>
public virtual void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b)
{
}
}
internal static class CalamityWaterLoader
{
internal static void ModifyLightSetup(ref readonly Tile tile, int i, int j, int type, ref float r, ref float g, ref float b)
{
CalamityModWaterStyle styles = (CalamityModWaterStyle)LoaderManager.Get<WaterStylesLoader>().Get(type);
if (styles != null)
{
styles?.ModifyLight(in tile, i, j, ref r, ref g, ref b);
}
}
internal static void DrawColorSetup(int x, int y, int type, ref VertexColors liquidColor, bool isSlope = false)
{
CalamityModWaterStyle styles = (CalamityModWaterStyle)LoaderManager.Get<WaterStylesLoader>().Get(type);
if (styles != null)
{
styles?.DrawColor(x, y, ref liquidColor, isSlope);
}
}
}
}
File diff suppressed because it is too large. Load diff
+262
View File
@@ -0,0 +1,262 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent.Liquid;
using Terraria.GameContent;
using Terraria.Graphics;
using Terraria.ModLoader;
using System.Linq;
using Terraria.ID;
using Microsoft.Xna.Framework;
using CalamityMod.Items.Potions.Alcohol;
namespace CalamityMod.Systems
{
public abstract class ModLavaStyle : ModTexturedType
{
/// <summary>
/// The ID of the lava style.
/// </summary>
public int Slot { get; private set; } = -1;
public override string Name => base.Name;
public override string Texture => base.Texture;
public virtual string BlockTexture => Texture + "_Block";
public virtual string SlopeTexture => Texture + "_Slope";
public virtual string WaterfallTexture => Texture + "_Waterfall";
protected sealed override void Register()
{
Slot = LavaStylesLoader.Register(this);
}
public sealed override void SetupContent()
{
SetStaticDefaults();
}
/// <summary>
/// Allows you to determine how much light this lava emits.<br />
/// It can also let you light up the block in front of this lava.<br />
/// Keep in mind this also effects what color the lavafalls emit <br />
/// See <see cref="M:Terraria.Graphics.Light.TileLightScanner.ApplyLiquidLight(Terraria.Tile,Microsoft.Xna.Framework.Vector3@)" /> for vanilla tile light values to use as a reference.<br />
/// </summary>
/// <param name="i">The x position in tile coordinates.</param>
/// <param name="j">The y position in tile coordinates.</param>
/// <param name="r">The red component of light, usually a value between 0 and 1</param>
/// <param name="g">The green component of light, usually a value between 0 and 1</param>
/// <param name="b">The blue component of light, usually a value between 0 and 1</param>
public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
r = 0.55f;
g = 0.33f;
b = 0.11f;
}
/// <summary>
/// Allows water styles to manipulate what color the liquid is drawn to, this can allow waters to be see-throughable to see backgrounds (surface and underground backgrounds not walls)
/// </summary>
/// <param name="x">X position of the water</param>
/// <param name="y">Y position of the water</param>
/// <param name="liquidColor">The vertexColor of the water color, this is both used to get the current color and to set the color of the water</param>
public virtual void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope)
{
}
/// <summary>
/// The ID of the dust that is created when anything splashes in lava.
/// </summary>
public virtual int GetSplashDust()
{
return DustID.Lava;
}
/// <summary>
/// The ID of the gore that represents droplets of lava falling down from a block. Return <see cref="F:Terraria.ID.GoreID.LavaDrip" /> (or another existing droplet gore).
/// </summary>
public virtual int GetDropletGore()
{
return GoreID.LavaDrip;
}
/// <summary>
/// Return true if the player is in the correct zone to activate the lava.
/// </summary>
/// <returns></returns>
public virtual bool IsLavaActive()
{
return false;
}
/// <summary>
/// Return false if the waterfall made by the lavastyle should have a glowmask
/// </summary>
/// <returns></returns>
public virtual bool LavafallGlowmask()
{
return true;
}
/// <summary>
/// Allows your lavastyle to inflict debuffs to Players and NPCs when they enter your lava style
/// </summary>
/// <param name="player">The Player that is inflicted with the debuff apon entering the lavastyle</param>
/// <param name="onfireDuration">The duration of the OnFire! debuff. This allows for easy replacement of OnFire</param>
public virtual void InflictDebuff(Player player, int onfireDuration)
{
}
}
public class LavaStylesLoader : ModSystem
{
private static readonly MethodInfo ResizeArrayMethodInfo;
static LavaStylesLoader()
{
ResizeArrayMethodInfo = typeof(ModContent).GetMethod("ResizeArrays", BindingFlags.NonPublic | BindingFlags.Static);
}
private static void ResizeArrays(ResizeArray_orig orig, bool unloading)
{
orig.Invoke(unloading);
int totalCount = TotalCount;
Array.Resize(ref CalamityMod.LavaTextures.liquid, totalCount);
Array.Resize(ref CalamityMod.LavaTextures.block, totalCount);
Array.Resize(ref CalamityMod.LavaTextures.slope, totalCount);
Array.Resize(ref CalamityMod.LavaTextures.fall, totalCount);
Array.Resize(ref CalamityMod.lavaAlpha, totalCount);
}
private static readonly List<ModLavaStyle> _content = [];
public static IReadOnlyList<ModLavaStyle> Content => _content;
public static int VanillaCount => 1;
public static int ModCount => _content.Count;
public static int TotalCount => VanillaCount + ModCount;
public override void Load()
{
if (ResizeArrayMethodInfo != null)
{
MonoModHooks.Add(ResizeArrayMethodInfo, ResizeArrays);
}
}
public override void PostSetupContent()
{
foreach (ModLavaStyle item in Content)
{
int Slot = item.Slot;
CalamityMod.LavaTextures.liquid[Slot] = ModContent.Request<Texture2D>(item.Texture, (AssetRequestMode)2);
CalamityMod.LavaTextures.block[Slot] = ModContent.Request<Texture2D>(item.BlockTexture, (AssetRequestMode)2);
CalamityMod.LavaTextures.slope[Slot] = ModContent.Request<Texture2D>(item.SlopeTexture, (AssetRequestMode)2);
CalamityMod.LavaTextures.fall[Slot] = ModContent.Request<Texture2D>(item.WaterfallTexture, (AssetRequestMode)2);
}
}
public static ModLavaStyle Get(int type)
{
type -= VanillaCount;
return type >= 0 && type < _content.Count ? _content[type] : null;
}
internal static int Register(ModLavaStyle instance)
{
int type = TotalCount;
ModTypeLookup<ModLavaStyle>.Register(instance);
_content.Add(instance);
return type;
}
private delegate void ResizeArray_orig(bool unloading);
public static void UpdateLiquidAlphas()
{
if (CalamityMod.LavaStyle >= VanillaCount)
{
for (int i = 0; i < VanillaCount; i++)
{
CalamityMod.lavaAlpha[i] -= 0.2f;
if (CalamityMod.lavaAlpha[i] < 0f)
{
CalamityMod.lavaAlpha[i] = 0f;
}
}
}
foreach (ModLavaStyle item in Content)
{
int type = item.Slot;
if (CalamityMod.LavaStyle == type)
{
CalamityMod.lavaAlpha[type] += 0.2f;
if (CalamityMod.lavaAlpha[type] > 1f)
{
CalamityMod.lavaAlpha[type] = 1f;
}
}
else
{
CalamityMod.lavaAlpha[type] -= 0.2f;
if (CalamityMod.lavaAlpha[type] < 0f)
{
CalamityMod.lavaAlpha[type] = 0f;
}
}
}
}
public static void ModifyLightSetup(int i, int j, int style, ref float r, ref float g, ref float b)
{
ModLavaStyle lavaStyle = Get(style);
if (lavaStyle != null)
{
lavaStyle?.ModifyLight(i, j, ref r, ref g, ref b);
}
}
internal static void DrawColorSetup(int x, int y, int type, ref VertexColors liquidColor, bool isSlope = false)
{
ModLavaStyle styles = Get(type);
if (styles != null)
{
styles?.DrawColor(x, y, ref liquidColor, isSlope);
}
}
public static void InflictDebuff(Player player, int type, int onfireDuration)
{
ModLavaStyle lavaStyle = Get(type);
if (lavaStyle != null)
{
lavaStyle?.InflictDebuff(player, onfireDuration);
}
}
public static void IsLavaActive()
{
foreach (ModLavaStyle item in Content)
{
int type = item.Slot;
ModLavaStyle lavaStyle = Get(type);
if (lavaStyle != null)
{
bool? flag = lavaStyle?.IsLavaActive();
if (flag != null && flag == true)
{
CalamityMod.LavaStyle = lavaStyle.Slot;
}
}
}
}
}
}
+133 -36
View File
@@ -214,6 +214,112 @@ namespace CalamityMod.Systems
}
#endregion
#region Tile Variation Helpers
public static int GetVariation4x4_012_Low0(int i, int j)
{
int xRel = i & 0b0011;
int yRel = j & 0b0011;
var output = xRel switch
{
0 => (yRel switch
{
0 => 0,
1 => 2,
2 => 1,
_ => 2
}),
1 => (yRel switch
{
0 => 2,
1 => 0,
2 => 2,
_ => 2
}),
2 => (yRel switch
{
0 => 2,
1 => 0,
2 => 1,
_ => 2
}),
_ => (yRel switch
{
0 => 1,
1 => 2,
2 => 0,
_ => 2
}),
};
return output;
}
public static int GetVariation4x4_01_Low0(int i, int j)
{
int xRel = i & 0b0011;
int yRel = j & 0b0011;
var output = xRel switch
{
0 => (yRel switch
{
0 => 0,
1 => 0,
2 => 1,
_ => 1
}),
1 => (yRel switch
{
0 => 1,
1 => 0,
2 => 1,
_ => 1
}),
2 => (yRel switch
{
0 => 1,
1 => 0,
2 => 0,
_ => 1
}),
_ => (yRel switch
{
0 => 0,
1 => 1,
2 => 0,
_ => 1
}),
};
return output;
}
public static int GetVariation3x3_01234_Low3(int i, int j)
{
int xRel = i % 3;
int yRel = j % 3;
var output = xRel switch
{
0 => (yRel switch
{
0 => 0,
1 => 1,
_ => 2
}),
1 => (yRel switch
{
0 => 2,
1 => 3,
_ => 4
}),
_ => (yRel switch
{
0 => 4,
1 => 0,
_ => 1
}),
};
return output;
}
#endregion
#region Framing Helpers
private static bool GetMerge(Tile myTile, Tile mergeTile)
{
@@ -1301,57 +1407,48 @@ namespace CalamityMod.Systems
#endregion
}
internal static void SlopedGlowmask(int i, int j, int type, Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color drawColor, Vector2 positionOffset, bool overrideTileFrame = false)
internal static void SlopedGlowmask(ref readonly Tile tile, int i, int j, Texture2D texture, Rectangle? sourceRectangle, Color drawColor, Vector2 positionOffset)
{
var tile = Main.tile[i, j];
int frameX = tile.TileFrameX;
int frameY = tile.TileFrameY;
int TileFrameX = tile.TileFrameX;
int TileFrameY = tile.TileFrameY;
if (overrideTileFrame)
{
TileFrameX = 0;
TileFrameY = 0;
}
var width = 16;
var height = 16;
int width = 16;
int height = 16;
if (sourceRectangle != null)
{
TileFrameX = ((Rectangle)sourceRectangle).X;
TileFrameY = ((Rectangle)sourceRectangle).Y;
frameX = ((Rectangle)sourceRectangle).X;
frameY = ((Rectangle)sourceRectangle).Y;
}
var iX16 = i * 16;
var jX16 = j * 16;
var location = new Vector2(iX16, jX16);
var zero = new Vector2(Main.offScreenRange, Main.offScreenRange);
if (Main.drawToScreen)
zero = Vector2.Zero;
int iX16 = i * 16;
int jX16 = j * 16;
var offsets = -Main.screenPosition + zero + positionOffset;
var drawCoordinates = location + offsets;
if (tile.Slope == 0 && !tile.IsHalfBlock || Main.tileSolid[tile.TileType] && Main.tileSolidTop[tile.TileType]) //second one should be for platforms
Vector2 location = new Vector2(iX16, jX16);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
Vector2 offsets = -Main.screenPosition + zero + positionOffset;
Vector2 drawCoordinates = location + offsets;
if ((tile.Slope == 0 && !tile.IsHalfBlock) || (Main.tileSolid[tile.TileType] && Main.tileSolidTop[tile.TileType])) //second one should be for platforms
{
Main.spriteBatch.Draw(texture, drawCoordinates, new Rectangle(TileFrameX, TileFrameY, width, height), drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
Main.spriteBatch.Draw(texture, drawCoordinates, new Rectangle(frameX, frameY, width, height), drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
else if (tile.IsHalfBlock)
{
Main.spriteBatch.Draw(texture, new Vector2(drawCoordinates.X, drawCoordinates.Y + 8), new Rectangle(TileFrameX, TileFrameY, width, 8), drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
Main.spriteBatch.Draw(texture, new Vector2(drawCoordinates.X, drawCoordinates.Y + 8), new Rectangle(frameX, frameY, width, 8), drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
else
{
var b = (byte)tile.Slope;
byte b = (byte)tile.Slope;
Rectangle TileFrame;
Vector2 drawPos;
if (b == 1 || b == 2)
{
int length;
int height2;
for (var a = 0; a < 8; ++a)
for (int a = 0; a < 8; ++a)
{
var aX2 = a * 2;
int aX2 = a * 2;
if (b == 2)
{
length = 16 - aX2 - 2;
@@ -1363,12 +1460,12 @@ namespace CalamityMod.Systems
height2 = 14 - length;
}
TileFrame = new Rectangle(TileFrameX + length, TileFrameY, 2, height2);
TileFrame = new Rectangle(frameX + length, frameY, 2, height2);
drawPos = new Vector2(iX16 + length, jX16 + aX2) + offsets;
Main.spriteBatch.Draw(texture, drawPos, TileFrame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
TileFrame = new Rectangle(TileFrameX, TileFrameY + 14, 16, 2);
TileFrame = new Rectangle(frameX, frameY + 14, 16, 2);
drawPos = new Vector2(iX16, jX16 + 14) + offsets;
Main.spriteBatch.Draw(texture, drawPos, TileFrame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
@@ -1376,9 +1473,9 @@ namespace CalamityMod.Systems
{
int length;
int height2;
for (var a = 0; a < 8; ++a)
for (int a = 0; a < 8; ++a)
{
var aX2 = a * 2;
int aX2 = a * 2;
if (b == 3)
{
length = aX2;
@@ -1390,15 +1487,15 @@ namespace CalamityMod.Systems
height2 = 16 - aX2;
}
TileFrame = new Rectangle(TileFrameX + length, TileFrameY + 16 - height2, 2, height2);
TileFrame = new Rectangle(frameX + length, frameY + 16 - height2, 2, height2);
drawPos = new Vector2(iX16 + length, jX16) + offsets;
Main.spriteBatch.Draw(texture, drawPos, TileFrame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
drawPos = new Vector2(iX16, jX16) + offsets;
if (tile.TileType != ModContent.TileType<EutrophicGlass>())
if (tile.TileType != EutrophicGlass.TypeCache)
{
TileFrame = new Rectangle(TileFrameX, TileFrameY, 16, 2);
TileFrame = new Rectangle(frameX, frameY, 16, 2);
Main.spriteBatch.Draw(texture, drawPos, TileFrame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
}
+7 -23
View File
@@ -10,18 +10,11 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss.AbyssAmbient
{
public class AbyssGiantKelp1 : ModTile
public class AbyssGiantKelp1 : GlowMaskTile
{
protected virtual string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1Glow";
internal static FramedGlowMask GlowMask;
public override void SetStaticDefaults()
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1Glow";
public override void SetupStatic()
{
if (!string.IsNullOrEmpty(GlowAsset))
{
GlowMask = new(GlowAsset, 18, 18);
}
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
TileObjectData.newTile.Width = 2;
@@ -39,9 +32,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
AddMapEntry(new Color(92, 93, 42));
DustType = DustID.Grass;
HitSound = SoundID.Grass;
base.SetStaticDefaults();
}
public override void NearbyEffects(int i, int j, bool closer)
{
if (closer && Main.rand.NextBool(100) && j > Main.worldSurface)
@@ -70,23 +62,15 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
num = fail ? 1 : 2;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask is not null && GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
Vector2 pos = new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero;
Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
spriteBatch.Draw(GlowMask.Texture, pos, frame, Color.White);
}
return Color.White;
}
}
//just clone the first one its literally the same size
public class AbyssGiantKelp2 : AbyssGiantKelp1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp2Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp2Glow";
}
}
+5 -15
View File
@@ -10,14 +10,12 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss.AbyssAmbient
{
public class AbyssGiantKelp3 : ModTile
public class AbyssGiantKelp3 : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3Glow", 18, 18);
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
TileObjectData.newTile.Width = 2;
@@ -35,8 +33,6 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
AddMapEntry(new Color(92, 93, 42));
DustType = DustID.Grass;
HitSound = SoundID.Grass;
base.SetStaticDefaults();
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
@@ -66,15 +62,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
num = fail ? 1 : 2;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
spriteBatch.Draw(GlowMask.Texture, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White);
}
return Color.White;
}
}
}
+5 -15
View File
@@ -10,14 +10,12 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss.AbyssAmbient
{
public class AbyssGiantKelp4 : ModTile
public class AbyssGiantKelp4 : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4Glow", 18, 18);
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
TileObjectData.newTile.Width = 2;
@@ -35,8 +33,6 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
AddMapEntry(new Color(92, 93, 42));
DustType = DustID.Grass;
HitSound = SoundID.Grass;
base.SetStaticDefaults();
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
@@ -66,15 +62,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
num = fail ? 1 : 2;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
spriteBatch.Draw(GlowMask.Texture, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White);
}
return Color.White;
}
}
}
+7 -23
View File
@@ -9,18 +9,12 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss.AbyssAmbient
{
public class BulbTree1 : ModTile
public class BulbTree1 : GlowMaskTile
{
protected virtual string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree1Glow";
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree1Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
if (!string.IsNullOrEmpty(GlowAsset))
{
GlowMask = new(GlowAsset, 18, 18);
}
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
TileObjectData.newTile.Width = 3;
@@ -37,8 +31,6 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
TileObjectData.addTile(Type);
AddMapEntry(new Color(52, 124, 153));
DustType = 33;
base.SetStaticDefaults();
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
@@ -53,27 +45,19 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
num = fail ? 1 : 2;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask is not null && GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
Vector2 pos = new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero;
Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
spriteBatch.Draw(GlowMask.Texture, pos, frame, Color.White);
}
return Color.White;
}
}
public class BulbTree2 : BulbTree1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree3Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree2Glow";
}
public class BulbTree3 : BulbTree1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree3Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree3Glow";
}
}
+7 -23
View File
@@ -12,19 +12,13 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
//
// Pirate Crate With Glow
public class PirateCrate1 : ModTile
public class PirateCrate1 : GlowMaskTile
{
protected virtual string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow";
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow";
public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/CrateBreak", 3) { Volume = 0.8f };
public override void SetStaticDefaults()
public override void SetupStatic()
{
if (!string.IsNullOrEmpty(GlowAsset))
{
GlowMask = new(GlowAsset, 18, 18);
}
Main.tileFrameImportant[Type] = true;
Main.tileLavaDeath[Type] = true;
Main.tileWaterDeath[Type] = false;
@@ -35,8 +29,6 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
AddMapEntry(new Color(97, 69, 52), CalamityUtils.GetText("Tiles.PirateCrate"));
DustType = DustID.WoodFurniture;
HitSound = MineSound;
base.SetStaticDefaults();
}
public override void KillMultiTile(int i, int j, int frameX, int frameY)
@@ -54,28 +46,20 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
num = fail ? 1 : 2;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask is not null && GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
Vector2 pos = new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero;
Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
spriteBatch.Draw(GlowMask.Texture, pos, frame, Color.White);
}
return Color.White;
}
}
public class PirateCrate2 : PirateCrate1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow";
}
public class PirateCrate3 : PirateCrate1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow";
}
//
+9 -25
View File
@@ -11,18 +11,12 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss.AbyssAmbient
{
public class SpiderCoral1 : ModTile
public class SpiderCoral1 : GlowMaskTile
{
protected virtual string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral1Glow";
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral1Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
if (!string.IsNullOrEmpty(GlowAsset))
{
GlowMask = new(GlowAsset, 18, 18);
}
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
@@ -30,8 +24,6 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
TileObjectData.addTile(Type);
AddMapEntry(new Color(82, 49, 27));
DustType = 32;
base.SetStaticDefaults();
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
@@ -41,37 +33,29 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
b = 0.08f;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask is not null && GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
Vector2 pos = new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero;
Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
spriteBatch.Draw(GlowMask.Texture, pos, frame, Color.White);
}
return Color.White;
}
}
public class SpiderCoral2 : SpiderCoral1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral2Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral2Glow";
}
public class SpiderCoral3 : SpiderCoral1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral3Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral3Glow";
}
public class SpiderCoral4 : SpiderCoral1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral4Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral4Glow";
}
public class SpiderCoral5 : SpiderCoral1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral5Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral5Glow";
}
}
+7 -23
View File
@@ -9,18 +9,12 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss.AbyssAmbient
{
public class SulphurPireCoral1 : ModTile
public class SulphurPireCoral1 : GlowMaskTile
{
protected virtual string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral2Glow";
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral1Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
if (!string.IsNullOrEmpty(GlowAsset))
{
GlowMask = new(GlowAsset, 18, 18);
}
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
TileObjectData.newTile.Width = 3;
@@ -37,8 +31,6 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
TileObjectData.addTile(Type);
AddMapEntry(new Color(91, 128, 13));
DustType = 32;
base.SetStaticDefaults();
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
@@ -53,27 +45,19 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient
num = fail ? 1 : 2;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
Tile tile = Framing.GetTileSafely(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange);
if (GlowMask is not null && GlowMask.HasContentInFramePos(tile.TileFrameX, tile.TileFrameY))
{
Vector2 pos = new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero;
Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16);
spriteBatch.Draw(GlowMask.Texture, pos, frame, Color.White);
}
return Color.White;
}
}
public class SulphurPireCoral2 : SulphurPireCoral1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral2Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral2Glow";
}
public class SulphurPireCoral3 : SulphurPireCoral1
{
protected override string GlowAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral3Glow";
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral3Glow";
}
}
+2 -87
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using CalamityMod.Systems;
using CalamityMod.Tiles.Abyss.AbyssAmbient;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -67,93 +68,7 @@ namespace CalamityMod.Tiles.Abyss
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
}
}
+14 -96
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using CalamityMod.Systems;
using CalamityMod.Tiles.Abyss.AbyssAmbient;
using CalamityMod.Walls;
using Microsoft.Xna.Framework;
@@ -51,93 +52,7 @@ namespace CalamityMod.Tiles.Abyss
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 1;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_01_Low0(i, j);
}
public override void RandomUpdate(int i, int j)
@@ -161,24 +76,26 @@ namespace CalamityMod.Tiles.Abyss
NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None);
}
Tile down = Main.tile[i, j + 1];
int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143));
if (Main.tile[i, j + 1] != null)
if (down != null)
{
if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType<ViperVines>())
if (!down.HasTile && down.TileType != (ushort)ModContent.TileType<ViperVines>())
{
if (Main.tile[i, j + 1].LiquidAmount == 255 &&
Main.tile[i, j + 1].WallType == (ushort)ModContent.WallType<AbyssGravelWall>() &&
Main.tile[i, j + 1].LiquidType != LiquidID.Lava)
if (down.LiquidAmount == 255 &&
down.WallType == (ushort)ModContent.WallType<AbyssGravelWall>() &&
down.LiquidType != LiquidID.Lava)
{
bool canGrowVine = false;
for (int k = vineLength; k > vineLength - 10; k--)
{
if (Main.tile[i, k].BottomSlope)
var vineTile = Main.tile[i, k];
if (vineTile.BottomSlope)
{
canGrowVine = false;
break;
}
if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope)
if (vineTile.HasTile && !vineTile.BottomSlope)
{
canGrowVine = true;
break;
@@ -188,8 +105,9 @@ namespace CalamityMod.Tiles.Abyss
{
int vineX = i;
int vineY = j + 1;
Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType<ViperVines>();
Main.tile[vineX, vineY].Get<TileWallWireStateData>().HasTile = true;
var newVineTile = Main.tile[vineX, vineY];
newVineTile.TileType = (ushort)ModContent.TileType<ViperVines>();
newVineTile.Get<TileWallWireStateData>().HasTile = true;
WorldGen.SquareTileFrame(vineX, vineY, true);
if (Main.netMode == NetmodeID.Server)
NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None);
+10 -40
View File
@@ -7,21 +7,20 @@ using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Abyss
{
public class PyreMantleMolten : ModTile
public class PyreMantleMolten : GlowMaskTile
{
public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f };
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/PyreMantleMolten_Glowmask";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Abyss/PyreMantleMolten_Glowmask", 18, 18);
Main.tileLighted[Type] = true;
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -75,34 +74,10 @@ namespace CalamityMod.Tiles.Abyss
}
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
if (GlowMask.Texture is null)
return;
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(200, 200, 200, 200));
Tile trackTile = Main.tile[i, j];
float glowbrightness = 1f;
float glowspeed = Main.GameUpdateCount * 0.01f;
glowbrightness *= (float)MathF.Sin(i / 60f + glowspeed);
drawColour *= glowbrightness;
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
glowbrightness += 0.3f;
}
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
float brightness = 0.7f;
float lightspeed = Main.GameUpdateCount * 0.01f;
float lightspeed = (float)(Main.timeForVisualEffects * 0.01);
brightness *= (float)MathF.Sin(i / 60f + lightspeed);
brightness += 0.3f;
r = 1f;
@@ -113,17 +88,12 @@ namespace CalamityMod.Tiles.Abyss
b *= brightness;
}
private Color GetDrawColour(int i, int j, Color colour)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
float glowbrightness = 1f;
float glowspeed = (float)(Main.timeForVisualEffects * 0.01);
glowbrightness *= MathF.Sin(i / 60f + glowspeed);
return Color.White * glowbrightness;
}
}
}
+4
View File
@@ -10,8 +10,12 @@ namespace CalamityMod.Tiles.Abyss
{
public class RustyChestTile : ModTile
{
public static int Type;
public override void SetStaticDefaults()
{
Type = (ushort)ModContent.TileType<RustyChestTile>();
this.SetUpChest(ModContent.ItemType<RustyChest>());
AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName<RustyChest>(), CalamityUtils.GetMapChestName);
}
+9 -91
View File
@@ -1,4 +1,6 @@
using CalamityMod.Tiles.Abyss.AbyssAmbient;
using CalamityMod.Systems;
using CalamityMod.Tiles.Abyss.AbyssAmbient;
using CalamityMod.Waters;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
@@ -13,7 +15,7 @@ namespace CalamityMod.Tiles.Abyss
int animationFrameWidth = 234;
public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3);
public override void SetStaticDefaults()
{
Main.tileSolid[Type] = true;
@@ -35,9 +37,12 @@ namespace CalamityMod.Tiles.Abyss
public override void NearbyEffects(int i, int j, bool closer)
{
if (Main.dedServ)
return;
if (Main.LocalPlayer.InModBiome(ModContent.GetInstance<BiomeManagers.AbyssLayer1Biome>()))
{
Main.SceneMetrics.ActiveFountainColor = ModContent.Find<ModWaterStyle>("CalamityMod/SulphuricDepthsWater").Slot;
Main.SceneMetrics.ActiveFountainColor = SulphuricDepthsWater.Instance.Slot;
}
}
@@ -53,7 +58,6 @@ namespace CalamityMod.Tiles.Abyss
public override void RandomUpdate(int i, int j)
{
int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143));
int nearbyVineCount = 0;
for (int x = i - 15; x <= i + 15; x++)
@@ -130,93 +134,7 @@ namespace CalamityMod.Tiles.Abyss
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
}
}
+20 -217
View File
@@ -7,23 +7,26 @@ using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Abyss
{
public class Voidstone : ModTile
public class Voidstone : GlowMaskTile
{
public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f };
internal static FramedGlowMask GlowMask;
public override void SetStaticDefaults()
public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/Voidstone_Glowmask";
public GrayscaleTexture2D NoiseTexture;
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Abyss/Voidstone_Glowmask", 18, 18);
NoiseTexture = new("CalamityMod/ExtraTextures/GreyscaleGradients/BlobbyNoise");
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileBrick[Type] = true;
Main.tileBrick[Type] = true;
CalamityUtils.MergeWithGeneral(Type);
CalamityUtils.MergeWithAbyss(Type);
@@ -39,6 +42,12 @@ namespace CalamityMod.Tiles.Abyss
this.RegisterUniversalMerge(ModContent.TileType<PyreMantle>(), "CalamityMod/Tiles/Merges/PyreMantleMerge");
}
public override void OnUnload()
{
NoiseTexture?.Unload();
NoiseTexture = null;
}
int animationFrameWidth = 234;
public override bool CreateDust(int i, int j, ref int type)
@@ -76,221 +85,15 @@ namespace CalamityMod.Tiles.Abyss
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
if (GlowMask.Texture is null)
return;
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = 0;
int relativeXPos = i % 4;
int relativeYPos = j % 4;
switch (relativeXPos)
{
case 0:
switch (relativeYPos)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 1:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 2;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 2:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 3:
switch (relativeYPos)
{
case 0:
xOffset = 1;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 0;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
}
xOffset *= 234;
xPos += xOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(255, 255, 255, 255));
Tile trackTile = Main.tile[i, j];
float brightness = 1f;
float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f;
brightness *= (float)MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= 0.5f;
drawColour *= brightness;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
int time = (int)(Main.timeForVisualEffects * 0.11);
float brightness = 1.0f - NoiseTexture.GetRepeat((i * 100) + time, (j * 100) + time);
brightness -= 0.55f;
return new Color(brightness, brightness, brightness);
}
}
}
+2 -87
View File
@@ -1,4 +1,5 @@
using CalamityMod.Dusts;
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.GameContent.Metadata;
@@ -81,93 +82,7 @@ namespace CalamityMod.Tiles.Astral
}
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 1;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_01_Low0(i, j);
}
public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
+6 -38
View File
@@ -5,23 +5,21 @@ using CalamityMod.Tiles.Astral;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles
{
public class AstralBrick : ModTile
public class AstralBrick : GlowMaskTile
{
private const short subsheetWidth = 324;
private const short subsheetHeight = 90;
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/AstralBrickGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/AstralBrickGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = SoundID.Tink;
@@ -50,39 +48,9 @@ namespace CalamityMod.Tiles
frameYOffset = yPos * subsheetHeight;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = i % 2;
int yOffset = j % 2;
xOffset *= subsheetWidth;
yOffset *= subsheetHeight;
xPos += xOffset;
yPos += yOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(50, 50, 50, 50));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return new Color(50, 50, 50);
}
}
}
@@ -1,4 +1,5 @@
using CalamityMod.Items.Placeables.Furniture.Fountains;
using CalamityMod.Waters;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
@@ -15,7 +16,7 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void NearbyEffects(int i, int j, bool closer)
{
if (!Main.dedServ && Main.tile[i, j].TileFrameX >= 36)
Main.SceneMetrics.ActiveFountainColor = ModContent.Find<ModWaterStyle>("CalamityMod/VoidWater").Slot;
Main.SceneMetrics.ActiveFountainColor = VoidWater.Instance.Slot;
}
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true;
@@ -1,5 +1,6 @@
using CalamityMod.Dusts;
using CalamityMod.Items.Placeables.Furniture.Fountains;
using CalamityMod.Waters;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
@@ -16,7 +17,7 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void NearbyEffects(int i, int j, bool closer)
{
if (!Main.dedServ && Main.tile[i, j].TileFrameX >= 36)
Main.SceneMetrics.ActiveFountainColor = ModContent.Find<ModWaterStyle>("CalamityMod/AstralWater").Slot;
Main.SceneMetrics.ActiveFountainColor = AstralWater.Instance.Slot;
}
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true;
@@ -1,4 +1,5 @@
using CalamityMod.Items.Placeables.Furniture.Fountains;
using CalamityMod.Waters;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
@@ -16,7 +17,7 @@ namespace CalamityMod.Tiles.Furniture.Fountains
{
string waterColor = Main.zenithWorld ? "CalamityMod/PissWater" : "CalamityMod/SulphuricWater";
if (!Main.dedServ && Main.tile[i, j].TileFrameX >= 36)
Main.SceneMetrics.ActiveFountainColor = ModContent.Find<ModWaterStyle>(waterColor).Slot;
Main.SceneMetrics.ActiveFountainColor = Main.zenithWorld ? PissWater.Instance.Slot : SulphuricWater.Instance.Slot;
}
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true;
@@ -1,4 +1,5 @@
using CalamityMod.Items.Placeables.Furniture.Fountains;
using CalamityMod.Waters;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
@@ -15,7 +16,7 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void NearbyEffects(int i, int j, bool closer)
{
if (!Main.dedServ && Main.tile[i, j].TileFrameX >= 36)
Main.SceneMetrics.ActiveFountainColor = ModContent.Find<ModWaterStyle>("CalamityMod/SunkenSeaWater").Slot;
Main.SceneMetrics.ActiveFountainColor = BasaltGullyWater.Type;
}
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true;
+6 -31
View File
@@ -3,19 +3,18 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureAshen
{
public class SmoothBrimstoneSlag : ModTile
public class SmoothBrimstoneSlag : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAshen/SmoothBrimstoneSlagGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureAshen/SmoothBrimstoneSlagGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = false;
Main.tileBlockLight[Type] = true;
@@ -37,33 +36,9 @@ namespace CalamityMod.Tiles.FurnitureAshen
return false;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(25, 25, 25, 25));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return new Color(25, 25, 25);
}
}
}
@@ -4,19 +4,18 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureAuric
{
public class ActivatedAuricPanelTile : ModTile
public class ActivatedAuricPanelTile : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAuric/ActivatedAuricPanelTile_Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureAuric/ActivatedAuricPanelTile_Glow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = AuricOre.MineSound;
@@ -31,35 +30,11 @@ namespace CalamityMod.Tiles.FurnitureAuric
return false;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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.White);
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
return Color.White;
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
+2 -7
View File
@@ -23,15 +23,10 @@ namespace CalamityMod.Tiles.FurnitureAuric
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
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;
var tileCache = Main.tile[i, j];
Color drawColour = GetDrawColour(i, j, Color.White);
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, TextureAssets.Tile[Type].Value, drawOffset, null, GetDrawColour(i, j, drawColour), default);
TileFramingSystem.SlopedGlowmask(in tileCache, i, j, TextureAssets.Tile[Type].Value, null, GetDrawColour(i, j, drawColour), default);
}
private Color GetDrawColour(int i, int j, Color colour)
+6 -31
View File
@@ -4,19 +4,18 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureAuric
{
public class AuricRepulserPanelTile : ModTile
public class AuricRepulserPanelTile : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAuric/AuricRepulserPanelTile_Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureAuric/AuricRepulserPanelTile_Glow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = AuricOre.MineSound;
@@ -31,35 +30,11 @@ namespace CalamityMod.Tiles.FurnitureAuric
return false;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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.White);
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
return Color.White;
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
+6 -31
View File
@@ -4,19 +4,18 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureAuric
{
public class ExoAuricPanelTile : ModTile
public class ExoAuricPanelTile : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAuric/ExoAuricPanelTile_Glow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureAuric/ExoAuricPanelTile_Glow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = AuricOre.MineSound;
@@ -31,35 +30,11 @@ namespace CalamityMod.Tiles.FurnitureAuric
return false;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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.White);
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
return Color.White;
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
+6 -32
View File
@@ -3,19 +3,18 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureCosmilite
{
public class CosmiliteBrick : ModTile
public class CosmiliteBrick : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureCosmilite/CosmiliteBrickGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureCosmilite/CosmiliteBrickGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = SoundID.Tink;
@@ -30,34 +29,9 @@ namespace CalamityMod.Tiles.FurnitureCosmilite
return false;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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.White);
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White;
}
}
}
+6 -35
View File
@@ -4,19 +4,18 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureExo
{
public class ExoPlatingTile : ModTile
public class ExoPlatingTile : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureExo/ExoPlatingTileGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureExo/ExoPlatingTileGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -43,37 +42,9 @@ namespace CalamityMod.Tiles.FurnitureExo
frameYOffset = yPos * AnimationFrameHeight;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
// If the cached textures don't exist for some reason, don't bother using them.
if (GlowMask.Texture is null)
return;
Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j);
int xPos = tile.TileFrameX;
int frameOffset = j % 2 * AnimationFrameHeight;
int yPos = tile.TileFrameY + frameOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
Color drawColour = GetDrawColour(i, j, Color.White);
Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White;
}
}
}
+6 -35
View File
@@ -4,19 +4,18 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureExo
{
public class ExoPrismPanelTile : ModTile
public class ExoPrismPanelTile : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureExo/ExoPrismPanelTileGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureExo/ExoPrismPanelTileGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -43,37 +42,9 @@ namespace CalamityMod.Tiles.FurnitureExo
frameYOffset = frameOffset * AnimationFrameHeight;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
// If the cached textures don't exist for some reason, don't bother using them.
if (GlowMask.Texture is null)
return;
Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j);
int xPos = tile.TileFrameX;
int frameOffset = (i + j) % 6 * AnimationFrameHeight;
int yPos = tile.TileFrameY + frameOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
Color drawColour = GetDrawColour(i, j, Color.White);
Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White;
}
}
}
+9 -33
View File
@@ -3,19 +3,18 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurniturePlaguedPlate
{
public class PlaguedPlate : ModTile
public class PlaguedPlate : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurniturePlaguedPlate/PlaguedPlateGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurniturePlaguedPlate/PlaguedPlateGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
HitSound = SoundID.Tink;
@@ -34,37 +33,14 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate
num = fail ? 1 : 3;
}
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
return new Color(128, 128, 128);
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
return TileFramingSystem.BrimstoneFraming(i, j, resetFrame);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(128, 128, 128, 128));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
}
}
}
+11 -209
View File
@@ -4,19 +4,20 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureProfaned
{
public class ProfanedRock : ModTile
public class ProfanedRock : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public const int AnimationFrameWidth = 288;
public override void SetStaticDefaults()
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureProfaned/ProfanedRockGlow";
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureProfaned/ProfanedRockGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -30,7 +31,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned
MinPick = 225;
AddMapEntry(new Color(84, 38, 33));
}
int animationFrameWidth = 288;
public override bool CreateDust(int i, int j, ref int type)
{
@@ -41,212 +43,12 @@ namespace CalamityMod.Tiles.FurnitureProfaned
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = AnimationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
if (GlowMask.Texture is null)
return;
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = 0;
int relativeXPos = i % 4;
int relativeYPos = j % 4;
switch (relativeXPos)
{
case 0:
switch (relativeYPos)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 1:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 2;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 2:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 3:
switch (relativeYPos)
{
case 0:
xOffset = 1;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 0;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
}
xOffset *= 288;
xPos += xOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(25, 25, 25, 25));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White * 0.098f;
}
}
}
+9 -39
View File
@@ -4,19 +4,20 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureProfaned
{
public class RunicProfanedBrick : ModTile
public class RunicProfanedBrick : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public const int AnimationFrameWidth = 234;
public override void SetStaticDefaults()
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureProfaned/RunicProfanedBrickGlow";
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureProfaned/RunicProfanedBrickGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -29,7 +30,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned
AddMapEntry(new Color(122, 66, 59));
AnimationFrameHeight = 90;
}
int animationFrameWidth = 234;
public override bool CreateDust(int i, int j, ref int type)
{
@@ -40,43 +40,13 @@ namespace CalamityMod.Tiles.FurnitureProfaned
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
frameXOffset = i % 2 * animationFrameWidth;
frameXOffset = i % 2 * AnimationFrameWidth;
frameYOffset = j % 2 * AnimationFrameHeight;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = i % 2;
int yOffset = j % 2;
xOffset *= animationFrameWidth;
yOffset *= AnimationFrameHeight;
xPos += xOffset;
yPos += yOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(128, 128, 128, 128));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White * 0.5f;
}
}
}
+9 -34
View File
@@ -3,19 +3,18 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureStratus
{
public class StratusBricks : ModTile
public class StratusBricks : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureStratus/StratusBricksGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureStratus/StratusBricksGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
TileID.Sets.HasSlopeFrames[Type] = true;
@@ -34,38 +33,14 @@ namespace CalamityMod.Tiles.FurnitureStratus
return false;
}
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
return new Color(100, 100, 100);
}
public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
{
return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
Color drawColour = GetDrawColour(i, j, new Color(100, 100, 100, 100));
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;
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
}
}
}
+14 -213
View File
@@ -4,19 +4,18 @@ using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureVoid
{
public class SmoothVoidstone : ModTile
public class SmoothVoidstone : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureVoid/SmoothVoidstoneGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/FurnitureVoid/SmoothVoidstoneGlow", 18, 18);
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -30,6 +29,7 @@ namespace CalamityMod.Tiles.FurnitureVoid
MineResist = 2.1f;
AddMapEntry(new Color(27, 24, 31));
}
int animationFrameWidth = 288;
public override bool CreateDust(int i, int j, ref int type)
@@ -40,217 +40,18 @@ namespace CalamityMod.Tiles.FurnitureVoid
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 1;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 1;
break;
default:
uniqueAnimationFrameX = 0;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_01_Low0(i, j);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = 0;
int relativeXPos = i % 4;
int relativeYPos = j % 4;
switch (relativeXPos)
{
case 0:
switch (relativeYPos)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 1;
break;
default:
xOffset = 0;
break;
}
break;
case 1:
switch (relativeYPos)
{
case 0:
xOffset = 1;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 1;
break;
default:
xOffset = 0;
break;
}
break;
case 2:
switch (relativeYPos)
{
case 0:
xOffset = 1;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 0;
break;
case 3:
xOffset = 1;
break;
default:
xOffset = 0;
break;
}
break;
case 3:
switch (relativeYPos)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = 1;
break;
case 2:
xOffset = 0;
break;
case 3:
xOffset = 1;
break;
default:
xOffset = 0;
break;
}
break;
}
xOffset *= 288;
xPos += xOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(255, 255, 255, 255));
Tile trackTile = Main.tile[i, j];
float brightness = 1f;
float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f;
brightness *= (float)MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes);
drawColour *= brightness;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
float brightness = 1f;
float timeFactor = Main.GameUpdateCount * 0.007f;
brightness *= (float)MathF.Sin(i / 18f + timeFactor);
brightness *= (float)MathF.Sin(j / 18f + timeFactor);
brightness *= (float)MathF.Sin(i * 18f + timeFactor);
brightness *= (float)MathF.Sin(j * 18f + timeFactor);
return Color.White * brightness;
}
}
}
+10 -153
View File
@@ -1,14 +1,18 @@
using Microsoft.Xna.Framework;
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.FurnitureVoid
{
public class VoidstoneSlab : ModTile
public class VoidstoneSlab : GlowMaskTile
{
public override void SetStaticDefaults()
public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureVoid/VoidstoneSlabGlow";
public override void SetupStatic()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
@@ -28,159 +32,12 @@ namespace CalamityMod.Tiles.FurnitureVoid
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrame = Main.tileFrame[Type] + i;
int xPos = i % 3;
int yPos = j % 3;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrame = 0;
break;
case 1:
uniqueAnimationFrame = 1;
break;
case 2:
uniqueAnimationFrame = 2;
break;
default:
uniqueAnimationFrame = 0;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrame = 2;
break;
case 1:
uniqueAnimationFrame = 3;
break;
case 2:
uniqueAnimationFrame = 4;
break;
default:
uniqueAnimationFrame = 0;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrame = 4;
break;
case 1:
uniqueAnimationFrame = 0;
break;
case 2:
uniqueAnimationFrame = 1;
break;
default:
uniqueAnimationFrame = 0;
break;
}
break;
}
frameYOffset = uniqueAnimationFrame * AnimationFrameHeight;
frameYOffset = AnimationFrameHeight * TileFramingSystem.GetVariation3x3_01234_Low3(i, j);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
if (Main.tile[i, j].TileType == ModContent.TileType<VoidstoneSlab>())
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int yOffset = 0;
int relavtiveXPos = i % 3;
int relavtiveYPos = j % 3;
switch (relavtiveXPos)
{
case 0:
switch (relavtiveYPos)
{
case 0:
yOffset = 0;
break;
case 1:
yOffset = 1;
break;
case 2:
yOffset = 2;
break;
default:
yOffset = 0;
break;
}
break;
case 1:
switch (relavtiveYPos)
{
case 0:
yOffset = 2;
break;
case 1:
yOffset = 3;
break;
case 2:
yOffset = 4;
break;
default:
yOffset = 0;
break;
}
break;
case 2:
switch (relavtiveYPos)
{
case 0:
yOffset = 4;
break;
case 1:
yOffset = 0;
break;
case 2:
yOffset = 1;
break;
default:
yOffset = 0;
break;
}
break;
}
yOffset *= 270;
yPos += yOffset;
Texture2D glowmask = ModContent.Request<Texture2D>("CalamityMod/Tiles/FurnitureVoid/VoidstoneSlabGlow").Value;
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, new Color(75, 75, 75, 75));
Tile trackTile = Main.tile[i, j];
if (!trackTile.IsHalfBlock && trackTile.Slope == 0)
{
Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
else if (trackTile.IsHalfBlock)
{
Main.spriteBatch.Draw(glowmask, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return new Color(75, 75, 75);
}
}
}
+6 -22
View File
@@ -13,17 +13,14 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles
{
public class GiantPlanteraBulb : ModTile
public class GiantPlanteraBulb : GlowMaskTile
{
public static FramedGlowMask GlowMask { get; private set; }
public override string GlowMaskAsset => $"{Texture}Glow";
public override void Load()
public override void SetupStatic()
{
GlowMask = new($"{Texture}Glow", 18, 18);
}
GlowMaskPaintInteraction = PaintColorTint.None;
public override void SetStaticDefaults()
{
// Tile can provide light
Main.tileLighted[Type] = true;
@@ -192,22 +189,9 @@ namespace CalamityMod.Tiles
}
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
var tile = Main.tile[i, j];
var xPos = tile.TileFrameX;
var yPos = tile.TileFrameY + AnimationFrameHeight * Main.tileFrame[Type];
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
spriteBatch.Draw(
GlowMask.Texture,
new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + CalamityUtils.TileDrawOffset,
new Rectangle(xPos, yPos, 16, 16),
Color.Yellow
);
}
return Color.Yellow;
}
}
}
+81
View File
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles
{
public abstract class GlowMaskTile : ModTile
{
public enum PaintColorTint
{
OnlyByDeepPaint,
ByEveryPaint,
None,
}
public FramedMaskTexture GlowMask;
internal static GlowMaskTile[] InstanceLookup; // This Lookup is Array for performances sake
internal static int LookupLength;
public PaintColorTint GlowMaskPaintInteraction = PaintColorTint.OnlyByDeepPaint;
public abstract string GlowMaskAsset { get; }
public sealed override void SetStaticDefaults()
{
if (GlowMask != null)
{
CalamityMod.Instance.Logger.Error($"{Name} has called {nameof(SetStaticDefaults)} themselve! This is not allowed!");
return;
}
GlowMask = new(GlowMaskAsset, 18, 18);
InstanceLookup ??= new GlowMaskTile[TileLoader.TileCount];
LookupLength = InstanceLookup.Length;
InstanceLookup[Type] = this;
SetupStatic();
}
public sealed override void Unload()
{
GlowMask?.Unload();
GlowMask = null;
InstanceLookup = null;
OnUnload();
}
public virtual void SetupStatic() { }
public virtual void OnUnload() { }
public abstract Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData);
public static Color ApplyPaint(int paintType, Color color, bool deepPaintOnly = true)
{
if (deepPaintOnly && !IsDeepPaint(paintType))
return color;
Color paintCol = WorldGen.paintColor(paintType);
color = color.MultiplyRGB(paintCol);
return color;
}
private static bool IsDeepPaint(int paintType)
{
return PaintID.DeepRedPaint <= paintType && paintType <= PaintID.DeepPinkPaint;
}
}
}
+8 -183
View File
@@ -1,12 +1,10 @@

using System.Collections.Generic;
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Ores
@@ -70,199 +68,26 @@ namespace CalamityMod.Tiles.Ores
}
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
if (GlowTexture is null)
return;
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = 0;
int relativeXPos = i % 4;
int relativeYPos = j % 4;
switch (relativeXPos)
{
case 0:
switch (relativeYPos)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 1:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 2;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 2:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 3:
switch (relativeYPos)
{
case 0:
xOffset = 1;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 0;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
}
xOffset *= 234;
var tile = Main.tile[i, j];
int xPos = tile.TileFrameX;
int yPos = tile.TileFrameY;
int xOffset = animationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
xPos += xOffset;
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, new Color(100, 100, 100, 50));
Tile trackTile = Main.tile[i, j];
if (!trackTile.IsHalfBlock && trackTile.Slope == 0)
if (!tile.IsHalfBlock && tile.Slope == 0)
{
Main.spriteBatch.Draw(GlowTexture, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
else if (trackTile.IsHalfBlock)
else if (tile.IsHalfBlock)
{
Main.spriteBatch.Draw(GlowTexture, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
}
+2 -87
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -59,93 +60,7 @@ namespace CalamityMod.Tiles.Ores
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * AnimationFrameWidth;
frameXOffset = AnimationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
}
}
+5 -32
View File
@@ -15,18 +15,15 @@ using Terraria.ObjectData;
namespace CalamityMod.Tiles.Ores
{
public class AuricOre : ModTile
public class AuricOre : GlowMaskTile
{
public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AuricMine", 3);
public static bool Animate;
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Ores/AuricOreGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Ores/AuricOreGlow", 18, 18);
AnimationFrameHeight = 90;
Main.tileLighted[Type] = true;
Main.tileSolid[Type] = true;
@@ -86,33 +83,9 @@ namespace CalamityMod.Tiles.Ores
}
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY + AnimationFrameHeight * Main.tileFrame[Type];
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(225, 255, 255, 255));
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White;
}
}
}
+12 -210
View File
@@ -7,20 +7,21 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Ores
{
public class PerennialOre : ModTile
public class PerennialOre : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public const int AnimationFrameWidth = 234;
public override void SetStaticDefaults()
public override string GlowMaskAsset => "CalamityMod/Tiles/Ores/PerennialOreGlow";
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Ores/PerennialOreGlow", 18, 18);
Main.tileLighted[Type] = true;
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
@@ -46,7 +47,9 @@ namespace CalamityMod.Tiles.Ores
this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge");
}
int animationFrameWidth = 234;
public override bool CanExplode(int i, int j)
{
@@ -107,213 +110,12 @@ namespace CalamityMod.Tiles.Ores
public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
{
int uniqueAnimationFrameX = 0;
int xPos = i % 4;
int yPos = j % 4;
switch (xPos)
{
case 0:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 0;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 1:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 2;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 2:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 2;
break;
case 1:
uniqueAnimationFrameX = 0;
break;
case 2:
uniqueAnimationFrameX = 1;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
case 3:
switch (yPos)
{
case 0:
uniqueAnimationFrameX = 1;
break;
case 1:
uniqueAnimationFrameX = 2;
break;
case 2:
uniqueAnimationFrameX = 0;
break;
case 3:
uniqueAnimationFrameX = 2;
break;
default:
uniqueAnimationFrameX = 2;
break;
}
break;
}
frameXOffset = uniqueAnimationFrameX * animationFrameWidth;
frameXOffset = AnimationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
if (GlowMask.Texture is null)
return;
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
int xOffset = 0;
int relativeXPos = i % 4;
int relativeYPos = j % 4;
switch (relativeXPos)
{
case 0:
switch (relativeYPos)
{
case 0:
xOffset = 0;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 1:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 2;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 2:
switch (relativeYPos)
{
case 0:
xOffset = 2;
break;
case 1:
xOffset = 0;
break;
case 2:
xOffset = 1;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
case 3:
switch (relativeYPos)
{
case 0:
xOffset = 1;
break;
case 1:
xOffset = 2;
break;
case 2:
xOffset = 0;
break;
case 3:
xOffset = 2;
break;
default:
xOffset = 2;
break;
}
break;
}
xOffset *= 234;
xPos += xOffset;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(175, 175, 175, 175));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White * 0.686f;
}
}
}
+5 -31
View File
@@ -13,14 +13,12 @@ using Terraria.ModLoader;
namespace CalamityMod.Tiles.Ores
{
[LegacyName("ChaoticOre")]
public class ScoriaOre : ModTile
public class ScoriaOre : GlowMaskTile
{
internal static FramedGlowMask GlowMask;
public override string GlowMaskAsset => "CalamityMod/Tiles/Ores/ScoriaOreGlow";
public override void SetStaticDefaults()
public override void SetupStatic()
{
GlowMask = new("CalamityMod/Tiles/Ores/ScoriaOreGlow", 18, 18);
Main.tileLighted[Type] = true;
Main.tileSolid[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -91,34 +89,10 @@ namespace CalamityMod.Tiles.Ores
g = 0.00f;
b = 0.00f;
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
{
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
if (GlowMask.HasContentInFramePos(xPos, yPos))
{
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, new Color(50, 50, 50, 50));
Tile trackTile = Main.tile[i, j];
double num6 = Main.time * 0.08;
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowMask.Texture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
}
private Color GetDrawColour(int i, int j, Color colour)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
return Color.White * 0.195f;
}
}
}
+19 -47
View File
@@ -1,30 +1,26 @@

using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Tiles.Plates
{
public class Cinderplate : ModTile
public class Cinderplate : GlowMaskTile
{
public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/CinderplateGlow";
public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3);
internal static Texture2D GlowTexture;
internal static Texture2D PulseTexture;
internal static Color[] PulseColors;
public override void SetStaticDefaults()
internal static GrayscaleTexture1D PulseGradient;
public override void SetupStatic()
{
if (!Main.dedServ)
{
PulseTexture = ModContent.Request<Texture2D>("CalamityMod/Tiles/Plates/CinderplatePulse", AssetRequestMode.ImmediateLoad).Value;
PulseColors = new Color[PulseTexture.Width];
Main.QueueMainThreadAction(() => PulseTexture.GetData(PulseColors));
GlowTexture = ModContent.Request<Texture2D>("CalamityMod/Tiles/Plates/CinderplateGlow", AssetRequestMode.ImmediateLoad).Value;
}
PulseGradient = new("CalamityMod/Tiles/Plates/CinderplatePulse");
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
@@ -36,6 +32,12 @@ namespace CalamityMod.Tiles.Plates
AddMapEntry(new Color(242, 216, 131));
}
public override void OnUnload()
{
PulseGradient?.Unload();
PulseGradient = null;
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Torch, 0f, 0f, 1, new Color(255, 255, 255), 1f);
@@ -48,41 +50,11 @@ namespace CalamityMod.Tiles.Plates
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Torch, 0f, 0f, 1, new Color(255, 255, 255), 1f);
}
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData)
{
// If the cached textures don't exist for some reason, don't bother using them.
if (GlowTexture is null || PulseTexture is null)
return;
int xPos = Main.tile[i, j].TileFrameX;
int yPos = Main.tile[i, j].TileFrameY;
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;
// Glowmask 'pulse' effect
int factor = (int)Main.GameUpdateCount % PulseTexture.Width;
float brightness = PulseColors[factor].R / 255f;
int drawBrightness = (int)(40 * brightness) + 10;
Color drawColour = GetDrawColour(i, j, new Color(drawBrightness, drawBrightness, drawBrightness, drawBrightness));
// If these tiles cause lag, comment out the pulse effect code and uncomment this:
//Color drawColour = GetDrawColour(i, j, new Color(50, 50, 50, 50));
Tile trackTile = Main.tile[i, j];
TileFramingSystem.SlopedGlowmask(i, j, 0, GlowTexture, drawOffset, null, GetDrawColour(i, j, drawColour), default);
}
private Color GetDrawColour(int i, int j, Color colour)
{
int colType = Main.tile[i, j].TileColor;
Color paintCol = WorldGen.paintColor(colType);
if (colType >= 13 && colType <= 24)
{
colour.R = (byte)(paintCol.R / 255f * colour.R);
colour.G = (byte)(paintCol.G / 255f * colour.G);
colour.B = (byte)(paintCol.B / 255f * colour.B);
}
return colour;
float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount);
brightness = 0.04f + (brightness * 0.156f);
return Color.White * brightness;
}
}
}
Loaded 100 of 150 files, more files were not shown because too many files have changed in this diff. Show more