Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DontStarveDarknessDamageDealer.cs
Go to the documentation of this file.
4using Terraria.ID;
6
8
10{
11 public const int DARKNESS_HIT_TIMER_MAX_BEFORE_HIT = 60;
12
13 public static int darknessTimer = -1;
14
15 public static int darknessHitTimer = 0;
16
17 public static bool saidMessage = false;
18
19 public static bool lastFrameWasTooBright = true;
20
21 public static void Reset()
22 {
23 ResetTimer();
24 saidMessage = false;
26 }
27
28 private static void ResetTimer()
29 {
30 darknessTimer = -1;
32 }
33
34 private static int GetDarknessDamagePerHit()
35 {
36 return 250;
37 }
38
40 {
41 return 120;
42 }
43
44 private static int GetDarknessTimeForMessage()
45 {
46 return 60;
47 }
48
49 public static void Update(Player player)
50 {
51 if (player.DeadOrGhost || Main.gameInactive || player.shimmering)
52 {
53 ResetTimer();
54 return;
55 }
56 UpdateDarknessState(player);
57 int darknessTimeBeforeStartingHits = GetDarknessTimeBeforeStartingHits();
58 if (darknessTimer >= darknessTimeBeforeStartingHits)
59 {
60 darknessTimer = darknessTimeBeforeStartingHits;
62 if (darknessHitTimer > 60 && !player.immune)
63 {
64 int darknessDamagePerHit = GetDarknessDamagePerHit();
66 player.Hurt(PlayerDeathReason.ByOther(17), darknessDamagePerHit, 0);
68 }
69 }
70 }
71
72 private static void UpdateDarknessState(Player player)
73 {
75 {
76 if (saidMessage)
77 {
78 if (!Main.getGoodWorld)
79 {
80 Main.NewText(Language.GetTextValue("Game.DarknessSafe"), 50, 200, 50);
81 }
82 saidMessage = false;
83 }
84 ResetTimer();
85 return;
86 }
87 int darknessTimeForMessage = GetDarknessTimeForMessage();
88 if (darknessTimer >= darknessTimeForMessage && !saidMessage)
89 {
90 if (!Main.getGoodWorld)
91 {
92 Main.NewText(Language.GetTextValue("Game.DarknessDanger"), 200, 50, 50);
93 }
94 saidMessage = true;
95 }
97 }
98
99 private static bool IsPlayerSafe(Player player)
100 {
101 Vector3 vector = Lighting.GetColor((int)player.Center.X / 16, (int)player.Center.Y / 16).ToVector3();
102 bool flag = true;
103 if (Main.LocalGolfState != null && (Main.LocalGolfState.ShouldCameraTrackBallLastKnownLocation || Main.LocalGolfState.IsTrackingBall))
104 {
106 }
107 if (Main.DroneCameraTracker != null && Main.DroneCameraTracker.IsInUse())
108 {
110 }
111 return vector.Length() >= 0.1f;
112 }
113}
static void PlaySound(int type, Vector2 position, int style=1)
static PlayerDeathReason ByOther(int type)
Vector2 Center
Definition Entity.cs:43
static readonly LegacySoundStyle Item1
Definition SoundID.cs:416
static Color GetColor(Point tileCoords)
Definition Lighting.cs:182
static string GetTextValue(string key)
Definition Language.cs:15
static GolfState LocalGolfState
Definition Main.cs:1876
static bool gameInactive
Definition Main.cs:1074
static void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
Definition Main.cs:61429
static bool getGoodWorld
Definition Main.cs:341
static DroneCameraTracker DroneCameraTracker
Definition Main.cs:1878
double Hurt(PlayerDeathReason damageSource, int Damage, int hitDirection, bool pvp=false, bool quiet=false, bool Crit=false, int cooldownCounter=-1, bool dodgeable=true)
Definition Player.cs:36134