-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlchPlayer.cs
50 lines (49 loc) · 1.5 KB
/
AlchPlayer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;
using System.Linq;
using Terraria.ModLoader.IO;
namespace PotionOverhaul
{
class AlchPlayer : ModPlayer
{
public List<Item> ItemsOnPotion = new List<Item>();
public List<List<Item>> SavedPotions = new List<List<Item>>();
public override void PreUpdate()
{
if (ItemsOnPotion.Count > 0 && !player.HasBuff(ModContent.BuffType<AlchBuff>()))
ItemsOnPotion.Clear();
}
public override void PostUpdateEquips()
{
if (!player.HasBuff(ModContent.BuffType<AlchBuff>())) return;
for (int i = 0; i < ItemsOnPotion.Count(); i++)
{
AlchEffects.AlchPostUpdateEquip(player, ItemsOnPotion[i].stack, ItemsOnPotion[i]);
}
}
public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{
if (!player.HasBuff(ModContent.BuffType<AlchBuff>())) return;
for (int i = 0; i < ItemsOnPotion.Count(); i++)
{
AlchEffects.AlchOnMeleeHit(player, ItemsOnPotion[i].stack, ItemsOnPotion[i], target, damage, knockback, crit);
}
}
public override TagCompound Save()
{
return new TagCompound
{
{"SavedPotions", SavedPotions},
{"ItemsOnPotion", ItemsOnPotion}
};
}
public override void Load(TagCompound tag)
{
if (tag.ContainsKey("SavedPotions"))
SavedPotions = tag.GetList<List<Item>>("SavedPotions").ToList();
if (tag.ContainsKey("ItemsOnPotion"))
ItemsOnPotion = tag.GetList<Item>("ItemsOnPotion").ToList();
}
}
}