void OnDie(ref MyEventDie msg) { MyPlayerRemote senderPlayer = (MyPlayerRemote)msg.SenderConnection.Tag; MyEntity deadEntity; if (MyEntities.TryGetEntityById(msg.EntityId.ToEntityId(), out deadEntity)) { Log("On Die: " + deadEntity.DisplayName); deadEntity.IsDestructible = true; deadEntity.Kill(null); if (deadEntity == senderPlayer.Ship) { OnPeerDied(senderPlayer, msg.KillerId); } } else { Log("ON DIE, UNKNOWN ENTITY, " + msg.SenderEndpoint.ToString() + ", ENTITY ID: " + msg.EntityId); } }
public void Die(MyEntity deadEntity, MyEntity killer) { Debug.Assert(deadEntity != null && deadEntity.EntityId.HasValue); Log("Died: " + deadEntity.DisplayName); var msg = new MyEventDie(); msg.EntityId = deadEntity.EntityId.Value.NumericValue; msg.Position = new MyMwcPositionAndOrientation(deadEntity.WorldMatrix); msg.KillerId = killer != null && killer.EntityId != null ? killer.EntityId.Value.PlayerId : (byte?)null; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered); deadEntity.OnDie -= m_onEntityDie; if (deadEntity == MySession.PlayerShip) { OnMeDied(msg.KillerId); } }