private void ReceivedSingularityMineHitMsg(NetIncomingMessage msg) { long mineId = msg.ReadInt64(); long id = msg.ReadInt64(); Vector pos = msg.ReadVector(); Vector dir = msg.ReadVector(); float speed = msg.ReadFloat(); foreach (ISceneObject obj in objects) { if (obj.Id == mineId) { DroppingSingularityControl c = obj.GetControlOfType <DroppingSingularityControl>(); if (c == null) { ExplodingSingularityBulletControl c2 = obj.GetControlOfType <ExplodingSingularityBulletControl>(); if (c2 == null) { Logger.Error("Object id " + mineId + " (" + obj.GetType().Name + ") is supposed to be a SingularityMine and have DroppingSingularityControl " + "or SingularityExplodingBullet and have ExplodingSingularityBulletControl, but control is null"); } else { c2.StartDetonation(); } } else { c.StartDetonation(); } continue; } if (obj.Id != id) { continue; } obj.Position = pos; (obj as IMovable).Direction = dir; IMovementControl control = obj.GetControlOfType <IMovementControl>(); if (control != null) { control.Speed = speed; } } //SoundManager.Instance.StartPlayingOnce(SharedDef.MUSIC_EXPLOSION); }
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(); } }