-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathCalamityMod.cs
More file actions
129 lines (107 loc) · 4.33 KB
/
Copy pathCalamityMod.cs
File metadata and controls
129 lines (107 loc) · 4.33 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
using System;
using System.IO;
using System.Runtime.CompilerServices;
using CalamityMod.FluidSimulation;
using CalamityMod.Items;
using CalamityMod.MainMenu;
using CalamityMod.Particles;
using CalamityMod.Projectiles;
using log4net;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
[assembly: InternalsVisibleTo("CalTestHelpers")]
[assembly: InternalsVisibleTo("InfernumMode")]
namespace CalamityMod
{
public class CalamityMod : Mod
{
#region External Flags
// External flag to disable Defense Damage
// This can be edited by other mods using reflection if desired
// Note that this flag trumps Bloodflare Core and will stop that accessory from working properly.
// There is also a means to disable defense damage on a per-player basis.
public static bool ExternalFlag_DisableDefenseDamage = false;
#endregion
internal static CalamityMod Instance => _Instance ??= ModContent.GetInstance<CalamityMod>();
private static CalamityMod _Instance;
// This should not be named as 'Logger' as it hides Instance Property 'Logger'
internal static ILog Log => Instance.Logger;
#region Load
public override void Load()
{
// Initialize the EnemyStats struct as early as it is safe to do so
NPCStats.LoadDebuffs();
// Initialize Calamity Balance, since it is tightly coupled with the remaining systems
CalamityGlobalItem.LoadTweaks();
CalamityGlobalProjectile.LoadTweaks();
if (!Main.dedServ)
{
// This must be done separately from immediate loading, as loading is now multithreaded.
// However, render targets and certain other graphical objects can only be created on the main thread.
Main.QueueMainThreadAction(() => Main.OnPreDraw += PrepareRenderTargets);
}
}
#endregion
#region Unload
public override void Unload()
{
NPCStats.UnloadDebuffs();
CalamityGlobalItem.UnloadTweaks();
CalamityGlobalProjectile.UnloadTweaks();
Main.QueueMainThreadAction(() =>
{
Main.OnPreDraw -= PrepareRenderTargets;
});
_Instance = null;
base.Unload();
}
#endregion
#region Render Target Management
public static void PrepareRenderTargets(GameTime gameTime)
{
DeathAshParticle.PrepareRenderTargets();
FluidFieldManager.Update();
}
#endregion Render Target Management
#region Music
// This function returns an available Calamity Music Mod track, or null if the Calamity Music Mod is not available.
public int? GetMusicFromMusicMod(string songFilename) => ExternalMods.MusicAvailable ? MusicLoader.GetMusicSlot(ExternalMods.musicMod, "Sounds/Music/" + songFilename) : null;
// This function returns an available VCMM track, or null if VCMM is not available.
// Unlike the main Music Mod, VCMM is hierarchical.
public int? GetMusicFromVCMM(string songPath) => ExternalMods.VCMMAvailable ? MusicLoader.GetMusicSlot(ExternalMods.vcmm, "Assets/" + songPath) : null;
#endregion
#region Mod Support
public override object Call(params object[] args) => ModCalls.Call(args);
#endregion
#region Seasons
public static Season CurrentSeason
{
get
{
DateTime date = DateTime.Now;
int day = date.DayOfYear - Convert.ToInt32(DateTime.IsLeapYear(date.Year) && date.DayOfYear > 59);
if (day < 80 || day >= 355)
{
return Season.Winter;
}
else if (day >= 80 && day < 172)
{
return Season.Spring;
}
else if (day >= 172 && day < 266)
{
return Season.Summer;
}
else
{
return Season.Fall;
}
}
}
#endregion
#region Netcode
public override void HandlePacket(BinaryReader reader, int whoAmI) => CalamityNetcode.HandlePacket(this, reader, whoAmI);
#endregion
}
}