Repository navigation
Expand file tree
/
Copy pathSpiritMod.cs
More file actions
739 lines (609 loc) · 34.1 KB
/
Copy pathSpiritMod.cs
File metadata and controls
739 lines (609 loc) · 34.1 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SpiritMod.NPCs.Boss.Atlas;
using SpiritMod.NPCs.Tides.Tide;
using SpiritMod.Skies;
using SpiritMod.Skies.Overlays;
using SpiritMod.Utilities;
using SpiritMod.Dusts;
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.Shaders;
using Terraria.GameContent.Dyes;
using Terraria.GameContent.UI;
using Terraria.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.UI;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Core;
using Terraria.Utilities;
using Terraria.UI.Chat;
using SpiritMod.Prim;
using SpiritMod.Particles;
using SpiritMod.UI.QuestUI;
using SpiritMod.Mechanics.QuestSystem;
using SpiritMod.Mechanics.BoonSystem;
using System.Collections.Concurrent;
using SpiritMod.Effects.Stargoop;
using SpiritMod.Mechanics.PortraitSystem;
using SpiritMod.Mechanics.Boids;
using SpiritMod.Mechanics.AutoSell;
using SpiritMod.Buffs.Summon;
using System.Linq;
using SpiritMod.Items.Weapon.Magic.Rhythm;
using SpiritMod.Items.Weapon.Magic.Rhythm.Anthem;
using SpiritMod.Mechanics.EventSystem;
using SpiritMod.Skies.Starjinx;
using SpiritMod.Mechanics.Trails;
using SpiritMod.Items.Sets.OlympiumSet;
using SpiritMod.Mechanics.Coverings;
using static Terraria.ModLoader.Core.TmodFile;
using SpiritMod.Items.Sets.DyesMisc.HairDye;
using SpiritMod.Items.Glyphs;
using ReLogic.Content;
using SpiritMod.Items.Books.UI;
using SpiritMod.Mechanics.Fathomless_Chest;
using SpiritMod.NPCs.Town.Oracle;
using SpiritMod.GlobalClasses.Items;
using SpiritMod.Systems.Aurora;
using SpiritMod.Systems.LuminousOcean;
namespace SpiritMod;
public partial class SpiritMod : Mod
{
internal UserInterface BookUserInterface;
public static QuestBookUI QuestBookUIState;
public static QuestHUD QuestHUD;
public static CoveringsManager Coverings;
public static ModKeybind QuestBookHotkey;
public static ModKeybind QuestHUDHotkey;
internal UserInterface SlotUserInterface;
public static SpiritMod Instance;
public UnifiedRandom spiritRNG;
public static Effect auroraEffect;
public static BasicEffect basicEffect;
public static Effect GSaber;
public static TrailManager TrailManager;
public static PrimTrailManager primitives;
public static StargoopManager Metaballs;
public static BoidHost Boids;
public static Effect stardustOverlayEffect;
public static Effect glitchEffect;
public static Effect starjinxBorderEffect;
public static Effect vignetteEffect;
public static Effect StarjinxNoise;
public static Effect CircleNoise;
public static Effect StarfirePrims;
public static Effect ScreamingSkullTrail;
public static Effect RipperSlugShader;
public static Effect RepeatingTextureShader;
public static Effect PrimitiveTextureMap;
public static Effect EyeballShader;
public static Effect ArcLashShader;
public static Effect ConicalNoise;
public static Effect JemShaders;
public static Effect SunOrbShader;
public static Effect ThyrsusShader;
public static Effect JetbrickTrailShader;
public static Effect OutlinePrimShader;
public static Effect AnthemCircle;
public static Effect TeslaShader;
public static Effect GhostShader;
public static IDictionary<string, Effect> ShaderDict = new Dictionary<string, Effect>();
public static PerlinNoise GlobalNoise;
public static GlitchScreenShader glitchScreenShader;
public static StarjinxBorderShader starjinxBorderShader;
public static Vignette vignetteShader;
public static Texture2D noise;
public AutoSellUI AutoSellUI_SHORTCUT;
public Mechanics.AutoSell.Sell_NoValue.Sell_NoValue SellNoValue_SHORTCUT;
public Mechanics.AutoSell.Sell_Lock.Sell_Lock SellLock_SHORTCUT;
public Mechanics.AutoSell.Sell_Weapons.Sell_Weapons SellWeapons_SHORTCUT;
public UserInterface AutoSellUI_INTERFACE;
public UserInterface SellNoValue_INTERFACE;
public UserInterface SellLock_INTERFACE;
public UserInterface SellWeapons_INTERFACE;
public static event Action<SpriteViewMatrix> OnModifyTransformMatrix;
//public static Dictionary<int, Texture2D> Portraits = new Dictionary<int, Texture2D>(); //Portraits dict - Gabe
public const string EMPTY_TEXTURE = "SpiritMod/Empty";
public static Texture2D EmptyTexture
{
get;
private set;
}
internal static float deltaTime;
private Vector2 _lastScreenSize;
private Vector2 _lastViewSize;
private Viewport _lastViewPort;
public static int GlyphCurrencyID;
public static int OlympiumCurrencyID = 0;
internal static bool AutoTrashEnabled = false;
/// <summary>Automatically returns false for every NPC ID inside of this list in <seealso cref="NPCs.GNPC.AllowTrickOrTreat(NPC)"/>.
/// Note that this should only be used in edge cases where an NPC is neither homeless nor has homeTileX/Y set.</summary>
public readonly List<int> NPCCandyBlacklist = new();
public bool FinishedContentSetup { get; private set; }
public SpiritMod()
{
Instance = this;
spiritRNG = new UnifiedRandom();
}
public ModPacket GetPacket(MessageType type, int capacity)
{
ModPacket packet = GetPacket(capacity + 1);
packet.Write((byte)type);
return packet;
}
// this is alright, and i'll expand it so it can still be used, but really this shouldn't be used
public static ModPacket WriteToPacket(ModPacket packet, byte msg, params object[] param)
{
packet.Write(msg);
for (int m = 0; m < param.Length; m++)
{
object obj = param[m];
if (obj is bool) packet.Write((bool)obj);
else if (obj is byte) packet.Write((byte)obj);
else if (obj is int) packet.Write((int)obj);
else if (obj is float) packet.Write((float)obj);
else if (obj is double) packet.Write((double)obj);
else if (obj is short) packet.Write((short)obj);
else if (obj is ushort) packet.Write((ushort)obj);
else if (obj is sbyte) packet.Write((sbyte)obj);
else if (obj is uint) packet.Write((uint)obj);
else if (obj is decimal) packet.Write((decimal)obj);
else if (obj is long) packet.Write((long)obj);
else if (obj is string) packet.Write((string)obj);
}
return packet;
}
public override void HandlePacket(BinaryReader reader, int whoAmI) => SpiritMultiplayer.HandlePacket(reader, whoAmI);
public override void Load()
{
QuestBookHotkey = KeybindLoader.RegisterKeybind(this, "QuestBookToggle", Microsoft.Xna.Framework.Input.Keys.Q);
QuestHUDHotkey = KeybindLoader.RegisterKeybind(this, "QuestHUDToggle", Microsoft.Xna.Framework.Input.Keys.V);
QuestManager.Load();
if (!Main.dedServ)
{
ParticleHandler.RegisterParticles();
BookUserInterface = new UserInterface();
QuestBookUIState = new QuestBookUI();
QuestHUD = new QuestHUD();
Boids = new BoidHost();
EventManager.Load();
_lastScreenSize = new Vector2(Main.screenWidth, Main.screenHeight);
_lastViewSize = Main.ViewSize;
_lastViewPort = Main.graphics.GraphicsDevice.Viewport;
}
BoonLoader.Load();
SpiritMultiplayer.Load();
SpiritDetours.Initialize();
ChanceEffectManager.Load();
//Coverings = new CoveringsManager();
//Coverings.Load(this);
GlobalNoise = new PerlinNoise(Main.rand.Next());
Main.rand ??= new UnifiedRandom();
Items.Halloween.CandyBag.Initialize();
OlympiumCurrencyID = CustomCurrencyManager.RegisterCurrency(new OlympiumCurrency(ModContent.ItemType<OlympiumToken>(), 999));
if (Main.netMode != NetmodeID.Server)
{
Filters.Scene["Shockwave"] = new Filter(new ScreenShaderData(new Ref<Effect>(ModContent.Request<Effect>("SpiritMod/Effects/ShockwaveEffect", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value), "Shockwave"), EffectPriority.VeryHigh);
Filters.Scene["Shockwave"].Load();
Filters.Scene["PulsarShockwave"] = new Filter(new ScreenShaderData(new Ref<Effect>(ModContent.Request<Effect>("SpiritMod/Effects/PulsarShockwave", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value), "PulsarShockwave"), EffectPriority.VeryHigh);
Filters.Scene["PulsarShockwave"].Load();
SlotUserInterface = new UserInterface();
Filters.Scene["ShockwaveTwo"] = new Filter(new ScreenShaderData(new Ref<Effect>(ModContent.Request<Effect>("SpiritMod/Effects/ShockwaveTwo", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value), "ShockwaveTwo"), EffectPriority.VeryHigh);
Filters.Scene["ShockwaveTwo"].Load();
Filters.Scene["SpiritMod:AshRain"] = new Filter(new ScreenShaderData(new Ref<Effect>(ModContent.Request<Effect>("SpiritMod/Effects/AshRain", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value), "AshRain"), EffectPriority.VeryLow);
Filters.Scene["SpiritMod:AshRain"].Load();
}
Filters.Scene["SpiritMod:ReachSky"] = new Filter(new ScreenShaderData("FilterBloodMoon").UseColor(0.05f, 0.05f, .05f).UseOpacity(0.4f), EffectPriority.High);
Filters.Scene["CystalTower"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0.149f, 0.142f, 0.207f).UseOpacity(0.5f), EffectPriority.VeryHigh);
Filters.Scene["CystalBloodMoon"] = new Filter(new ScreenShaderData("FilterBloodMoon").UseColor(0.149f, 0.142f, 0.207f).UseOpacity(2f), EffectPriority.VeryHigh);
Filters.Scene["SpiritMod:SpiritUG1"] = new Filter(new ScreenShaderData("FilterBloodMoon").UseColor(0.2f, 0.2f, .2f).UseOpacity(0.8f), EffectPriority.High);
Filters.Scene["SpiritMod:SpiritUG2"] = new Filter(new ScreenShaderData("FilterBloodMoon").UseColor(0.45f, 0.45f, .45f).UseOpacity(0.9f), EffectPriority.High);
Filters.Scene["SpiritMod:WindEffect"] = new Filter((new BlizzardShaderData("FilterBlizzardForeground")).UseColor(0.4f, 0.4f, 0.4f).UseSecondaryColor(0.2f, 0.2f, 0.2f).UseImage("Images/Misc/noise", 0, null).UseOpacity(0.149f).UseImageScale(new Vector2(3f, 0.75f), 0), EffectPriority.High);
Filters.Scene["SpiritMod:WindEffect2"] = new Filter((new BlizzardShaderData("FilterBlizzardForeground")).UseColor(0.4f, 0.4f, 0.4f).UseSecondaryColor(0.2f, 0.2f, 0.2f).UseImage("Images/Misc/noise", 0, null).UseOpacity(0.549f).UseImageScale(new Vector2(3f, 0.75f), 0), EffectPriority.High);
GlyphCurrencyID = CustomCurrencyManager.RegisterCurrency(new GlyphCurrency(ModContent.ItemType<Glyph>(), 999L));
AutoloadMinionDictionary.AddBuffs(Code);
if (Main.netMode != NetmodeID.Server)
{
TrailManager = new TrailManager(this);
EmptyTexture = ModContent.Request<Texture2D>("SpiritMod/Empty", AssetRequestMode.ImmediateLoad).Value;
auroraEffect = ModContent.Request<Effect>("SpiritMod/Effects/aurora", AssetRequestMode.ImmediateLoad).Value;
ShaderDict = new Dictionary<string, Effect>();
var tmodfile = (TmodFile)typeof(SpiritMod).GetProperty("File", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Instance);
var files = (IDictionary<string, FileEntry>)typeof(TmodFile).GetField("files", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tmodfile);
foreach (KeyValuePair<string, FileEntry> kvp in files.Where(x => x.Key.Contains("Effects/") && x.Key.Contains(".xnb")))
ShaderDict.Add(kvp.Key.Remove(kvp.Key.Length - ".xnb".Length, ".xnb".Length).Remove(0, "Effects/".Length), ModContent.Request<Effect>("SpiritMod/" + kvp.Key.Remove(kvp.Key.Length - ".xnb".Length, ".xnb".Length), ReLogic.Content.AssetRequestMode.ImmediateLoad).Value);
int width = Main.graphics.GraphicsDevice.Viewport.Width;
int height = Main.graphics.GraphicsDevice.Viewport.Height;
Vector2 zoom = Main.GameViewMatrix.Zoom;
Matrix view = Matrix.CreateLookAt(Vector3.Zero, Vector3.UnitZ, Vector3.Up) * Matrix.CreateTranslation(width / 2, height / -2, 0) * Matrix.CreateRotationZ(MathHelper.Pi) * Matrix.CreateScale(zoom.X, zoom.Y, 1f);
Matrix projection = Matrix.CreateOrthographic(width, height, 0, 1000);
Main.QueueMainThreadAction(() =>
{
basicEffect = new BasicEffect(Main.graphics.GraphicsDevice)
{
VertexColorEnabled = true,
View = view,
Projection = projection
};
});
noise = ModContent.Request<Texture2D>("SpiritMod/Textures/noise", AssetRequestMode.ImmediateLoad).Value;
SpiritModAutoSellTextures.Load();
GameShaders.Hair.BindShader(ModContent.ItemType<SeafoamDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(Color.Cyan, Color.White, MathHelper.Lerp(0.2f, 1f, (float)((Math.Sin(3f + Main.GlobalTimeWrappedHourly * 1.3f) + 1f) * 0.5f)))));
GameShaders.Hair.BindShader(ModContent.ItemType<BrightbloodDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.IndianRed));
GameShaders.Hair.BindShader(ModContent.ItemType<MeteorDye>(), new HairShaderData(Main.PixelShaderRef, "ArmorHades")).UseImage("Images/Misc/noise").UseColor(Color.Orange).UseSecondaryColor(Color.DarkOrange).UseSaturation(5.3f);
GameShaders.Hair.BindShader(ModContent.ItemType<ViciousDye>(), new HairShaderData(Main.PixelShaderRef, "ArmorVortex")).UseImage("Images/Misc/noise").UseColor(Color.Crimson).UseSaturation(3.3f);
GameShaders.Hair.BindShader(ModContent.ItemType<CystalDye>(), new HairShaderData(Main.PixelShaderRef, "ArmorNebula")).UseImage("Images/Misc/Perlin").UseColor(Color.Plum).UseSaturation(5.3f);
GameShaders.Hair.BindShader(ModContent.ItemType<SnowMirageDye>(), new HairShaderData(Main.PixelShaderRef, "ArmorMirage")).UseImage("Images/Misc/Perlin").UseColor(Color.PaleTurquoise).UseSaturation(2.3f);
PortraitManager.Load();
AutoSellUI_INTERFACE = new UserInterface();
SellNoValue_INTERFACE = new UserInterface();
SellLock_INTERFACE = new UserInterface();
SellWeapons_INTERFACE = new UserInterface();
AutoSellUI_SHORTCUT = new AutoSellUI();
SellNoValue_SHORTCUT = new Mechanics.AutoSell.Sell_NoValue.Sell_NoValue();
SellLock_SHORTCUT = new Mechanics.AutoSell.Sell_Lock.Sell_Lock();
SellWeapons_SHORTCUT = new Mechanics.AutoSell.Sell_Weapons.Sell_Weapons();
AutoSellUI_SHORTCUT.Activate();
SellNoValue_SHORTCUT.Activate();
SellLock_SHORTCUT.Activate();
SellWeapons_SHORTCUT.Activate();
stardustOverlayEffect = ModContent.Request<Effect>("SpiritMod/Effects/StardustOverlay", AssetRequestMode.ImmediateLoad).Value;
glitchEffect = ModContent.Request<Effect>("SpiritMod/Effects/glitch", AssetRequestMode.ImmediateLoad).Value;
glitchScreenShader = new GlitchScreenShader(glitchEffect);
Filters.Scene["SpiritMod:Glitch"] = new Filter(glitchScreenShader, (EffectPriority)50);
starjinxBorderEffect = ModContent.Request<Effect>("SpiritMod/Effects/StarjinxBorder", AssetRequestMode.ImmediateLoad).Value;
starjinxBorderShader = new StarjinxBorderShader(starjinxBorderEffect, "MainPS");
Filters.Scene["SpiritMod:StarjinxBorder"] = new Filter(starjinxBorderShader, (EffectPriority)50);
Filters.Scene["SpiritMod:StarjinxBorderFade"] = new Filter(new StarjinxBorderShader(starjinxBorderEffect, "FadePS"), (EffectPriority)70);
vignetteEffect = ModContent.Request<Effect>("SpiritMod/Effects/Vignette", AssetRequestMode.ImmediateLoad).Value;
vignetteShader = new Vignette(vignetteEffect, "MainPS");
Filters.Scene["SpiritMod:Vignette"] = new Filter(vignetteShader, (EffectPriority)100);
StarjinxNoise = ModContent.Request<Effect>("SpiritMod/Effects/StarjinxNoise", AssetRequestMode.ImmediateLoad).Value;
CircleNoise = ModContent.Request<Effect>("SpiritMod/Effects/CircleNoise", AssetRequestMode.ImmediateLoad).Value;
StarfirePrims = ModContent.Request<Effect>("SpiritMod/Effects/StarfirePrims", AssetRequestMode.ImmediateLoad).Value;
ScreamingSkullTrail = ModContent.Request<Effect>("SpiritMod/Effects/ScreamingSkullTrail", AssetRequestMode.ImmediateLoad).Value;
RipperSlugShader = ModContent.Request<Effect>("SpiritMod/Effects/RipperSlugShader", AssetRequestMode.ImmediateLoad).Value;
RepeatingTextureShader = ModContent.Request<Effect>("SpiritMod/Effects/RepeatingTextureShader", AssetRequestMode.ImmediateLoad).Value;
PrimitiveTextureMap = ModContent.Request<Effect>("SpiritMod/Effects/PrimitiveTextureMap", AssetRequestMode.ImmediateLoad).Value;
EyeballShader = ModContent.Request<Effect>("SpiritMod/Effects/EyeballShader", AssetRequestMode.ImmediateLoad).Value;
ArcLashShader = ModContent.Request<Effect>("SpiritMod/Effects/ArcLashShader", AssetRequestMode.ImmediateLoad).Value;
ConicalNoise = ModContent.Request<Effect>("SpiritMod/Effects/ConicalNoise", AssetRequestMode.ImmediateLoad).Value;
JemShaders = ModContent.Request<Effect>("SpiritMod/Effects/JemShaders", AssetRequestMode.ImmediateLoad).Value;
SunOrbShader = ModContent.Request<Effect>("SpiritMod/Effects/SunOrbShader", AssetRequestMode.ImmediateLoad).Value;
ThyrsusShader = ModContent.Request<Effect>("SpiritMod/Effects/ThyrsusShader", AssetRequestMode.ImmediateLoad).Value;
JetbrickTrailShader = ModContent.Request<Effect>("SpiritMod/Effects/JetbrickTrailShader", AssetRequestMode.ImmediateLoad).Value;
OutlinePrimShader = ModContent.Request<Effect>("SpiritMod/Effects/OutlinePrimShader", AssetRequestMode.ImmediateLoad).Value;
GSaber = ModContent.Request<Effect>("SpiritMod/Effects/GSaber", AssetRequestMode.ImmediateLoad).Value;
AnthemCircle = ModContent.Request<Effect>("SpiritMod/Effects/AnthemCircle", AssetRequestMode.ImmediateLoad).Value;
TeslaShader = ModContent.Request<Effect>("SpiritMod/Effects/TeslaShader", AssetRequestMode.ImmediateLoad).Value;
GhostShader = ModContent.Request<Effect>("SpiritMod/Effects/GhostShader", AssetRequestMode.ImmediateLoad).Value;
SkyManager.Instance["SpiritMod:AuroraSky"] = new AuroraSky();
Filters.Scene["SpiritMod:AuroraSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
Overlays.Scene["SpiritMod:AuroraSky"] = new AuroraOverlay();
Filters.Scene["SpiritMod:BlueMoonSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0.1f, 0.2f, 0.5f).UseOpacity(0.53f), EffectPriority.High);
SkyManager.Instance["SpiritMod:BlueMoonSky"] = new BlueMoonSky();
SkyManager.Instance["SpiritMod:StarjinxSky"] = new StarjinxSky();
Filters.Scene["SpiritMod:StarjinxSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:MeteorSky"] = new MeteorSky();
SkyManager.Instance["SpiritMod:AsteroidSky2"] = new MeteorBiomeSky2();
Filters.Scene["SpiritMod:MeteorSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
Filters.Scene["SpiritMod:AsteroidSky2"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:SpiritBiomeSky"] = new SpiritBiomeSky();
Filters.Scene["SpiritMod:SpiritBiomeSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:JellySky"] = new JellySky();
Filters.Scene["SpiritMod:JellySky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:PurpleAlgaeSky"] = new PurpleAlgaeSky();
Filters.Scene["SpiritMod:PurpleAlgaeSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:GreenAlgaeSky"] = new GreenAlgaeSky();
Filters.Scene["SpiritMod:GreenAlgaeSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:OceanFloorSky"] = new OceanFloorSky();
Filters.Scene["SpiritMod:OceanFloorSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:BlueAlgaeSky"] = new BlueAlgaeSky();
Filters.Scene["SpiritMod:BlueAlgaeSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
SkyManager.Instance["SpiritMod:BloodMoonSky"] = new BloodMoonSky();
Filters.Scene["SpiritMod:BloodMoonSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryLow);
Filters.Scene["SpiritMod:Atlas"] = new Filter(new AtlasScreenShaderData("FilterMiniTower").UseColor(0.5f, 0.5f, 0.5f).UseOpacity(0.6f), EffectPriority.VeryHigh);
SkyManager.Instance["SpiritMod:Atlas"] = new AtlasSky();
Filters.Scene["SpiritMod:SynthwaveSky"] = new Filter(new AtlasScreenShaderData("FilterMiniTower").UseColor(0.158f, 0.083f, 0.212f).UseOpacity(0.43f), EffectPriority.VeryHigh);
SkyManager.Instance["SpiritMod:SynthwaveSky"] = new VaporwaveSky();
Filters.Scene["SpiritMod:MeteoriteSky"] = new Filter(new AtlasScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0f).UseOpacity(0f), EffectPriority.VeryHigh);
SkyManager.Instance["SpiritMod:MeteoriteSky"] = new MeteoriteSky();
//Music Boxes
LoadMusicBox("CrimsonNightBox", "Sounds/Music/CrimsonNight");
LoadMusicBox("OceanDepthsBox", "Sounds/Music/UnderwaterMusic");
LoadMusicBox("TranquilWindsBox", "Sounds/Music/TranquilWinds");
LoadMusicBox("NeonMusicBox", "Sounds/Music/NeonTech");
LoadMusicBox("HyperspaceDayBox", "Sounds/Music/NeonTech1");
LoadMusicBox("SpiritBox1", "Sounds/Music/SpiritOverworld");
LoadMusicBox("SpiritBox2", "Sounds/Music/SpiritLayer1");
LoadMusicBox("SpiritBox3", "Sounds/Music/SpiritLayer2");
LoadMusicBox("SpiritBox4", "Sounds/Music/SpiritLayer3");
LoadMusicBox("ReachBox", "Sounds/Music/Reach");
LoadMusicBox("BriarNightBox", "Sounds/Music/ReachNighttime");
LoadMusicBox("BriarUndergroundBox", "Sounds/Music/ReachUnderground");
LoadMusicBox("AsteroidBox", "Sounds/Music/Asteroids");
LoadMusicBox("StarplateBox", "Sounds/Music/Starplate");
LoadMusicBox("MJWBox", "Sounds/Music/MoonJelly");
LoadMusicBox("ScarabBox", "Sounds/Music/Scarabeus");
LoadMusicBox("AtlasBox", "Sounds/Music/Atlas");
LoadMusicBox("VinewrathBox", "Sounds/Music/ReachBoss");
LoadMusicBox("AvianBox", "Sounds/Music/AncientAvian");
LoadMusicBox("InfernonBox", "Sounds/Music/Infernon");
LoadMusicBox("BlizzardBox", "Sounds/Music/Blizzard");
LoadMusicBox("AuroraBox", "Sounds/Music/AuroraSnow");
LoadMusicBox("SnowNightBox", "Sounds/Music/SnowNighttime");
LoadMusicBox("DesertNightBox", "Sounds/Music/DesertNighttime");
LoadMusicBox("LuminousNightBox", "Sounds/Music/OceanNighttime");
LoadMusicBox("HallowNightBox", "Sounds/Music/HallowNight");
LoadMusicBox("CalmNightBox", "Sounds/Music/CalmNight");
LoadMusicBox("CorruptNightBox", "Sounds/Music/CorruptNight");
LoadMusicBox("MeteorBox", "Sounds/Music/Meteor");
LoadMusicBox("MarbleBox", "Sounds/Music/MarbleBiome");
LoadMusicBox("GraniteBox", "Sounds/Music/GraniteBiome");
LoadMusicBox("SpiderCaveBox", "Sounds/Music/SpiderCave");
LoadMusicBox("BlueMoonBox", "Sounds/Music/BlueMoon");
LoadMusicBox("TideBox", "Sounds/Music/DepthInvasion");
LoadMusicBox("JellyDelugeBox", "Sounds/Music/JellySky");
LoadMusicBox("FrostLegionBox", "Sounds/Music/FrostLegion");
LoadMusicBox("AshfallBox", "Sounds/Music/AshStorm");
LoadMusicBox("VictoryDayBox", "Sounds/Music/VictoryDay");
LoadMusicBox("SkeletronPrimeBox", "Sounds/Music/SkeletronPrime");
AutoSellUI.visible = false;
Mechanics.AutoSell.Sell_NoValue.Sell_NoValue.visible = false;
Mechanics.AutoSell.Sell_Lock.Sell_Lock.visible = false;
Mechanics.AutoSell.Sell_Weapons.Sell_Weapons.visible = false;
AutoSellUI_INTERFACE.SetState(AutoSellUI_SHORTCUT);
SellNoValue_INTERFACE.SetState(SellNoValue_SHORTCUT);
SellLock_INTERFACE.SetState(SellLock_SHORTCUT);
SellWeapons_INTERFACE.SetState(SellWeapons_SHORTCUT);
Main.OnPreDraw += DrawStarGoopTarget;
primitives = new PrimTrailManager();
primitives.LoadContent(Main.graphics.GraphicsDevice);
InitStargoop();
AdditiveCallManager.Load();
RhythmMinigame.LoadStatic();
GuitarMinigame.LoadStatic();
}
// using a mildly specific name to avoid mod clashes
ChatManager.Register<UI.Chat.QuestTagHandler>(["sq", "spiritQuest"]);
}
private void LoadMusicBox(string name, string path) => MusicLoader.AddMusicBox(this, MusicLoader.GetMusicSlot(this, path), Find<ModItem>(name).Type, Find<ModTile>(name).Type);
public void CheckScreenSize()
{
if (!Main.dedServ && !Main.gameMenu)
{
Main.QueueMainThreadAction(() =>
{
if (_lastScreenSize != new Vector2(Main.screenWidth, Main.screenHeight) && primitives != null)
primitives.InitializeTargets(Main.graphics.GraphicsDevice);
if (_lastViewSize != Main.ViewSize && Metaballs is not null)
Metaballs.Initialize(Main.graphics.GraphicsDevice);
if ((_lastViewPort.Bounds != Main.graphics.GraphicsDevice.Viewport.Bounds || _lastScreenSize != new Vector2(Main.screenWidth, Main.screenHeight) || _lastViewSize != Main.ViewSize)
&& basicEffect != null && primitives != null)
{
Helpers.SetBasicEffectMatrices(ref basicEffect, Main.GameViewMatrix.Zoom);
Helpers.SetBasicEffectMatrices(ref primitives.pixelEffect, Main.GameViewMatrix.Zoom);
Helpers.SetBasicEffectMatrices(ref primitives.galaxyEffect, new Vector2(1));
}
_lastScreenSize = new Vector2(Main.screenWidth, Main.screenHeight);
_lastViewSize = Main.ViewSize;
_lastViewPort = Main.graphics.GraphicsDevice.Viewport;
});
}
}
public static void InitStargoop()
{
Metaballs = new StargoopManager();
Metaballs.LoadContent();
Metaballs.Initialize(Main.graphics.GraphicsDevice);
var friendlyDust = (FriendlyStargoopDust)ModContent.GetModDust(ModContent.DustType<FriendlyStargoopDust>());
var enemyDust = (EnemyStargoopDust)ModContent.GetModDust(ModContent.DustType<EnemyStargoopDust>());
friendlyDust.Reset();
enemyDust.Reset();
}
public override void Unload()
{
BoonLoader.Unload();
spiritRNG = null;
auroraEffect = null;
StarjinxNoise = null;
CircleNoise = null;
StarfirePrims = null;
ScreamingSkullTrail = null;
RipperSlugShader = null;
EyeballShader = null;
RepeatingTextureShader = null;
PrimitiveTextureMap = null;
ArcLashShader = null;
ConicalNoise = null;
JemShaders = null;
ThyrsusShader = null;
JetbrickTrailShader = null;
OutlinePrimShader = null;
SunOrbShader = null;
noise = null;
AutoSellUI_INTERFACE = null;
SellNoValue_INTERFACE = null;
SellWeapons_INTERFACE = null;
SellLock_INTERFACE = null;
SpiritModAutoSellTextures.Unload();
QuestManager.Unload();
QuestBookUIState = null;
QuestHUD = null;
QuestBookHotkey = null;
QuestHUDHotkey = null;
EventManager.Unload();
//Coverings.Unload();
//Coverings = null;
SpiritMultiplayer.Unload();
AdditiveCallManager.Unload();
SpiritGlowmask.Unload();
ParticleHandler.Unload();
AutoloadMinionDictionary.Unload();
Mechanics.BackgroundSystem.BackgroundItemManager.Unload();
glitchEffect = null;
glitchScreenShader = null;
TrailManager = null;
GlobalNoise = null;
GlyphBase.UninitGlyphLookup();
primitives = null;
Metaballs = null;
ShaderDict = new Dictionary<string, Effect>();
SpiritDetours.Unload();
PortraitManager.Unload(); //Idk if this is necessary but it seems like a good move - Gabe
//UnloadDetours();
// remove any custom chat tag handlers
var handlerDict = (ConcurrentDictionary<string, ITagHandler>)typeof(ChatManager).GetField("_handlers", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
handlerDict.TryRemove("spiritQuest", out var _);
}
private void DrawStarGoopTarget(GameTime obj)
{
if (!Main.gameMenu && Metaballs != null && Main.graphics.GraphicsDevice != null && Main.spriteBatch != null)
Metaballs.DrawToTarget(Main.spriteBatch, Main.graphics.GraphicsDevice);
}
public static Color StarjinxColor(float Timer)
{
float timer = Timer % 10;
var yellow = new Color(238, 207, 91);
var orange = new Color(255, 131, 91);
var pink = new Color(230, 55, 166);
if (timer < 3)
return Color.Lerp(yellow, orange, timer / 3);
else if (timer < 6)
return Color.Lerp(orange, pink, (timer - 3) / 3);
else
return Color.Lerp(pink, yellow, (timer - 6) / 3);
}
internal static string GetWeatherRadioText(string key)
{
if (MyWorld.ashRain) return "Ashfall";
else if (AuroraWorld.AuroraActive) return "Aurora";
else if (MyWorld.blueMoon) return "Mystic Moon";
else if (MyWorld.jellySky) return "Jelly Deluge";
else if (LuminousWorld.LuminousOceanActive) return "Luminous Seas";
else if (MyWorld.calmNight) return "Calm Night";
else if (MyWorld.rareStarfallEvent) return "Starfall";
return LanguageManager.Instance.GetText(key).Value;
}
public override void PostSetupContent()
{
GlyphBase.InitializeGlyphLookup();
BossChecklistDataHandler.RegisterSpiritData(this);
CrossModContent();
FinishedContentSetup = true;
}
private static void CrossModContent()
{
if (ModLoader.TryGetMod("DialogueTweak", out Mod dialogue))
{
dialogue.Call("AddButton", ModContent.NPCType<Oracle>(), () => "Bless",
"SpiritMod/NPCs/Town/Oracle/OracleAuraLetter",
() =>
{
if (Main.mouseLeft)
Oracle.Bless();
});
// Since NPC types that may have quests are not certain, we add the button for all NPCs and check if they have a quest in the availability parameter
for (int i = 0; i < NPCLoader.NPCCount; i++)
{
dialogue.Call("AddButton", i, () => "Quest",
"DialogueTweak/Interfaces/Assets/Icon_Help", // Directly referencing this mod's texture.
() =>
{
if (Main.mouseLeft)
SpiritDetours.UnlockQuestFromNPC(Main.npc[Main.LocalPlayer.talkNPC]);
},
() =>
{
NPC talkNPC = Main.npc[Main.LocalPlayer.talkNPC];
var queue = ModContent.GetInstance<QuestWorld>().NPCQuestQueue;
return QuestManager.QuestBookUnlocked && queue.ContainsKey(talkNPC.type) && queue[talkNPC.type].Count > 0;
});
}
}
if (ModLoader.TryGetMod("AutoTrash", out _))
AutoTrashEnabled = true;
}
internal bool _questBookHover;
internal bool _questBookToggle = false;
public static void InvokeModifyTransform(SpriteViewMatrix matrix) => OnModifyTransformMatrix?.Invoke(matrix);
public static float tremorTime;
public int screenshakeTimer = 0;
internal static void DrawUpdateToggles()
{
Point mousePoint = new Point(Main.mouseX, Main.mouseY);
Rectangle AutoSellUI_TOGGLERECTANGLE = new Rectangle(494, 280, 39, 39);
bool AutoSellUI_TOGGLE = AutoSellUI_TOGGLERECTANGLE.Contains(mousePoint);
if (AutoSellUI_TOGGLE && Main.playerInventory && Main.npcShop > 0)
{
Main.LocalPlayer.mouseInterface = true;
Main.HoverItem = new Item();
Main.hoverItemName = Language.GetTextValue("Mods.SpiritMod.MiscUI.AutoSell");
}
Rectangle Sell_Lock_TOGGLERECTANGLE = new Rectangle(502, 324, 32, 32);
bool Sell_Lock_TOGGLE = Sell_Lock_TOGGLERECTANGLE.Contains(mousePoint);
if (Sell_Lock_TOGGLE && Main.playerInventory && Main.npcShop > 0)
{
Main.LocalPlayer.mouseInterface = true;
Main.HoverItem = new Item();
Main.hoverItemName = Language.GetTextValue("Mods.SpiritMod.MiscUI.SellLock");
}
Rectangle Sell_Weapons_TOGGLERECTANGLE = new Rectangle(502, 362, 32, 32);
bool Sell_Weapons_TOGGLE = Sell_Weapons_TOGGLERECTANGLE.Contains(mousePoint);
if (Sell_Weapons_TOGGLE && Main.playerInventory && Main.npcShop > 0)
{
Main.LocalPlayer.mouseInterface = true;
Main.HoverItem = new Item();
Main.hoverItemName = Language.GetTextValue("Mods.SpiritMod.MiscUI.SellWeapons");
}
Rectangle Sell_NoValue_TOGGLERECTANGLE = new Rectangle(502, 400, 32, 32);
bool Sell_NoValue_TOGGLE = Sell_NoValue_TOGGLERECTANGLE.Contains(mousePoint);
if (Sell_NoValue_TOGGLE && Main.playerInventory && Main.npcShop > 0)
{
Main.LocalPlayer.mouseInterface = true;
Main.HoverItem = new Item();
Main.hoverItemName = Language.GetTextValue("Mods.SpiritMod.MiscUI.SellNoValue");
}
}
public void DrawEventUI(SpriteBatch spriteBatch)
{
if (TideWorld.TheTide && Main.LocalPlayer.ZoneBeach)
{
const float Scale = 0.875f;
const float Alpha = 0.5f;
const int InternalOffset = 6;
const int OffsetX = 20;
const int OffsetY = 20;
Texture2D EventIcon = Assets.Request<Texture2D>("Textures/InvasionIcons/Depths_Icon", AssetRequestMode.ImmediateLoad).Value;
Color descColor = new Color(77, 39, 135);
Color waveColor = new Color(255, 241, 51);
int width = (int)(200f * Scale);
int height = (int)(46f * Scale);
Rectangle waveBackground = Utils.CenteredRectangle(new Vector2(Main.screenWidth - OffsetX - 100f, Main.screenHeight - OffsetY - 23f), new Vector2(width, height));
Utils.DrawInvBG(spriteBatch, waveBackground, new Color(63, 65, 151, 255) * 0.785f);
string waveText = Language.GetTextValue("Mods.SpiritMod.Events.TheTide.Wave", TideWorld.TideWave) + TideWorld.TidePoints + "%";
Utils.DrawBorderString(spriteBatch, waveText, new Vector2(waveBackground.Center.X, waveBackground.Y + 5), Color.White, Scale, 0.5f, -0.1f);
Rectangle waveProgressBar = Utils.CenteredRectangle(new Vector2(waveBackground.Center.X, waveBackground.Y + waveBackground.Height * 0.75f), TextureAssets.ColorBar.Size());
var waveProgressAmount = new Rectangle(0, 0, (int)(TextureAssets.ColorBar.Width() * 0.01f * MathHelper.Clamp(TideWorld.TidePoints, 0f, 100f)), TextureAssets.ColorBar.Height());
var offset = new Vector2((waveProgressBar.Width - (int)(waveProgressBar.Width * Scale)) * 0.5f, (waveProgressBar.Height - (int)(waveProgressBar.Height * Scale)) * 0.5f);
spriteBatch.Draw(TextureAssets.ColorBar.Value, waveProgressBar.Location.ToVector2() + offset, null, Color.White * Alpha, 0f, new Vector2(0f), Scale, SpriteEffects.None, 0f);
spriteBatch.Draw(TextureAssets.ColorBar.Value, waveProgressBar.Location.ToVector2() + offset, waveProgressAmount, waveColor, 0f, new Vector2(0f), Scale, SpriteEffects.None, 0f);
Vector2 descSize = new Vector2(154, 40) * Scale;
Rectangle barrierBackground = Utils.CenteredRectangle(new Vector2(Main.screenWidth - OffsetX - 100f, Main.screenHeight - OffsetY - 19f), new Vector2(width, height));
Rectangle descBackground = Utils.CenteredRectangle(new Vector2(barrierBackground.Center.X, barrierBackground.Y - InternalOffset - descSize.Y * 0.5f), descSize * 0.9f);
Utils.DrawInvBG(spriteBatch, descBackground, descColor * Alpha);
int descOffset = (descBackground.Height - (int)(32f * Scale)) / 2;
var icon = new Rectangle(descBackground.X + descOffset + 7, descBackground.Y + descOffset, (int)(32 * Scale), (int)(32 * Scale));
spriteBatch.Draw(EventIcon, icon, Color.White);
Utils.DrawBorderString(spriteBatch, Language.GetTextValue("Mods.SpiritMod.BossChecklistIntegration.TheTide.EntryName"), new Vector2(barrierBackground.Center.X, barrierBackground.Y - InternalOffset - descSize.Y * 0.5f), Color.White, 0.8f, 0.3f, 0.4f);
}
}
}