Skip to content

Commit

Permalink
add visible imp wings to impish clicker
Browse files Browse the repository at this point in the history
  • Loading branch information
direwolf420 committed Dec 10, 2021
1 parent 1e983b6 commit f70c570
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 31 deletions.
101 changes: 70 additions & 31 deletions ClickerPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.Audio;
using ClickerClass.Buffs;

namespace ClickerClass
{
Expand Down Expand Up @@ -91,8 +90,16 @@ public partial class ClickerPlayer : ModPlayer
/// Used to track effect names that are currently active. Resets every tick
/// </summary>
private Dictionary<string, bool> ClickEffectActive = new Dictionary<string, bool>();

public bool effectHotWings = false;
public const int EffectHotWingsTimerMax = 90;
public const int EffectHotWingsTimerFadeStart = 30;
public int effectHotWingsTimer = 0; //Gets set to max, counts down

public const int EffectHotWingsFrameMax = 4;
public int effectHotWingsFrame = 0;

public bool DrawHotWings => effectHotWingsTimer > 0;

//Out of combat
public const int OutOfCombatTimeMax = 300;
Expand Down Expand Up @@ -729,48 +736,71 @@ public override void PostUpdateEquips()
//Hot Wings
if (effectHotWings)
{
int dashDir = 0;
if (Player.controlRight && Player.releaseRight)
{
clickerDoubleTap += clickerDoubleTap > 0 ? 0 : 15;
if (Player.controlRight && Player.releaseRight && clickerDoubleTap < 15 && clickerDoubleTap > 0)
if (clickerDoubleTap < 15 && clickerDoubleTap > 0)
{
SoundEngine.PlaySound(SoundID.Item, (int)Player.position.X, (int)Player.position.Y, 73);
Player.ClearBuff(ModContent.BuffType<HotWingsBuff>());
if (Player.velocity.Y > 0f){Player.velocity.Y = 0f;}
if (Player.velocity.X > 0f){Player.velocity.X = 0f;}
Player.velocity.Y -= 6f;
Player.velocity.X += 12f;
Player.direction = 1;
for (int k = 0; k < 15; k++)
{
Dust dust = Dust.NewDustDirect(Player.position, Player.width, Player.height, 174, Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f), 0, default, 1.25f);
dust.noGravity = true;
dust.noLight = true;
}
dashDir = 1;
}
}
if (Player.controlLeft && Player.releaseLeft)
else if (Player.controlLeft && Player.releaseLeft)
{
clickerDoubleTap += clickerDoubleTap > 0 ? 0 : 15;
if (Player.controlLeft && Player.releaseLeft && clickerDoubleTap < 15 && clickerDoubleTap > 0)
if (clickerDoubleTap < 15 && clickerDoubleTap > 0)
{
SoundEngine.PlaySound(SoundID.Item, (int)Player.position.X, (int)Player.position.Y, 73);
Player.ClearBuff(ModContent.BuffType<HotWingsBuff>());
if (Player.velocity.Y > 0f){Player.velocity.Y = 0f;}
if (Player.velocity.X > 0f){Player.velocity.X = 0f;}
Player.velocity.Y -= 6f;
Player.velocity.X -= 12f;
Player.direction = -1;
for (int k = 0; k < 15; k++)
{
Dust dust = Dust.NewDustDirect(Player.position, Player.width, Player.height, 174, Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f), 0, default, 1.25f);
dust.noGravity = true;
dust.noLight = true;
}
dashDir = -1;
}
}

if (Math.Abs(dashDir) == 1)
{
effectHotWingsTimer = EffectHotWingsTimerMax;

SoundEngine.PlaySound(SoundID.Item, (int)Player.position.X, (int)Player.position.Y, 73);
Player.ClearBuff(ModContent.BuffType<HotWingsBuff>());
//if (Player.velocity.Y > 0f) Player.velocity.Y = 0f;
//if (Player.velocity.X < 0f) Player.velocity.X = 0f;
Player.velocity.Y -= 6f;
Player.velocity.X = dashDir * 12f;
Player.ChangeDir(dashDir);

//Vanilla code
Point point3 = (Player.Center + new Vector2(dashDir * Player.width / 2 + 2, Player.gravDir * -Player.height / 2f + Player.gravDir * 2f)).ToTileCoordinates();
Point point4 = (Player.Center + new Vector2(dashDir * Player.width / 2 + 2, 0f)).ToTileCoordinates();
if (WorldGen.SolidOrSlopedTile(point3.X, point3.Y) || WorldGen.SolidOrSlopedTile(point4.X, point4.Y))
{
Player.velocity.X /= 2f;
}

for (int k = 0; k < 15; k++)
{
Dust dust = Dust.NewDustDirect(Player.position, Player.width, Player.height, 174, Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f), 0, default, 1.25f);
dust.noGravity = true;
dust.noLight = true;
}
}
}

if (effectHotWingsTimer > 0)
{
effectHotWingsTimer--;

if (effectHotWingsTimer % 6 == 0)
{
effectHotWingsFrame++;
if (effectHotWingsFrame >= EffectHotWingsFrameMax)
{
effectHotWingsFrame = 0;
}
}
}
else
{
effectHotWingsFrame = 0;
}

//Acc
//Cookie acc
if (accCookieItem != null && !accCookieItem.IsAir && (accCookie || accCookie2) && clickerSelected)
Expand Down Expand Up @@ -1124,5 +1154,14 @@ public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeath
// Don't count as in combat after death, in case respawn timer is less than OutOfCombatTimeMax
outOfCombatTimer = 0;
}

public override void HideDrawLayers(PlayerDrawSet drawInfo)
{
if (DrawHotWings)
{
//Hide the vanilla wings layer. Important that our own replacement layer is not attached to that, then it would get hidden aswell :failure:
PlayerDrawLayers.Wings.Hide();
}
}
}
}
81 changes: 81 additions & 0 deletions DrawLayers/HotWingsWingLayer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace ClickerClass.DrawLayers
{
public class HotWingsWingLayer : PlayerDrawLayer
{
private Asset<Texture2D> wingTexture;

public override void Load()
{
if (!Main.dedServ)
{
wingTexture = Mod.Assets.Request<Texture2D>("DrawLayers/HotWings_Wings");
}
}

public override void Unload()
{
wingTexture = null;
}

public override bool GetDefaultVisibility(PlayerDrawSet drawInfo)
{
Player drawPlayer = drawInfo.drawPlayer;
if (drawPlayer.dead)
{
return false;
}

return drawPlayer.GetModPlayer<ClickerPlayer>().DrawHotWings;
}

public override Position GetDefaultPosition()
{
return new BeforeParent(PlayerDrawLayers.JimsCloak); //First layer
}

protected override void Draw(ref PlayerDrawSet drawInfo)
{
//Mostly copied from vanilla
Player drawPlayer = drawInfo.drawPlayer;

Asset<Texture2D> asset = wingTexture;
Texture2D texture = asset.Value;

Vector2 directions = drawPlayer.Directions;
Vector2 offset = new Vector2(0f, 7f);
Vector2 position = drawInfo.Position - Main.screenPosition + new Vector2(drawPlayer.width / 2, drawPlayer.height - drawPlayer.bodyFrame.Height / 2) + offset;

int num11 = 0;
int num12 = 0;
ClickerPlayer clickerPlayer = drawPlayer.GetModPlayer<ClickerPlayer>();
int numFrames = ClickerPlayer.EffectHotWingsFrameMax;

float fade = 1f;

const int fadeStart = ClickerPlayer.EffectHotWingsTimerFadeStart;
int timer = clickerPlayer.effectHotWingsTimer;
if (timer < fadeStart)
{
fade = (float)timer / fadeStart;
}

Color mainColor = Color.Lerp(drawInfo.colorArmorBody, Color.White * fade, 0.4f);

Color color = /*drawInfo.colorArmorBody*/ drawPlayer.GetImmuneAlpha(mainColor, drawInfo.shadow);

position += new Vector2(num12 - 9, num11 + 2) * directions;
position = position.Floor();
Rectangle frame = new Rectangle(0, asset.Height() / numFrames * clickerPlayer.effectHotWingsFrame, asset.Width(), asset.Height() / numFrames);
DrawData data = new DrawData(texture, position.Floor(), frame, color, drawPlayer.bodyRotation, new Vector2(asset.Width() / 2, asset.Height() / numFrames / 2), 1f, drawInfo.playerEffect, 0);
//data.shader = drawInfo.cWings;
drawInfo.DrawDataCache.Add(data);
}
}
}
File renamed without changes

0 comments on commit f70c570

Please sign in to comment.