Enchantment icons

This commit is contained in:
Dominic committed 2021-06-15 12:26:44 -05:00
1 parent 7222901420
commit a3e5bebe41
29 files changed
+96 -32

No files matched your search

+2
View File
@@ -1024,6 +1024,7 @@ namespace CalamityMod.CalPlayer
public int witheredWeaponHoldTime = 0;
public bool persecutedEnchant = false;
public int persecutedEnchantSummonTimer = 0;
#endregion Calamitas Enchant Effects
#endregion
@@ -2427,6 +2428,7 @@ namespace CalamityMod.CalPlayer
animusBoost = 1f;
potionTimer = 0;
bloodflareCoreLostDefense = 0;
persecutedEnchantSummonTimer = 0;
if (BossRushEvent.BossRushActive)
{
+14
View File
@@ -22,6 +22,7 @@ using CalamityMod.NPCs.AcidRain;
using CalamityMod.NPCs.Astral;
using CalamityMod.NPCs.Crags;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.Other;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Environment;
@@ -1180,6 +1181,19 @@ namespace CalamityMod.CalPlayer
modPlayer.aBulwarkRareTimer--;
if (modPlayer.hellbornBoost > 0)
modPlayer.hellbornBoost--;
if (modPlayer.persecutedEnchantSummonTimer < 1800)
modPlayer.persecutedEnchantSummonTimer++;
else
{
modPlayer.persecutedEnchantSummonTimer = 0;
if (Main.myPlayer == player.whoAmI && player.Calamity().persecutedEnchant && NPC.CountNPCS(ModContent.NPCType<DemonPortal>()) < 2)
{
Vector2 spawnPosition = player.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(270f, 420f);
int portal = NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, ModContent.NPCType<DemonPortal>());
if (Main.npc.IndexInRange(portal))
Main.npc[portal].target = player.whoAmI;
}
}
if (player.miscCounter % 20 == 0)
modPlayer.canFireAtaxiaRangedProjectile = true;
if (player.miscCounter % 100 == 0)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

+30 -8
View File
@@ -22,7 +22,7 @@ namespace CalamityMod.UI.CalamitasEnchants
public static bool CurrentlyViewing = false;
public static readonly Vector2 ReforgeUITopLeft = new Vector2(28f, 245f);
public static readonly Vector2 ReforgeUITopLeft = new Vector2(68f, 320f);
public static readonly float ResolutionRatio = Main.screenHeight / 1440f;
public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f);
@@ -87,10 +87,6 @@ namespace CalamityMod.UI.CalamitasEnchants
// Draw the background.
spriteBatch.Draw(backgroundTexture, ReforgeUITopLeft, null, Color.White, 0f, Vector2.Zero, backgroundScale, SpriteEffects.None, 0f);
// Draw the item icon.
Vector2 itemSlotDrawPosition = ReforgeUITopLeft + new Vector2(30f, 50f) * backgroundScale;
Vector2 reforgeIconDrawPosition = ReforgeUITopLeft + new Vector2(88f, 60f) * backgroundScale;
// Prevent the player from say, firing a weapon while the mouse is hovering over the UI.
DisableMouseWhenOverUI(backgroundTexture, backgroundScale);
@@ -104,11 +100,20 @@ namespace CalamityMod.UI.CalamitasEnchants
Point costDrawPositionTopLeft = (ReforgeUITopLeft + new Vector2(50f, 78f) * backgroundScale).ToPoint();
cost = DrawEnchantmentCost(spriteBatch, costDrawPositionTopLeft);
Point descriptionDrawPositionTopLeft = costDrawPositionTopLeft;
descriptionDrawPositionTopLeft.Y += 90;
descriptionDrawPositionTopLeft.Y += 70;
Vector2 iconDrawPositionTopLeft = costDrawPositionTopLeft.ToVector2() + new Vector2(270f, -24f);
DrawEnchantmentDescription(spriteBatch, descriptionDrawPositionTopLeft);
if (!string.IsNullOrEmpty(SelectedEnchantment.Value.IconTexturePath))
{
Texture2D iconTexture = ModContent.GetTexture(SelectedEnchantment.Value.IconTexturePath);
DrawIcon(spriteBatch, iconDrawPositionTopLeft, iconTexture);
}
}
// Draw the item icon.
Vector2 itemSlotDrawPosition = ReforgeUITopLeft + new Vector2(30f, 50f) * backgroundScale;
Vector2 reforgeIconDrawPosition = ReforgeUITopLeft + new Vector2(84f, 60f) * backgroundScale;
DrawItemIcon(spriteBatch, itemSlotDrawPosition, reforgeIconDrawPosition, backgroundScale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon);
if (isHoveringOverItemIcon)
InteractWithItemSlot();
@@ -167,7 +172,18 @@ namespace CalamityMod.UI.CalamitasEnchants
if (SelectedEnchantment.HasValue && SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName)
cost = (int)MathHelper.Min(cost, Item.buyPrice(5)) * 5;
ItemSlot.DrawMoney(spriteBatch, "Cost: ", costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y, Utils.CoinsSplit(cost));
// Draw the coin costs.
string costText = "Cost: ";
Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, costText, costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y + 45f, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero);
costDrawPositionTopLeft.X += (int)(Main.fontMouseText.MeasureString(costText).X * 0.5f + 12f);
int[] coinsArray = Utils.CoinsSplit(cost);
for (int i = 0; i < 4; i++)
{
Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + ChatManager.GetStringSize(Main.fontMouseText, costText, Vector2.One, -1f).X + (24 * i) - 24f, costDrawPositionTopLeft.Y + 54f);
spriteBatch.Draw(Main.itemTexture[ItemID.PlatinumCoin - i], drawPosition, null, Color.White, 0f, Main.itemTexture[ItemID.PlatinumCoin - i].Size() * 0.5f, 1f, SpriteEffects.None, 0f);
Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
}
return cost;
}
@@ -176,7 +192,7 @@ namespace CalamityMod.UI.CalamitasEnchants
{
Vector2 vectorDrawPosition = descriptionDrawPositionTopLeft.ToVector2();
Vector2 scale = new Vector2(0.67f, 0.7f) * MathHelper.Clamp(ResolutionRatio, 0.825f, 1f);
foreach (string line in Utils.WordwrapString(SelectedEnchantment.Value.Description, Main.fontMouseText, 400, 10, out _))
foreach (string line in Utils.WordwrapString(SelectedEnchantment.Value.Description, Main.fontMouseText, 465, 10, out _))
{
if (string.IsNullOrEmpty(line))
continue;
@@ -186,6 +202,11 @@ namespace CalamityMod.UI.CalamitasEnchants
}
}
public static void DrawIcon(SpriteBatch spriteBatch, Vector2 drawPositionTopLeft, Texture2D texture)
{
spriteBatch.Draw(texture, drawPositionTopLeft, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
public static void DrawItemIcon(SpriteBatch spriteBatch, Vector2 itemSlotDrawPosition, Vector2 reforgeIconDrawPosition, Vector2 scale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon)
{
isHoveringOverReforgeIcon = false;
@@ -261,6 +282,7 @@ namespace CalamityMod.UI.CalamitasEnchants
// Attempt to exchange if the slot is clicked.
if (Main.mouseLeftRelease && Main.mouseLeft && (Main.mouseItem.CanBeEnchantedBySomething() || Main.mouseItem.IsAir))
{
EnchantIndex = 0;
Utils.Swap(ref Main.mouseItem, ref CurrentlyHeldItem);
Main.PlaySound(SoundID.Grab);
}
+7 -3
View File
@@ -7,6 +7,7 @@ namespace CalamityMod.UI.CalamitasEnchants
{
public string Name;
public string Description;
public string IconTexturePath;
public Action<Item> CreationEffect;
public Action<Player> HoldEffect;
@@ -15,7 +16,7 @@ namespace CalamityMod.UI.CalamitasEnchants
// This is internal because CanBeAppliedTo should be used over this field directly.
// Using that has the benefit of null checks and is objectively superior to using the raw delegate.
internal Predicate<Item> ApplyRequirement;
public Enchantment(string name, string description, int id, Action<Item> creationEffect, Action<Player> holdEffect, Predicate<Item> requirement)
public Enchantment(string name, string description, int id, string iconTexturePath, Action<Item> creationEffect, Action<Player> holdEffect, Predicate<Item> requirement)
{
Name = name;
Description = description;
@@ -23,8 +24,9 @@ namespace CalamityMod.UI.CalamitasEnchants
HoldEffect = holdEffect;
ApplyRequirement = requirement;
ID = id;
IconTexturePath = iconTexturePath;
}
public Enchantment(string name, string description, int id, Action<Player> holdEffect, Predicate<Item> requirement)
public Enchantment(string name, string description, int id, string iconTexturePath, Action<Player> holdEffect, Predicate<Item> requirement)
{
Name = name;
Description = description;
@@ -32,8 +34,9 @@ namespace CalamityMod.UI.CalamitasEnchants
HoldEffect = holdEffect;
ApplyRequirement = requirement;
ID = id;
IconTexturePath = iconTexturePath;
}
public Enchantment(string name, string description, int id, Action<Item> creationEffect, Predicate<Item> requirement)
public Enchantment(string name, string description, int id, string iconTexturePath, Action<Item> creationEffect, Predicate<Item> requirement)
{
Name = name;
Description = description;
@@ -41,6 +44,7 @@ namespace CalamityMod.UI.CalamitasEnchants
HoldEffect = null;
ApplyRequirement = requirement;
ID = id;
IconTexturePath = iconTexturePath;
}
public bool CanBeAppliedTo(Item item)
+43 -21
View File
@@ -58,14 +58,15 @@ namespace CalamityMod.UI.CalamitasEnchants
public static void ConstructFromModcall(IEnumerable<object> parameters)
{
int secondaryArgumentCount = parameters.Count();
if (secondaryArgumentCount < 4)
if (secondaryArgumentCount < 5)
throw new ArgumentNullException("ERROR: A minimum of 4 arguments must be supplied to this command; a name, a description, an id, and a requirement predicate.");
if (secondaryArgumentCount > 6)
if (secondaryArgumentCount > 7)
throw new ArgumentNullException("ERROR: A maximum of 6 arguments can be supplied to this command.");
string name = string.Empty;
string description = string.Empty;
int id = -1;
string iconTexturePath = null;
Predicate<Item> requirement = null;
Action<Item> creationEffect = null;
Action<Player> holdEffect = null;
@@ -94,33 +95,39 @@ namespace CalamityMod.UI.CalamitasEnchants
else
throw new ArgumentException("The fourth argument to this command must be an Item Predicate.");
// Fifth element - the texture path. This determines what icon is drawn on the UI when selected. It may be null to specify that none should be drawn.
if (parameters.ElementAt(4) is string iconTexturePathElement)
iconTexturePath = iconTexturePathElement;
else
throw new ArgumentException("The fifth argument to this command must be a string.");
// Optional elements - creation and hold effects.
switch (secondaryArgumentCount)
{
case 5:
object fifthElement = parameters.ElementAt(4);
if (fifthElement is Action<Item> creationElement)
case 6:
object sixthElement = parameters.ElementAt(4);
if (sixthElement is Action<Item> creationElement)
creationEffect = creationElement;
else if (fifthElement is Action<Player> holdElement)
else if (sixthElement is Action<Player> holdElement)
holdEffect = holdElement;
else
throw new ArgumentException("The fifth argument to this command must be an Item or Player Action.");
throw new ArgumentException("The sixth argument to this command must be an Item or Player Action.");
break;
case 6:
fifthElement = parameters.ElementAt(4);
object sixthElement = parameters.ElementAt(5);
if (fifthElement is Action<Item> creationElement2)
case 7:
sixthElement = parameters.ElementAt(4);
object seventhElement = parameters.ElementAt(5);
if (sixthElement is Action<Item> creationElement2)
{
creationEffect = creationElement2;
holdEffect = sixthElement as Action<Player>;
holdEffect = seventhElement as Action<Player>;
}
else if (fifthElement is Action<Player> holdElement2)
else if (sixthElement is Action<Player> holdElement2)
{
creationEffect = sixthElement as Action<Item>;
creationEffect = seventhElement as Action<Item>;
holdEffect = holdElement2;
}
else
throw new ArgumentException("The fifth argument to this command must be an Item or Player Action and the sixth must be the other action type.");
throw new ArgumentException("The sixth argument to this command must be an Item or Player Action and the sixth must be the other action type.");
break;
}
@@ -128,33 +135,37 @@ namespace CalamityMod.UI.CalamitasEnchants
if (EnchantmentList.Any(enchant => enchant.ID == id) || id == ClearEnchantmentID)
throw new ArgumentException("An enchantment with this ID already exists. Another one must be specified.");
EnchantmentList.Add(new Enchantment(name, description, id, creationEffect, holdEffect, requirement));
EnchantmentList.Add(new Enchantment(name, description, id, iconTexturePathElement, creationEffect, holdEffect, requirement));
}
internal static void LoadAllEnchantments()
{
EnchantmentList = new List<Enchantment>
{
new Enchantment(UpgradeEnchantName, "Transforms this item into something significantly better.",
new Enchantment(UpgradeEnchantName, "Transforms this item into something significantly stronger.",
1,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed",
null,
null,
item => ItemUpgradeRelationship.ContainsKey(item.type)),
new Enchantment("Cursed", "Summons demons that harm you but drop healing items on death on item usage.",
new Enchantment("Indignant", "Summons demons that harm you but drop healing items on death on item usage.",
100,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant",
null,
player => player.Calamity().cursedSummonsEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && item.summon),
new Enchantment("Aflame", "Lights enemies ablaze on hit but also causes the user to take damage over time when holding this item.",
200,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame",
null,
player => player.Calamity().flamingItemEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && !item.summon),
new Enchantment("Oblatory", "Reduces mana cost and greatly increases damage but sometimes causes this item to use your life.",
300,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory",
item =>
{
item.damage = (int)(item.damage * 1.5);
@@ -165,30 +176,35 @@ namespace CalamityMod.UI.CalamitasEnchants
new Enchantment("Resentful", "Makes the damage of projectiles vary based on how far the hit target is from you. The farther, the more damage, and vice versa.",
400,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful",
null,
player => player.Calamity().farProximityRewardEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None),
new Enchantment("Bloodthirsty", "Makes the damage of projectiles vary based on how far the hit target is from you. The closer, the more damage, and vice versa.",
500,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty",
null,
player => player.Calamity().closeProximityRewardEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None),
new Enchantment("Ephemeral", "Causes the damage output of this item to discharge from exhaustive use. Its damage returns naturally when not being used.",
600,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral",
null,
player => player.Calamity().dischargingItemEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && !item.summon),
new Enchantment("Hellbound", "Causes minions to be created with a 40 second timer. Once it runs out, they explode violently. Minions do more damage the longer they live and idly explode as well.",
700,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound",
null,
player => player.Calamity().explosiveMinionsEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && item.summon),
new Enchantment("Tainted", "Removes projectile shooting capabilities of this item. In exchange, two skeletal arms are released on use that slice at the mouse position.",
800,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted",
item => item.useTime = item.useAnimation = 25,
player =>
{
@@ -219,27 +235,33 @@ namespace CalamityMod.UI.CalamitasEnchants
},
item => item.damage > 0 && item.maxStack == 1 && item.melee && !item.noUseGraphic && item.shoot > ProjectileID.None),
new Enchantment("Treacherous", "Causes this item to sometimes release a monster that hurts both you and enemies when you have less than 50% mana.",
new Enchantment("Traitorous", "Causes this item to sometimes release a monster that hurts both you and enemies when you have less than 50% mana.",
900,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous",
null,
player => player.Calamity().manaMonsterEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && item.magic && item.mana > 0),
new Enchantment("Withering", "You heal when hurt based on damage dealt. After being hurt, the weapon rapidly drains your life to deal massive damage.",
1000,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered",
null,
player => player.Calamity().witheringWeaponEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && !item.summon),
new Enchantment("Persecuted", "You attract portals which summon demons on hit. The portal must be brought close to death or the demons will attack you. Otherwise they attack enemies.",
new Enchantment("Persecuted", "When attacked, or over time, demon portals appear near you. If sufficiently damaged they are friendly; otherwise they attack you.",
1100,
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted",
null,
player => player.Calamity().persecutedEnchant = true,
item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None),
};
// Special disenchantment thing. This is separated from the list on purpose.
ClearEnchantment = new Enchantment("Disenchant", string.Empty, ClearEnchantmentID,
ClearEnchantment = new Enchantment("Disenchant",
string.Empty,
ClearEnchantmentID,
null,
item => item.Calamity().AppliedEnchantment = null,
item => item.maxStack == 1 && item.shoot >= ProjectileID.None);