-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChemistryClassPlayer.cs
150 lines (95 loc) · 3.74 KB
/
ChemistryClassPlayer.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System;
using System.IO;
using System.Security.Policy;
using ChemistryClass.ModUtils;
using ChemistryClass.UI;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace ChemistryClass {
public class ChemistryClassPlayer : ModPlayer {
//Chemistry class values
public float chemicalDamageAdd = 0f;
public float chemicalDamageMult = 1f;
public float chemicalKnockbackAdd = 0f;
public float chemicalKnockbackMult = 1f;
public float chemicalCritAdd = 0f;
public float chemicalCritMult = 1f;
public float decayRateMult = 1f;
public float decayChanceMult = 1f;
public bool zoneSulfur = false;
public bool sulfurHeart = false;
public bool autoRefine = false;
public bool prevAutoRefine = false;
public bool sulfurFire = false;
public Item autoRefineItem = new Item();
public override void ResetEffects() {
chemicalDamageAdd = 0f;
chemicalDamageMult = 1f;
chemicalKnockbackAdd = 0f;
chemicalKnockbackMult = 1f;
chemicalCritAdd = 0f;
chemicalCritMult = 1f;
decayRateMult = 1f;
decayChanceMult = 1f;
sulfurHeart = false;
sulfurFire = false;
prevAutoRefine = autoRefine;
autoRefine = false;
}
public override void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff) {
if(sulfurHeart) {
if(player.HeldItem.IsChemistry()) {
player.statLifeMax2 += 50;
}
}
if(!autoRefine && prevAutoRefine) {
ChemistryClass.refinementMenu.menu.autoRefineSlot.TossContents();
autoRefineItem = new Item();
}
}
public override void PreUpdateBuffs() {
player.buffImmune[ModContent.BuffType<Buffs.Debuffs.SulfurFire>()] = player.buffImmune[BuffID.OnFire];
if (sulfurFire) {
Dust.NewDustDirect(
player.position,
player.width, player.height,
ModContent.DustType<Dusts.SulfurFlame>(),
Scale: Main.rand.NextFloat(0.75f, 1.25f)
);
}
}
public override void UpdateBadLifeRegen() {
if (sulfurFire) {
if (player.lifeRegen > 0) player.lifeRegen = 0;
player.lifeRegenTime = 0;
player.lifeRegen -= 14;
}
}
//BIOME SHENANIGANS
public override void UpdateBiomes() {
zoneSulfur = ChemistryClassWorld.sulfurCount >= 8 && ChemistryClassWorld.sulfurHeartCount >= 1;
}
public override void CopyCustomBiomesTo(Player other) {
other.GetModPlayer<ChemistryClassPlayer>().zoneSulfur = zoneSulfur;
}
public override bool CustomBiomesMatch(Player other)
=> other.GetModPlayer<ChemistryClassPlayer>().zoneSulfur == zoneSulfur;
public override void SendCustomBiomes(BinaryWriter writer) {
writer.Write(zoneSulfur);
}
public override void ReceiveCustomBiomes(BinaryReader reader) {
zoneSulfur = reader.ReadBoolean();
}
//SAVING AND LOADING
public override TagCompound Save()
=> new TagCompound {
{ nameof(autoRefineItem), autoRefineItem }
};
public override void Load(TagCompound tag) {
autoRefineItem = tag.Get<Item>(nameof(autoRefineItem));
ChemistryClass.refinementMenu.menu.autoRefineSlot.Item = autoRefineItem;
}
}
}