public PlayerPositionPropertyMonitor(Player player) { ValueChanged.Add(self => ((IPropertyMonitor)self).ValueChanged.Invoke(self)); ValueChanged.Add(self => ((IPropertyMonitor <Vector>)self).ValueChanged.Invoke(self)); ValueChanged.Add(self => ((IEntityPropertyMonitor)self).ValueChanged.Invoke(self)); ValueChanged.Add(self => ((IEntityPropertyMonitor <Vector>)self).ValueChanged.Invoke(self)); ValueChanged.Add(self => ((IPlayerPropertyMonitor)self).ValueChanged.Invoke(self)); Player = player; LocalOriginXY = new PlayerPropertyMonitor <Vector>("DT_TFLocalPlayerExclusive.m_vecOrigin", Player, o => (Vector)o); LocalOriginZ = new PlayerPropertyMonitor <double>("DT_TFLocalPlayerExclusive.m_vecOrigin[2]", Player, o => (double)o); NonLocalOriginXY = new PlayerPropertyMonitor <Vector>("DT_TFNonLocalPlayerExclusive.m_vecOrigin", Player, o => (Vector)o); NonLocalOriginZ = new PlayerPropertyMonitor <double>("DT_TFNonLocalPlayerExclusive.m_vecOrigin[2]", Player, o => (double)o); LocalOriginXY.ValueChanged.Add(OriginXY_ValueChanged); LocalOriginZ.ValueChanged.Add(OriginZ_ValueChanged); NonLocalOriginXY.ValueChanged.Add(OriginXY_ValueChanged); NonLocalOriginZ.ValueChanged.Add(OriginZ_ValueChanged); Player.PropertiesUpdated.Add(Player_PropertiesUpdated); }
public Player(UserInfo info, WorldState ws, uint entityIndex) { EntityIndex = entityIndex; Info = info; World = ws; #region Property Monitors Position = new PlayerPositionPropertyMonitor(this); Team = new MultiPlayerPropertyMonitor <Team?>(this, new IPropertyMonitor <Team?>[] { new PlayerResourcePropertyMonitor <Team?>("m_iTeam", this, o => (Team)Convert.ToInt32(o)), new PlayerPropertyMonitor <Team?>("DT_BaseEntity.m_iTeamNum", this, o => (Team)Convert.ToInt32(o)) }); IsDead = new MultiPlayerPropertyMonitor <bool?>(this, new IPropertyMonitor <bool?>[] { new PlayerResourcePropertyMonitor <bool?>("m_bAlive", this, o => Convert.ToInt32(o) == 0), new PlayerPropertyMonitor <bool?>("DT_BasePlayer.m_lifeState", this, o => (LifeState)Convert.ToInt32(o) != LifeState.Alive) }); Health = new MultiPlayerPropertyMonitor <int?>(this, new IPropertyMonitor <int?>[] { new PlayerResourcePropertyMonitor <int?>("m_iHealth", this, o => Convert.ToInt32(o)), new PlayerPropertyMonitor <int?>("DT_BasePlayer.m_iHealth", this, o => Convert.ToInt32(o)), }); Class = new MultiPlayerPropertyMonitor <Class?>(this, new IPropertyMonitor <Class?>[] { new PlayerResourcePropertyMonitor <Class?>("m_iPlayerClass", this, o => (Class)Convert.ToInt32(o)), new PlayerPropertyMonitor <Class?>("DT_TFPlayerClassShared.m_iClass", this, o => (Class)Convert.ToInt32(o)) }); PlayerState = new PlayerPropertyMonitor <PlayerState?>("DT_TFPlayerShared.m_nPlayerState", this, o => (PlayerState)(uint)(o)); MaxHealth = new PlayerResourcePropertyMonitor <uint?>("m_iMaxHealth", this, o => (uint)o); MaxBuffedHealth = new PlayerResourcePropertyMonitor <uint?>("m_iMaxBuffedHealth", this, o => (uint)o); Ping = new PlayerResourcePropertyMonitor <uint?>("m_iPing", this, o => (uint)o); Score = new PlayerResourcePropertyMonitor <int?>("m_iScore", this, o => (int)o); Deaths = new PlayerResourcePropertyMonitor <int?>("m_iDeaths", this, o => (int)o); Connected = new PlayerResourcePropertyMonitor <bool?>("m_bConnected", this, o => (uint)o != 0); Damage = new PlayerResourcePropertyMonitor <uint?>("m_iDamage", this, o => (uint)o); // weapons { IPlayerPropertyMonitor <EHandle>[] array = new IPlayerPropertyMonitor <EHandle> [48]; for (int i = 0; i < 48; i++) { array[i] = new PlayerPropertyMonitor <EHandle>(string.Format("m_hMyWeapons.{0:D3}", i), this, o => new EHandle(ws, (uint)o)); } Weapons = ImmutableArray.Create(array); } #endregion World.Listeners.EntityEnteredPVS.Add(Listeners_EntityEnteredPVS); World.Listeners.EntityLeftPVS.Add(Listeners_EntityLeftPVS); if (InPVS) { Listeners_EntityEnteredPVS(Entity); } }