public void AddExplosion(Vector3 position, MyExplosionTypeEnum explosionType, float damage, float radius, bool forceDebris, bool createDecals)
 {
     var msg = new MyEventAddExplosion();
     msg.CreateDecals = createDecals;
     msg.ForceDebris = forceDebris;
     msg.Damage = damage;
     msg.Position = position;
     msg.EntityId = null;
     msg.ExplosionType = (byte)explosionType;
     msg.Radius = radius;
     Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered);
 }
        public void AddExplosion(MyEntity entity, MyExplosionTypeEnum explosionType, float damage, float radius, bool forceDebris, bool createDecals, MyParticleEffectsIDEnum? particleIDOverride = null)
        {
            Debug.Assert(entity != null && entity.EntityId.HasValue);

            var msg = new MyEventAddExplosion();
            msg.Damage = damage;
            msg.EntityId = entity.EntityId.Value.NumericValue;
            msg.ExplosionType = (byte)explosionType;
            msg.Radius = radius;
            msg.ParticleIDOverride = (int?)particleIDOverride;
            msg.CreateDecals = createDecals;
            msg.ForceDebris = forceDebris;

            Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered);
        }
        void OnAddExplosion(ref MyEventAddExplosion msg)
        {
            if (!MyMwcEnums.IsValidValue(msg.ExplosionFlags))
            {
                Alert("Invalid explosion", msg.SenderEndpoint, msg.EventType);
                return;
            }

            MyEntity entity;
            if (msg.EntityId.HasValue && MyEntities.TryGetEntityById(msg.EntityId.Value.ToEntityId(), out entity))
            {
                MyScriptWrapper.AddExplosion(entity, (MyExplosionTypeEnum)msg.ExplosionType, msg.Damage, msg.Radius, msg.ForceDebris, msg.CreateDecals, (MyParticleEffectsIDEnum?)msg.ParticleIDOverride);
            }
            else if (msg.Position.HasValue)
            {
                MyScriptWrapper.AddExplosion(msg.Position.Value, (MyExplosionTypeEnum)msg.ExplosionType, msg.Radius, msg.Damage, msg.ForceDebris, msg.CreateDecals);
            }
            else
            {
                Alert("Invalid explosion", msg.SenderEndpoint, msg.EventType);
            }
        }