1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using GameNetcodeStuff ;
4
+ using Steamworks ;
5
+
6
+ namespace Coroner {
7
+ class AdvancedDeathTracker {
8
+ private static readonly Dictionary < int , AdvancedCauseOfDeath > PlayerCauseOfDeath = new Dictionary < int , AdvancedCauseOfDeath > ( ) ;
9
+
10
+ public static void ClearDeathTracker ( ) {
11
+ PlayerCauseOfDeath . Clear ( ) ;
12
+ }
13
+
14
+ public static void SetCauseOfDeath ( int playerIndex , AdvancedCauseOfDeath causeOfDeath ) {
15
+ PlayerCauseOfDeath [ playerIndex ] = causeOfDeath ;
16
+ }
17
+
18
+ public static void SetCauseOfDeath ( int playerIndex , CauseOfDeath causeOfDeath ) {
19
+ SetCauseOfDeath ( playerIndex , ConvertCauseOfDeath ( causeOfDeath ) ) ;
20
+ }
21
+
22
+ public static void SetCauseOfDeath ( PlayerControllerB playerController , CauseOfDeath causeOfDeath ) {
23
+ SetCauseOfDeath ( ( int ) playerController . playerClientId , ConvertCauseOfDeath ( causeOfDeath ) ) ;
24
+ }
25
+
26
+ public static void SetCauseOfDeath ( PlayerControllerB playerController , AdvancedCauseOfDeath causeOfDeath ) {
27
+ SetCauseOfDeath ( ( int ) playerController . playerClientId , causeOfDeath ) ;
28
+ }
29
+
30
+ public static AdvancedCauseOfDeath GetCauseOfDeath ( int playerIndex ) {
31
+ PlayerControllerB playerController = StartOfRound . Instance . allPlayerScripts [ playerIndex ] ;
32
+
33
+ return GetCauseOfDeath ( playerController ) ;
34
+ }
35
+
36
+ public static AdvancedCauseOfDeath GetCauseOfDeath ( PlayerControllerB playerController ) {
37
+ if ( ! PlayerCauseOfDeath . ContainsKey ( ( int ) playerController . playerClientId ) ) {
38
+ return GuessCauseOfDeath ( playerController ) ;
39
+ }
40
+ return PlayerCauseOfDeath [ ( int ) playerController . playerClientId ] ;
41
+ }
42
+
43
+ public static AdvancedCauseOfDeath GuessCauseOfDeath ( PlayerControllerB playerController ) {
44
+ if ( playerController . isPlayerDead ) {
45
+ if ( playerController . causeOfDeath == CauseOfDeath . Suffocation && playerController . isSinking ) {
46
+ return AdvancedCauseOfDeath . Quicksand ;
47
+ } else if ( IsHoldingJetpack ( playerController ) ) {
48
+ if ( playerController . causeOfDeath == CauseOfDeath . Gravity ) {
49
+ return AdvancedCauseOfDeath . Jetpack_Gravity ;
50
+ } else if ( playerController . causeOfDeath == CauseOfDeath . Blast ) {
51
+ return AdvancedCauseOfDeath . Jetpack_Blast ;
52
+ }
53
+ }
54
+
55
+ return ConvertCauseOfDeath ( playerController . causeOfDeath ) ;
56
+ } else {
57
+ return AdvancedCauseOfDeath . Unknown ;
58
+ }
59
+ }
60
+
61
+ public static bool IsHoldingJetpack ( PlayerControllerB playerController ) {
62
+ var heldObject = playerController . currentlyHeldObjectServer . gameObject . GetComponent < GrabbableObject > ( ) ;
63
+ if ( heldObject == null ) {
64
+ return false ;
65
+ }
66
+ if ( heldObject is JetpackItem ) {
67
+ return true ;
68
+ } else {
69
+ return false ;
70
+ }
71
+ }
72
+
73
+ public static AdvancedCauseOfDeath ConvertCauseOfDeath ( CauseOfDeath causeOfDeath ) {
74
+ switch ( causeOfDeath ) {
75
+ case CauseOfDeath . Unknown :
76
+ return AdvancedCauseOfDeath . Unknown ;
77
+ case CauseOfDeath . Bludgeoning :
78
+ return AdvancedCauseOfDeath . Bludgeoning ;
79
+ case CauseOfDeath . Gravity :
80
+ return AdvancedCauseOfDeath . Gravity ;
81
+ case CauseOfDeath . Blast :
82
+ return AdvancedCauseOfDeath . Blast ;
83
+ case CauseOfDeath . Strangulation :
84
+ return AdvancedCauseOfDeath . Strangulation ;
85
+ case CauseOfDeath . Suffocation :
86
+ return AdvancedCauseOfDeath . Suffocation ;
87
+ case CauseOfDeath . Mauling :
88
+ return AdvancedCauseOfDeath . Mauling ;
89
+ case CauseOfDeath . Gunshots :
90
+ return AdvancedCauseOfDeath . Gunshots ;
91
+ case CauseOfDeath . Crushing :
92
+ return AdvancedCauseOfDeath . Crushing ;
93
+ case CauseOfDeath . Drowning :
94
+ return AdvancedCauseOfDeath . Drowning ;
95
+ case CauseOfDeath . Abandoned :
96
+ return AdvancedCauseOfDeath . Abandoned ;
97
+ case CauseOfDeath . Electrocution :
98
+ return AdvancedCauseOfDeath . Electrocution ;
99
+ default :
100
+ return AdvancedCauseOfDeath . Unknown ;
101
+ }
102
+ }
103
+
104
+ public static string StringifyCauseOfDeath ( CauseOfDeath causeOfDeath ) {
105
+ return StringifyCauseOfDeath ( ConvertCauseOfDeath ( causeOfDeath ) ) ;
106
+ }
107
+
108
+ public static string StringifyCauseOfDeath ( AdvancedCauseOfDeath causeOfDeath ) {
109
+ switch ( causeOfDeath ) {
110
+ case AdvancedCauseOfDeath . Bludgeoning :
111
+ return "Bludgeoned to death." ;
112
+ case AdvancedCauseOfDeath . Gravity :
113
+ return "Fell to their death." ;
114
+ case AdvancedCauseOfDeath . Blast :
115
+ return "Exploded." ;
116
+ case AdvancedCauseOfDeath . Strangulation :
117
+ return "Strangled to death." ;
118
+ case AdvancedCauseOfDeath . Suffocation :
119
+ return "Suffocated to death." ;
120
+ case AdvancedCauseOfDeath . Mauling :
121
+ return "Mauled to death." ;
122
+ case AdvancedCauseOfDeath . Gunshots :
123
+ return "Shot to death by a turret." ;
124
+ case AdvancedCauseOfDeath . Crushing :
125
+ return "Crushed to death." ;
126
+ case AdvancedCauseOfDeath . Drowning :
127
+ return "Drowned to death." ;
128
+ case AdvancedCauseOfDeath . Abandoned :
129
+ return "Abandoned by their coworkers." ;
130
+ case AdvancedCauseOfDeath . Electrocution :
131
+ return "Electrocuted to death." ;
132
+
133
+ case AdvancedCauseOfDeath . Enemy_DepositItemsDesk :
134
+ return "Received a demotion." ;
135
+ case AdvancedCauseOfDeath . Enemy_Bracken :
136
+ return "Had their neck snapped by a Bracken." ;
137
+ case AdvancedCauseOfDeath . Enemy_EyelessDog :
138
+ return "Was eaten by an Eyeless Dog." ;
139
+ case AdvancedCauseOfDeath . Enemy_ForestGiant :
140
+ return "Swallowed whole by a Forest Giant." ;
141
+ case AdvancedCauseOfDeath . Enemy_CircuitBees :
142
+ return "Electro-stung to death by Circuit Bees." ;
143
+ case AdvancedCauseOfDeath . Enemy_GhostGirl :
144
+ return "Died a mysterious death." ;
145
+ case AdvancedCauseOfDeath . Enemy_EarthLeviathan :
146
+ return "Swallowed whole by an Earth Leviathan." ;
147
+ case AdvancedCauseOfDeath . Enemy_BaboonHawk :
148
+ return "Was eaten by a Baboon Hawk." ;
149
+ case AdvancedCauseOfDeath . Enemy_Jester :
150
+ return "Was the butt of a joke." ;
151
+
152
+ case AdvancedCauseOfDeath . Quicksand :
153
+ return "Got stuck in quicksand." ;
154
+ case AdvancedCauseOfDeath . Jetpack_Gravity :
155
+ return "Flew too close to the sun." ;
156
+ case AdvancedCauseOfDeath . Jetpack_Blast :
157
+ return "Went up in a fiery blaze." ;
158
+
159
+ case AdvancedCauseOfDeath . Unknown :
160
+ return "Died somehow." ;
161
+ default :
162
+ return "Died somehow." ;
163
+ }
164
+ }
165
+
166
+ internal static void SetCauseOfDeath ( PlayerControllerB playerControllerB , object enemy_BaboonHawk )
167
+ {
168
+ throw new NotImplementedException ( ) ;
169
+ }
170
+ }
171
+
172
+ enum AdvancedCauseOfDeath {
173
+ // Basic causes of death
174
+ Unknown ,
175
+ Bludgeoning ,
176
+ Gravity ,
177
+ Blast ,
178
+ Strangulation ,
179
+ Suffocation ,
180
+ Mauling ,
181
+ Gunshots ,
182
+ Crushing ,
183
+ Drowning ,
184
+ Abandoned ,
185
+ Electrocution ,
186
+
187
+ // Custom causes (enemies)
188
+ Enemy_DepositItemsDesk ,
189
+ Enemy_Bracken , // Also known as Flowerman
190
+ Enemy_EyelessDog , // Also known as MouthDog
191
+ Enemy_ForestGiant ,
192
+ Enemy_CircuitBees , // Also known as RedLocustBees
193
+ Enemy_GhostGirl , // Also known as DressGirl
194
+ Enemy_EarthLeviathan , // Also known as SandWorm
195
+ Enemy_BaboonHawk , // Also known as BaboonBird
196
+
197
+ // Custom causes (other)
198
+ Quicksand ,
199
+ Enemy_Jester ,
200
+ Jetpack_Gravity ,
201
+ Jetpack_Blast ,
202
+ }
203
+ }
0 commit comments