Beginnings

This commit is contained in:
Xhack committed 2024-08-04 02:37:19 -04:00
1 parent ac72dccba0
commit 90c64c12af
4 files changed
+224

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

@@ -0,0 +1,123 @@
using CalamityMod.NPCs.OldDuke;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.ForegroundDrawing.LoopingTextures
{
public abstract class LoopingTextureForeground : ModSystem
{
public virtual string Texture => "CalamityMod/ExtraTextures/Miscellaneous/NuclearTorrent";
/// <summary>
/// How much the effect has moved. Increments by Speed.
/// </summary>
float Progress = 0f;
/// <summary>
/// The speed at which Progress is incremented every frame.
/// </summary>
public virtual float Speed => 60f;
/// <summary>
/// How opaque the visual is. Caps out at IntensityMaximum.
/// </summary>
public float Intensity = 0f;
/// <summary>
/// How opaque the visual can become before capping out.
/// </summary>
public virtual float IntensityMaximum => 0.15f;
/// <summary>
/// Current parallax.
/// </summary>
Vector2 Parallax = Vector2.Zero;
/// <summary>
/// Current parallax depth.
/// </summary>
public virtual Vector2 ParallaxDepth => Vector2.Zero;
/// <summary>
/// When true, the Intensity will increase until it caps out. If false it will decrease until it hits 0.
/// </summary>
/// <returns>Whether or not the visual is active.</returns>
public virtual bool DoesThisShow()
{
return false;
}
public override void PostDrawTiles()
{
if (DoesThisShow())
{
Intensity = MathHelper.Lerp(Intensity, IntensityMaximum, 0.1f);
}
else
{
Intensity = MathHelper.Lerp(Intensity, 0, 0.1f);
}
Intensity = MathHelper.Clamp(Intensity, 0f, 1f);
Parallax += Main.LocalPlayer.velocity * ParallaxDepth;
Progress += Speed;
Main.spriteBatch.Begin();
Draw();
PostDraw();
Main.spriteBatch.End();
Update();
}
public override void PostUpdateEverything()
{
Update();
}
/// <summary>
/// Extra drawing logic can be placed here.
/// </summary>
public virtual void PostDraw()
{
}
/// <summary>
/// Called every frame. Run behavior such as particle effects here.
/// </summary>
public virtual void Update()
{
}
/// <summary>
/// Override this to replace existing drawing logic. Only recommended if you know what you're doing.
/// </summary>
public virtual void Draw()
{
var tex = ModContent.Request<Texture2D>(Texture);
for (var i = -4; i < 14; i++)
{
float wid = tex.Width();
float hei = tex.Height();
var rect = new Rectangle(0, 0, (int)wid, (int)hei);
var rot = -Main.WindForVisuals;
var col = new Color(Intensity, Intensity, Intensity, 0f);
Main.EntitySpriteDraw(tex.Value, new Vector2(Parallax.X % wid, 0).RotatedBy(rot) + new Vector2(tex.Width() * i, 0).RotatedBy(rot), rect, col, rot, new Vector2(0, (hei - Progress) % hei), 1, SpriteEffects.None);
Main.EntitySpriteDraw(tex.Value, new Vector2(Parallax.X % wid, 0).RotatedBy(rot) + new Vector2(tex.Width() * i, -hei).RotatedBy(rot), rect, col, rot, new Vector2(0, (hei - Progress) % hei), 1, SpriteEffects.None);
Main.EntitySpriteDraw(tex.Value, new Vector2(Parallax.X % wid, 0).RotatedBy(rot) + new Vector2(tex.Width() * i, -hei * 2).RotatedBy(rot), rect, col, rot, new Vector2(0, (hei - Progress) % hei), 1, SpriteEffects.None);
}
}
}
}
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CalamityMod.NPCs.OldDuke;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.ForegroundDrawing.LoopingTextures
{
public class NuclearTorrentForeground : LoopingTextureForeground
{
public override Vector2 ParallaxDepth => new Vector2(1f, 1f);
public override float IntensityMaximum => 0.045f;
public static List<NuclearRaindrop> Raindrops = new List<NuclearRaindrop>();
public class NuclearRaindrop
{
public Vector2 Position;
public Vector2 Velocity;
public NuclearRaindrop(Vector2 pos, Vector2 vel)
{
Position = pos;
Velocity = vel;
}
public void Update(NuclearRaindrop drop, NuclearTorrentForeground foreground)
{
drop.Position += drop.Velocity;
drop.Position -= Main.LocalPlayer.velocity;
drop.Velocity = new Vector2(0, 20).RotatedBy(-Main.windSpeedCurrent);
if (drop.Position.Y > Main.screenHeight + 200)
{
RemoveDrop(drop);
}
}
public void Draw(NuclearRaindrop drop, NuclearTorrentForeground foreground)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/ForegroundDrawing/LoopingTextures/NuclearTorrentRaindrop");
float intensity = foreground.Intensity / foreground.IntensityMaximum / 4f;
Main.EntitySpriteDraw(tex.Value, drop.Position, tex.Frame(), Color.White.MultiplyRGBA(new Color(intensity, intensity, intensity, intensity)), Vector2.Zero.AngleTo(drop.Velocity) - MathHelper.ToRadians(90f), tex.Size() / 2, new Vector2(1f, 4f), SpriteEffects.None);
}
}
public static void RemoveDrop(NuclearRaindrop drop)
{
Raindrops.Remove(drop);
}
public override bool DoesThisShow() => NPC.CountNPCS(ModContent.NPCType<OldDuke>()) > 0 && Main.LocalPlayer.Calamity().ZoneSulphur;
public override void Update()
{
if (NPC.CountNPCS(ModContent.NPCType<OldDuke>()) > 0)
{
int duke = NPC.FindFirstNPC(ModContent.NPCType<OldDuke>());
Main.windSpeedCurrent = MathHelper.Lerp(Main.windSpeedCurrent, MathHelper.ToRadians(50f), 0.005f);
foreach (Rain rain in Main.rain)
{
rain.velocity = new Vector2(0, 15).RotatedBy(-Main.windSpeedCurrent);
rain.rotation = Vector2.Zero.AngleTo(rain.velocity) + MathHelper.PiOver2;
}
}
NuclearRaindrop dr = new NuclearRaindrop(new Vector2(Main.screenWidth / 2f, -100) + new Vector2(Main.rand.NextFloat(-Main.screenWidth, Main.screenWidth), -Main.screenWidth * 0.65f).RotatedBy(-Main.windSpeedCurrent),
new Vector2(0, 20).RotatedBy(-Main.windSpeedCurrent));
Raindrops.Add(dr);
for (int i = 0; i < Raindrops.Count; i++)
{
NuclearRaindrop drop = Raindrops[i];
drop.Update(drop, this);
}
}
public override void PostDraw()
{
for (int i = 0; i < Raindrops.Count; i++)
{
NuclearRaindrop drop = Raindrops[i];
drop.Draw(drop, this);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B