void OnProjectileHit(ref MyEventProjectileHit msg) { MyEntity target; if (MyEntities.TryGetEntityById(new MyEntityIdentifier(msg.TargetEntityId), out target)) { MyEntity source; if (!msg.SourceEntityId.HasValue || !MyEntities.TryGetEntityById(new MyEntityIdentifier(msg.SourceEntityId.Value), out source)) { source = null; } var ammo = MyAmmoConstants.GetAmmoProperties(msg.AmmoType); target.DoDamage(ammo.HealthDamage, ammo.ShipDamage, ammo.EMPDamage, ammo.DamageType, ammo.AmmoType, source); MyProjectile.ApplyProjectileForce(target, msg.Position, Vector3.Normalize(msg.Direction), !(target is MySmallShipBot)); } }
public void ProjectileHit(MyEntity target, Vector3 position, Vector3 direction, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType, MyEntity source) { if (target.EntityId.HasValue) { MyEventProjectileHit msg = new MyEventProjectileHit(); msg.TargetEntityId = target.EntityId.Value.NumericValue; msg.Position = position; msg.Direction = direction; msg.AmmoType = ammoType; msg.SourceEntityId = source != null ? MyEntityIdentifier.ToNullableInt(source.EntityId) : null; Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableUnordered); } }