private void ReceivedBulletHitMsg(NetIncomingMessage msg) { long bulletId = msg.ReadInt64(); long aId = msg.ReadInt64(); int damage = msg.ReadInt32(); IProjectile bullet = null; IDestroyable target = null; foreach (ISceneObject obj in objects) { if (obj.Id == bulletId) { if (obj is IProjectile) { bullet = obj as IProjectile; } ExplodingSingularityBulletControl c = obj.GetControlOfType <ExplodingSingularityBulletControl>(); if (c != null) { c.StartDetonation(); } break; } } foreach (ISceneObject obj in objects) { if (obj.Id != aId) { continue; } if (obj is IDestroyable) { target = (obj as IDestroyable); } else { Logger.Error("Object id " + bulletId + " (" + obj.GetType().Name + ") is supposed to be a instance of IDestroyable but it is not"); } break; } if (bullet == null) { return; } if (target != null) { target.TakeDamage(damage, bullet); } else { idsToRemove.Add(aId); } if (!(bullet is SingularityExplodingBullet)) { bullet.DoRemoveMe(); } }