-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFishColorPlayer.cs
More file actions
265 lines (246 loc) · 9.97 KB
/
FishColorPlayer.cs
File metadata and controls
265 lines (246 loc) · 9.97 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
using BeastCustomization.Textures;
using BeastCustomization.UI;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.Chat;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.GameContent.UI.States;
using Terraria.GameInput;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
using Terraria.ModLoader.IO;
using Terraria.UI;
namespace BeastCustomization {
public class FishColorPlayer : BeastPlayerBase {
#region fields
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.headScaleStyle")]
[ListRange("HeadScaleTextures"), Slider]
public int headScaleStyle = 1;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.headScaleStyle2")]
[ListRange("HeadSecondaryScaleTextures"), Slider]
public int headScaleStyle2 = 0;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.headEyeStyle")]
[ListRange("EyesTextures"), Slider]
public int headEyeStyle = 0;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.bodyScaleStyle")]
[ListRange("BodyScaleTextures"), Slider]
public int bodyScaleStyle = 1;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.bodySecondaryScaleStyle")]
[ListRange("BodySecondaryScaleTextures"), Slider]
public int bodySecondaryScaleStyle = 0;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.legsScaleStyle")]
[ListRange("LegsScaleTextures"), Slider]
public int legsScaleStyle = 1;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.legsScaleStyle2")]
[ListRange("LegsSecondaryScaleTextures"), Slider]
public int legsScaleStyle2 = 0;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.eyesGlow")]
public bool eyesGlow = false;
//[JsonIgnore]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyHead")]
public bool applyHead = false;
//[JsonIgnore]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyBody")]
public bool applyBody = false;
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyCloaks")]
public bool applyCloaks = true;
//[JsonIgnore]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyLegs")]
public bool applyLegs = false;
//[JsonIgnore]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyHeadOver")]
[TooltipKey("$Mods.BeastCustomization.Forms.WolfColorPlayer.LooksRidiculous")]
public bool applyHeadOver = false;
//[JsonIgnore]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyBodyOver")]
[TooltipKey("$Mods.BeastCustomization.Forms.WolfColorPlayer.LooksRidiculous")]
public bool applyBodyOver = false;
//[JsonIgnore]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.applyLegsOver")]
[TooltipKey("$Mods.BeastCustomization.Forms.WolfColorPlayer.LooksRidiculous")]
public bool applyLegsOver = false;
[OldOverrideShaderField("eyesDye", true)]
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.eyesColor")]
public ColorDefinition eyesColor = new Color(242, 8, 46);
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.scaleColor")]
public ColorDefinition scaleColor = new Color(41, 185, 127);
[LabelKey("$Mods.BeastCustomization.Forms.FishColorPlayer.scaleColor2")]
public ColorDefinition scaleColor2 = new Color(168, 255, 106);
TagCompound oldData;
#endregion fields
//public override string DisplayName => "Merfolk";
public override FishColorPlayer CreateNew() => new FishColorPlayer();
public override Type ResourceCacheType => typeof(Merfolk);
public override ref List<TagCompound> ConfigPresets => ref BeastCustomizationSavedPresets.Instance.fishPresets;
public override bool IsActive => (Player.merman && !Player.hideMerman) || Player.forceMerman;
public override int Specificity => 1;
public override void StartCustomization() {
oldData = new();
ExportData(oldData);
}
public override void FinishCustomization(bool overwrite) {
if (!overwrite) {
ImportData(oldData ??= new());
SendData();
}
}
public override void UpdateData(TagCompound tag, Version lastVersion, out bool warn) {
warn = false;
ColorToColorDefinition(tag);
}
public override void ApplyVanillaDrawLayers(PlayerDrawSet drawInfo, out bool applyHead, out bool applyBody, out bool applyCloaks, out bool applyLegs) {
applyHead = this.applyHead;
applyBody = this.applyBody;
applyCloaks = this.applyCloaks;
applyLegs = this.applyLegs;
}
public override void HideVanillaDrawLayers(PlayerDrawSet drawInfo, out bool hideHead, out bool hideBody, out bool hideLegs) {
hideHead = !applyHead || GetSlot(0) == -1;
hideBody = !applyBody || GetSlot(1) == -1;
hideLegs = !applyLegs || GetSlot(2) == -1;
}
}
public class Merfolk_Head_Layer : GenericHeadLayer {
public override Type BoundBeastPlayer => typeof(FishColorPlayer);
public override IEnumerable<BeastLayerItem> GetData(PlayerDrawSet drawInfo) {
FishColorPlayer beastColorPlayer = drawInfo.drawPlayer.GetModPlayer<FishColorPlayer>();
yield return beastColorPlayer.scaleColor.GetLayerItem(drawInfo, drawInfo.colorArmorHead,
Merfolk.HeadScaleTextures[beastColorPlayer.headScaleStyle],
applyDye: true
);
yield return beastColorPlayer.scaleColor2.GetLayerItem(drawInfo, drawInfo.colorArmorHead,
Merfolk.HeadSecondaryScaleTextures[beastColorPlayer.headScaleStyle2],
applyDye: true
);
Color eyesLightColor = beastColorPlayer.eyesGlow ? (Color.White * (drawInfo.colorArmorHead.A / 255f)) : drawInfo.colorArmorHead;
yield return beastColorPlayer.eyesColor.GetLayerItem(drawInfo, eyesLightColor,
Merfolk.EyesTextures[beastColorPlayer.headEyeStyle]
);
if (beastColorPlayer.applyHeadOver) {
int slot = beastColorPlayer.GetSlot(0);
if (slot > 0) {
if (slot < ArmorIDs.Head.Count) {
Main.instance.LoadArmorHead(slot);
int backID = ArmorIDs.Head.Sets.FrontToBackID[slot];
if (backID >= 0) {
Main.instance.LoadArmorHead(backID);
}
}
yield return new(
TextureAssets.ArmorHead[slot].Value,
drawInfo.colorArmorHead,
applyDye: true
);
}
}
}
}
public class Merfolk_Body_Layer : GenericBodyLayer {
public override Type BoundBeastPlayer => typeof(FishColorPlayer);
public override IEnumerable<BeastLayerItem> GetData(PlayerDrawSet drawInfo) {
FishColorPlayer beastColorPlayer = drawInfo.drawPlayer.GetModPlayer<FishColorPlayer>();
yield return beastColorPlayer.scaleColor.GetLayerItem(drawInfo, drawInfo.colorArmorBody,
Merfolk.BodyScaleTextures[beastColorPlayer.bodyScaleStyle]
);
yield return beastColorPlayer.scaleColor2.GetLayerItem(drawInfo, drawInfo.colorArmorBody,
Merfolk.BodySecondaryScaleTextures[beastColorPlayer.bodySecondaryScaleStyle]
);
if (beastColorPlayer.applyBodyOver) {
int slot = beastColorPlayer.GetSlot(1);
if (slot > 0) {
if (slot < ArmorIDs.Body.Count) {
Main.instance.LoadArmorBody(slot);
}
yield return new(
TextureAssets.ArmorBodyComposite[slot].Value,
drawInfo.colorArmorBody
);
}
}
}
}
public class Merfolk_Arm_Layer_Back : GenericArmLayer_Back {
public override Type BoundBeastPlayer => typeof(FishColorPlayer);
public override IEnumerable<BeastLayerItem> GetData(PlayerDrawSet drawInfo) {
FishColorPlayer beastColorPlayer = drawInfo.drawPlayer.GetModPlayer<FishColorPlayer>();
yield return beastColorPlayer.scaleColor.GetLayerItem(drawInfo, drawInfo.colorArmorBody,
Merfolk.BodyScaleTextures[beastColorPlayer.bodyScaleStyle]
);
yield return beastColorPlayer.scaleColor2.GetLayerItem(drawInfo, drawInfo.colorArmorBody,
Merfolk.BodySecondaryScaleTextures[beastColorPlayer.bodySecondaryScaleStyle]
);
if (beastColorPlayer.applyBodyOver) {
int slot = beastColorPlayer.GetSlot(1);
if (slot > 0) {
if (slot < ArmorIDs.Body.Count) {
Main.instance.LoadArmorBody(slot);
}
yield return new(
TextureAssets.ArmorBodyComposite[slot].Value,
drawInfo.colorArmorBody
);
}
}
}
}
public class Merfolk_Arm_Layer_Front : GenericArmLayer_Front {
public override Type BoundBeastPlayer => typeof(FishColorPlayer);
public override IEnumerable<BeastLayerItem> GetData(PlayerDrawSet drawInfo) {
FishColorPlayer beastColorPlayer = drawInfo.drawPlayer.GetModPlayer<FishColorPlayer>();
yield return beastColorPlayer.scaleColor.GetLayerItem(drawInfo, drawInfo.colorArmorBody,
Merfolk.BodyScaleTextures[beastColorPlayer.bodyScaleStyle]
);
yield return beastColorPlayer.scaleColor2.GetLayerItem(drawInfo, drawInfo.colorArmorBody,
Merfolk.BodySecondaryScaleTextures[beastColorPlayer.bodySecondaryScaleStyle]
);
if (beastColorPlayer.applyBodyOver) {
int slot = beastColorPlayer.GetSlot(1);
if (slot > 0) {
if (slot < ArmorIDs.Body.Count) {
Main.instance.LoadArmorBody(slot);
}
yield return new(
TextureAssets.ArmorBodyComposite[slot].Value,
drawInfo.colorArmorBody
);
}
}
}
}
public class Merfolk_Legs_Layer : GenericLegsLayer {
public override Type BoundBeastPlayer => typeof(FishColorPlayer);
public override IEnumerable<BeastLayerItem> GetData(PlayerDrawSet drawInfo) {
FishColorPlayer beastColorPlayer = drawInfo.drawPlayer.GetModPlayer<FishColorPlayer>();
yield return beastColorPlayer.scaleColor.GetLayerItem(drawInfo, drawInfo.colorArmorLegs,
Merfolk.LegsScaleTextures[beastColorPlayer.legsScaleStyle]
);
yield return beastColorPlayer.scaleColor2.GetLayerItem(drawInfo, drawInfo.colorArmorLegs,
Merfolk.LegsSecondaryScaleTextures[beastColorPlayer.legsScaleStyle2]
);
if (beastColorPlayer.applyLegsOver) {
int slot = beastColorPlayer.GetSlot(2);
if (slot > 0) {
if (slot < ArmorIDs.Legs.Count) {
Main.instance.LoadArmorLegs(slot);
}
yield return new(
TextureAssets.ArmorLeg[slot].Value,
drawInfo.colorArmorLegs
);
}
}
}
}
}