The Comb
This commit is contained in:
1 parent
e509242d8c
commit
249b077b35
6 files changed
+156
-1
No files matched your search
@@ -113,6 +113,7 @@ namespace CalamityMod.CalPlayer
|
||||
public float healingPotionMultiplier = 1f;
|
||||
public bool heldGaelsLastFrame = false;
|
||||
internal bool hadNanomachinesLastFrame = false;
|
||||
public bool combHair;
|
||||
public bool disableVoodooSpawns = false;
|
||||
public bool disablePerfCystSpawns = false;
|
||||
public bool disableHiveCystSpawns = false;
|
||||
@@ -1608,6 +1609,7 @@ namespace CalamityMod.CalPlayer
|
||||
ResetRogueStealth();
|
||||
|
||||
calamityBonusLuck = 0f;
|
||||
combHair = false;
|
||||
|
||||
// Reset adrenaline duration to default. If Draedon's Heart is equipped, it'll change itself every frame.
|
||||
AdrenalineDuration = CalamityUtils.SecondsToFrames(5);
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
using CalamityMod.Items.Accessories.Vanity;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.CalPlayer.DrawLayers
|
||||
{
|
||||
public class CombHairSparkleLayer : PlayerDrawLayer
|
||||
{
|
||||
public override Position GetDefaultPosition() => new BeforeParent(PlayerDrawLayers.LeinforsHairShampoo);
|
||||
|
||||
public override bool IsHeadLayer => true;
|
||||
|
||||
public override bool GetDefaultVisibility(PlayerDrawSet drawInfo)
|
||||
{
|
||||
Player drawPlayer = drawInfo.drawPlayer;
|
||||
CalamityPlayer modPlayer = drawPlayer.Calamity();
|
||||
|
||||
// Specific hair drawing requirements: Hair must be drawing with 20% lightness, and you're not bald
|
||||
bool canReceiveHairSparkles = (drawInfo.fullHair || drawInfo.hatHair || drawInfo.drawsBackHairWithoutHeadgear || drawPlayer.head == -1 || drawPlayer.head == 0) && Main.rgbToHsl(drawInfo.colorHead).Z > 0.2f;
|
||||
bool baldHairStyles = drawPlayer.hair == 12 || drawPlayer.hair == 76;
|
||||
return drawInfo.shadow == 0f && !drawPlayer.dead && !drawInfo.headOnlyRender && modPlayer.combHair && canReceiveHairSparkles && !baldHairStyles;
|
||||
}
|
||||
|
||||
protected override void Draw(ref PlayerDrawSet drawInfo)
|
||||
{
|
||||
Player drawPlayer = drawInfo.drawPlayer;
|
||||
|
||||
// 5% chance per frame any of this draws
|
||||
if (!Main.rand.NextBool(20))
|
||||
return;
|
||||
|
||||
// Search through the equipped index for the comb. We need this to get the right dye
|
||||
int dyeIndex = -1;
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (drawPlayer.armor[i].type == ModContent.ItemType<TheComb>())
|
||||
{
|
||||
dyeIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var shader = GameShaders.Armor.GetSecondaryShader(dyeIndex == -1 ? 0 : drawPlayer.dye[dyeIndex % 10].dye, drawPlayer);
|
||||
|
||||
// Now detect if there are chests nearby
|
||||
int LeftRange = Utils.Clamp((int)drawPlayer.MountedCenter.X / 16 - 60, 2, Main.maxTilesX - 2);
|
||||
int RightRange = Utils.Clamp((int)drawPlayer.MountedCenter.X / 16 + 60, 2, Main.maxTilesX - 2);
|
||||
int TopRange = Utils.Clamp((int)drawPlayer.MountedCenter.Y / 16 - 60, 2, Main.maxTilesY - 2);
|
||||
int BottomRange = Utils.Clamp((int)drawPlayer.MountedCenter.Y / 16 + 60, 2, Main.maxTilesY - 2);
|
||||
|
||||
float range = 50000f;
|
||||
Vector2 ChestPosition = Vector2.Zero;
|
||||
for (int i = LeftRange; i <= RightRange; i++)
|
||||
{
|
||||
for (int j = TopRange; j <= BottomRange; j++)
|
||||
{
|
||||
int PotentialChest = Chest.FindChestByGuessing(i, j);
|
||||
if (PotentialChest != -1 && !TileID.Sets.BasicDresser[Main.tile[i, j].TileType])
|
||||
{
|
||||
// Adjust position ot the center of the chest
|
||||
Chest chest = Main.chest[PotentialChest];
|
||||
Vector2 chestCenter = new Vector2(chest.x + 1, chest.y + 1) * 16f;
|
||||
float distance = Vector2.Distance(chestCenter, drawPlayer.MountedCenter);
|
||||
|
||||
if (distance < range)
|
||||
{
|
||||
range = distance;
|
||||
ChestPosition = chestCenter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!drawInfo.hatHair || Main.rand.NextBool())
|
||||
{
|
||||
Rectangle area = drawInfo.hatHair ? Utils.CenteredRectangle(drawInfo.Position + drawPlayer.Size * 0.5f + new Vector2(drawPlayer.direction * -10, drawPlayer.gravDir * -10f), new Vector2(5f, 5f))
|
||||
: Utils.CenteredRectangle(drawInfo.Position + drawPlayer.Size * 0.5f + new Vector2(0f, drawPlayer.gravDir * -20f), new Vector2(20f, 14f));
|
||||
|
||||
Dust sparkle = Dust.NewDustDirect(area.TopLeft(), area.Width, area.Height, DustID.GoldCoin, Alpha: 150, Scale: 0.3f);
|
||||
sparkle.fadeIn = 1f;
|
||||
sparkle.velocity = ChestPosition == Vector2.Zero ? (sparkle.velocity * 0.1f) : (ChestPosition - sparkle.position).SafeNormalize(Vector2.Zero);
|
||||
sparkle.noLight = true;
|
||||
sparkle.shader = shader;
|
||||
drawInfo.DustCache.Add(sparkle.dustIndex);
|
||||
}
|
||||
|
||||
// Back hair
|
||||
if (drawPlayer.velocity.X != 0f && drawInfo.backHairDraw)
|
||||
{
|
||||
Rectangle areaB = Utils.CenteredRectangle(drawInfo.Position + drawPlayer.Size * 0.5f + new Vector2(drawPlayer.direction * -14, 0f), new Vector2(4f, 30f));
|
||||
Dust sparkleB = Dust.NewDustDirect(areaB.TopLeft(), areaB.Width, areaB.Height, DustID.GoldCoin, Alpha: 150, Scale: 0.3f);
|
||||
sparkleB.fadeIn = 1f;
|
||||
sparkleB.velocity = ChestPosition == Vector2.Zero ? (sparkleB.velocity * 0.1f) : (ChestPosition - sparkleB.position).SafeNormalize(Vector2.Zero);
|
||||
sparkleB.noLight = true;
|
||||
sparkleB.shader = shader;
|
||||
drawInfo.DustCache.Add(sparkleB.dustIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Accessories.Vanity
|
||||
{
|
||||
public class TheComb : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Accessories";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 40;
|
||||
Item.height = 42;
|
||||
Item.accessory = true;
|
||||
Item.value = CalamityGlobalItem.RarityBlueBuyPrice;
|
||||
Item.rare = ItemRarityID.Blue;
|
||||
Item.vanity = true;
|
||||
}
|
||||
|
||||
public override void UpdateVanity(Player player) => player.Calamity().combHair = true;
|
||||
|
||||
public override void UpdateAccessory(Player player, bool hideVisual)
|
||||
{
|
||||
if (!hideVisual)
|
||||
player.Calamity().combHair = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 887 B |
@@ -2079,6 +2079,11 @@ SharkyPlush: {
|
||||
Tooltip: "[c/696969:'Look around, at the sight and sound...']"
|
||||
}
|
||||
|
||||
TheComb: {
|
||||
DisplayName: The Comb
|
||||
Tooltip: '''"We ain't found shit!"'''
|
||||
}
|
||||
|
||||
XyksBlessingBlue: {
|
||||
DisplayName: Xyk's Blessing (Blue)
|
||||
Tooltip:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using CalamityMod.Items.Accessories.Vanity;
|
||||
using CalamityMod.Items.SummonItems;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.World;
|
||||
@@ -573,7 +574,7 @@ namespace CalamityMod.Systems
|
||||
}
|
||||
}
|
||||
|
||||
// Adds Desert Medallion to Sandstone Chests at a 20% chance
|
||||
// Adds Desert Medallion and The Comb to Sandstone Chests, each at a 20% chance
|
||||
if (isSandstoneChest)
|
||||
{
|
||||
float rng = WorldGen.genRand.NextFloat();
|
||||
@@ -589,6 +590,18 @@ namespace CalamityMod.Systems
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rng < 0.4f)
|
||||
{
|
||||
for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++)
|
||||
{
|
||||
if (chest.item[inventoryIndex].IsAir)
|
||||
{
|
||||
chest.item[inventoryIndex].SetDefaults(ModContent.ItemType<TheComb>());
|
||||
chest.item[inventoryIndex].stack = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user