public bool ProcessMessage(ExplosionEventArgs message) { if (message == null) { return(false); } Vector3 offsetCorrection = Vector3.zero; if (message.TargetVesselId != Guid.Empty) { Vector3 vesselPositionInClient = new Vector3(message.TargetVesselComX, message.TargetVesselComY, message.TargetVesselComZ); Vessel vessel = FlightGlobals.VesselsLoaded.FirstOrDefault(v => v.id == message.TargetVesselId); if (vessel != null && !vessel.packed) { // calculating offset offsetCorrection = vessel.CoM - vesselPositionInClient; } } ExplosionFx.CreateVisualExplosion(new Vector3(message.PositionX, message.PositionY, message.PositionZ), message.TntMassEquivalent, message.ExplosionModelPath, message.SoundPath, new Vector3(message.DirectionX, message.DirectionY, message.DirectionZ)); return(true); }
private bool ExplosiveDetonation(Part hitPart, RaycastHit hit, Ray ray, bool airDetonation = false) { /////////////////////////////////////////////////////////////////////// // High Explosive Detonation /////////////////////////////////////////////////////////////////////// if (hitPart == null || hitPart.vessel != sourceVessel) { //if bullet hits and is HE, detonate and kill bullet if (explosive) { if (BDArmorySettings.DRAW_DEBUG_LABELS) { Debug.Log("[BDArmory]: Detonation Triggered | penetration: " + hasPenetrated + " penTick: " + penTicker + " airDet: " + airDetonation); } if (airDetonation) { if (OnlyVisual) { ExplosionFx.CreateVisualExplosion(hit.point, GetExplosivePower(), explModelPath, explSoundPath); } else { ExplosionFx.CreateExplosion(hit.point, GetExplosivePower(), explModelPath, explSoundPath, false, caliber, null, default(Vector3), hitPart?.vessel != null ? hitPart.vessel : null); } } else { if (OnlyVisual) { ExplosionFx.CreateVisualExplosion(hit.point - (ray.direction * 0.1f), GetExplosivePower(), explModelPath, explSoundPath, currentVelocity); } else { ExplosionFx.CreateExplosion(hit.point - (ray.direction * 0.1f), GetExplosivePower(), explModelPath, explSoundPath, false, caliber, null, currentVelocity, hitPart?.vessel != null ? hitPart.vessel : null); } } KillBullet(); hasDetonated = true; return(true); } } return(false); }