forked from StatsHelix/demoinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
128 lines (86 loc) · 2.47 KB
/
Player.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
using DemoInfo.DP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DemoInfo
{
public class Player
{
public string Name { get; set; }
public long SteamID { get; set; }
public Vector Position { get; set; }
public int EntityID { get; set; }
public int HP { get; set; }
public int Armor { get; set; }
public Vector LastAlivePosition { get; set; }
public Vector Velocity { get; set; }
public float ViewDirectionX { get; set; }
public float ViewDirectionY { get; set; }
public int Money { get; set; }
public int CurrentEquipmentValue { get; set; }
public int FreezetimeEndEquipmentValue { get; set; }
public int RoundStartEquipmentValue { get; set; }
public bool IsDucking { get; set; }
internal Entity Entity;
public bool Disconnected { get; set; }
internal int ActiveWeaponID;
public Equipment ActiveWeapon
{
get
{
if (ActiveWeaponID == DemoParser.INDEX_MASK) return null;
return rawWeapons[ActiveWeaponID];
}
}
internal Dictionary<int, Equipment> rawWeapons = new Dictionary<int, Equipment>();
public IEnumerable<Equipment> Weapons { get { return rawWeapons.Values; } }
public bool IsAlive {
get { return HP > 0; }
}
public Team Team { get; set; }
public bool HasDefuseKit { get; set; }
public bool HasHelmet { get; set; }
internal int TeamID;
internal int[] AmmoLeft = new int[32];
public AdditionalPlayerInformation AdditionaInformations { get; internal set; }
public Player()
{
Velocity = new Vector();
LastAlivePosition = new Vector();
}
/// <summary>
/// Copy this instance for multi-threading use.
/// </summary>
public Player Copy()
{
Player me = new Player();
me.EntityID = -1; //this should bot be copied
me.Entity = null;
me.Name = Name;
me.SteamID = SteamID;
me.HP = HP;
me.Armor = Armor;
me.ViewDirectionX = ViewDirectionX;
me.ViewDirectionY = ViewDirectionY;
me.Disconnected = Disconnected;
me.Team = Team;
me.HasDefuseKit = HasDefuseKit;
me.HasHelmet = HasHelmet;
if (Position != null)
me.Position = Position.Copy(); //Vector is a class, not a struct - thus we need to make it thread-safe.
if (LastAlivePosition != null)
me.LastAlivePosition = LastAlivePosition.Copy();
if (Velocity != null)
me.Velocity = Velocity.Copy();
return me;
}
}
public enum Team
{
Spectate = 1,
Terrorist = 2,
CounterTerrorist = 3,
}
}