forked from frankc123/RustSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeathTransfer.cs
254 lines (240 loc) · 8.46 KB
/
DeathTransfer.cs
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
using Facepunch;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using uLink;
using UnityEngine;
public sealed class DeathTransfer : IDLocalCharacterAddon, IInterpTimedEventReceiver
{
[NonSerialized]
private GameObject _ragdollInstance;
[CompilerGenerated]
private static Dictionary<string, int> <>f__switch$map3;
[NonSerialized]
private QueuedShotDeathInfo deathShot;
private const IDLocalCharacterAddon.AddonFlags DeathTransferAddonFlags = 0;
public DeathTransfer() : this(0)
{
}
protected DeathTransfer(IDLocalCharacterAddon.AddonFlags addonFlags) : base(addonFlags)
{
}
[RPC]
protected void Client_OnKilled(NetworkMessageInfo info)
{
this.Client_OnKilledShared(false, null, ref info);
}
[RPC]
protected void Client_OnKilledBy(NetworkViewID attackerViewID, NetworkMessageInfo info)
{
NetworkView view = NetworkView.Find(attackerViewID);
if (view == null)
{
this.Client_OnKilledShared(false, null, ref info);
}
else
{
Character component = view.GetComponent<Character>();
this.Client_OnKilledShared((bool) component, component, ref info);
}
}
private void Client_OnKilledShared(bool killedBy, Character attacker, ref NetworkMessageInfo info)
{
Controllable controllable;
bool flag2;
AudioClipArray death = base.GetTrait<CharacterSoundsTrait>().death;
death[Random.Range(0, death.Length)].Play(base.transform.position, (float) 1f, (float) 1f, (float) 10f);
bool localControlled = base.localControlled;
if (localControlled)
{
base.rposLimitFlags = RPOSLimitFlags.HideSprites | RPOSLimitFlags.HideContext | RPOSLimitFlags.HideInventory | RPOSLimitFlags.KeepOff;
DeathScreen.Show();
}
BaseHitBox remote = base.idMain.GetRemote<BaseHitBox>();
if (remote != null)
{
remote.collider.enabled = false;
}
if (killedBy && (attacker != null))
{
controllable = attacker.controllable;
flag2 = (controllable != null) && controllable.localPlayerControlled;
}
else
{
controllable = null;
flag2 = false;
}
base.AdjustClientSideHealth(0f);
if (!localControlled && !flag2)
{
foreach (Collider collider in base.GetComponentsInChildren<Collider>())
{
if (collider != null)
{
collider.enabled = false;
}
}
InterpTimedEvent.Queue(this, "RAG", ref info);
NetCull.DontDestroyWithNetwork((MonoBehaviour) this);
}
else
{
InterpTimedEvent.Queue(this, "ClientLocalDeath", ref info);
if (localControlled)
{
InterpTimedEvent.Clear(true);
}
else
{
InterpTimedEvent.Remove(this, true);
}
}
}
[RPC]
protected void Client_OnKilledShot(Vector3 point, Angle2 normal, byte bodyPart, NetworkMessageInfo info)
{
this.Client_ShotShared(ref point, ref normal, bodyPart, ref info);
this.Client_OnKilled(info);
}
[RPC]
protected void Client_OnKilledShotBy(NetworkViewID attackerViewID, Vector3 point, Angle2 normal, byte bodyPart, NetworkMessageInfo info)
{
this.Client_ShotShared(ref point, ref normal, bodyPart, ref info);
this.Client_OnKilledBy(attackerViewID, info);
}
private void Client_ShotShared(ref Vector3 point, ref Angle2 normal, byte bodyPart, ref NetworkMessageInfo info)
{
this.deathShot.Set(base.idMain.hitBoxSystem, ref point, ref normal, bodyPart, ref info);
}
private void ClientLocalDeath()
{
Ragdoll ragdoll = this.DeathRagdoll();
if (base.localControlled)
{
if (!actor.forceThirdPerson)
{
CameraMount componentInChildren = base.GetComponentInChildren<CameraMount>();
if ((componentInChildren != null) && componentInChildren.open)
{
Transform transform;
bool flag;
RagdollTransferInfoProvider controller = base.controller as RagdollTransferInfoProvider;
if (controller != null)
{
try
{
flag = controller.RagdollTransferInfo.FindHead(ragdoll.transform, out transform);
}
catch (Exception exception)
{
Debug.LogException(exception, this);
transform = null;
flag = false;
}
}
else
{
transform = null;
flag = false;
}
if (flag)
{
Vector3 position = transform.InverseTransformPoint(componentInChildren.transform.position);
position.y += 0.08f;
Vector3 vector2 = transform.TransformPoint(position);
ragdoll.origin += vector2 - transform.position;
CameraMount.CreateTemporaryCameraMount(componentInChildren, transform).camera.nearClipPlane = 0.02f;
}
ArmorModelRenderer local = ragdoll.GetLocal<ArmorModelRenderer>();
if (local != null)
{
local.enabled = false;
}
}
else
{
Debug.Log("No camera?");
}
}
Object.Destroy(base.GetComponent<LocalDamageDisplay>());
}
}
private Ragdoll CreateRagdoll()
{
CharacterRagdollTrait trait = base.GetTrait<CharacterRagdollTrait>();
if (trait == null)
{
return null;
}
GameObject obj2 = Object.Instantiate(trait.ragdollPrefab, base.transform.position, base.transform.rotation) as GameObject;
Ragdoll component = obj2.GetComponent<Ragdoll>();
component.sourceMain = base.idMain;
this._ragdollInstance = obj2;
Object.Destroy(obj2, 80f);
this.deathShot.LinkRagdoll(base.transform, obj2);
ArmorModelRenderer local = base.GetLocal<ArmorModelRenderer>();
ArmorModelRenderer renderer2 = component.GetLocal<ArmorModelRenderer>();
if ((local != null) && (renderer2 != null))
{
renderer2.BindArmorModels(local.GetArmorModelMemberMapCopy());
}
return component;
}
private Ragdoll DeathRagdoll()
{
Ragdoll ragdoll = this.CreateRagdoll();
PlayerProxyTest component = base.GetComponent<PlayerProxyTest>();
if (component.body != null)
{
component.body.SetActive(false);
}
return ragdoll;
}
void IInterpTimedEventReceiver.OnInterpTimedEvent()
{
string tag = InterpTimedEvent.Tag;
if (tag != null)
{
int num;
if (<>f__switch$map3 == null)
{
Dictionary<string, int> dictionary = new Dictionary<string, int>(2);
dictionary.Add("ClientLocalDeath", 0);
dictionary.Add("RAG", 1);
<>f__switch$map3 = dictionary;
}
if (<>f__switch$map3.TryGetValue(tag, out num))
{
if (num == 0)
{
try
{
this.ClientLocalDeath();
}
finally
{
if (!base.localControlled)
{
Object.Destroy(base.gameObject);
}
}
return;
}
if (num == 1)
{
try
{
this.DeathRagdoll();
}
finally
{
Object.Destroy(base.gameObject);
}
return;
}
}
}
InterpTimedEvent.MarkUnhandled();
}
}