public void AddHit(MissionLogEventHit e) { if (e == null) { return; } if (e.TargetObject != null) { e.TargetObject.AddHit((object)e.AttackerPlayer ?? e.AttackerObject, e); } else if (e.TargetPlayer != null) { e.TargetPlayer.AddHit((object)e.AttackerPlayer ?? e.AttackerObject, e); } if (e.AttackerPlayer != null) { e.AttackerPlayer.Hits++; } }
/// <summary> /// Hit, ammo/explosion. For live events only. Doesn't run on history events /// </summary> /// <param name="data"></param> virtual public void OnHit(MissionLogEventHit data) { }
public void AddHit(object source, MissionLogEventHit e) { if (source == null || e == null || String.IsNullOrWhiteSpace(e.AmmoName)) { return; } if (source is GameObject) { var existing = HitsSources.FirstOrDefault(o => o != null && o.Hits != null && o.Object != null && o.Object.Id == (source as GameObject).Id); if (existing == null) { existing = new HitsSource() { Object = source as GameObject, }; HitsSources.Add(existing); } var hits = existing.Hits[e.AmmoName]; if (hits == null) { existing.Hits[e.AmmoName] = new Hit(e.AmmoName) { HitCount = 1 } } ; else { existing.Hits[e.AmmoName].HitCount++; } } else if (source is Player) { var existing = HitsSources.FirstOrDefault(o => o != null && o.Hits != null && o.Player != null && o.Player.Id == (source as Player).Id ); if (existing == null) { existing = new HitsSource() { Player = source as Player, }; HitsSources.Add(existing); } var hits = existing.Hits[e.AmmoName]; if (hits == null) { existing.Hits[e.AmmoName] = new Hit(e.AmmoName) { HitCount = 1 } } ; else { existing.Hits[e.AmmoName].HitCount++; } } }