Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Pages
LootEssencePlayer.cs
Go to the documentation of this file.
1 using Microsoft.Xna.Framework;
2 using Terraria;
3 using Terraria.ModLoader;
4 using Terraria.ModLoader.IO;
5 
6 namespace Loot.Soulforging
7 {
8  internal class LootEssencePlayer : ModPlayer
9  {
10  public int Essence { get; private set; } = 0;
11  public int BonusEssenceGain { get; private set; } = 0;
12  public int KillCount { get; set; } = 0;
13  public int TopEssence { get; set; } = 1000;
14 
15  public int GainEssence(int amount)
16  {
17  if (!ModContent.GetInstance<LootEssenceWorld>().SoulforgingUnlocked) return 0;
18 
19  var player = Main.LocalPlayer;
20  var gain = amount + BonusEssenceGain;
21  Essence += gain;
22  CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), new Color(49, 207, 238), $"+{gain} essence", false, false);
23  return Essence;
24  }
25 
26  public int UseEssence(int amount)
27  {
28  Essence -= amount;
29  return Essence;
30  }
31 
32  public void RecalcTopEssence()
33  {
34  if (!ModContent.GetInstance<LootEssenceWorld>().SoulforgingUnlocked) return;
35 
36  var amount = 1000;
37  if (NPC.downedBoss1) amount += 100;
38  if (NPC.downedBoss2) amount += 500;
39  if (NPC.downedBoss3) amount += 100;
40  // TODO do more;
41  TopEssence = amount;
42  }
43 
44  public override TagCompound Save()
45  {
46  return new TagCompound
47  {
48  {"Essence", Essence},
49  {"KillCount", KillCount}
50  };
51  }
52 
53  public override void Load(TagCompound tag)
54  {
55  Essence = tag.GetInt("Essence");
56  KillCount = tag.GetInt("KillCount");
57  RecalcTopEssence();
58  }
59  }
60 }