internal void DeferedVoxelCheck() { DeferedVoxels.ApplyAdditions(); for (int i = 0; i < DeferedVoxels.Count; i++) { var p = DeferedVoxels[i].Projectile; var branch = DeferedVoxels[i].Branch; var voxel = DeferedVoxels[i].Voxel; Vector3D?voxelHit = null; if (branch == VoxelIntersectBranch.DeferFullCheck) { if (p.Beam.Length > 85) { IHitInfo hit; p.Info.System.Session.Physics.CastLongRay(p.Beam.From, p.Beam.To, out hit, false); if (hit?.HitEntity is MyVoxelBase) { voxelHit = hit.Position; } } else { using (voxel.Pin()) { if (!voxel.GetIntersectionWithLine(ref p.Beam, out voxelHit, true, IntersectionFlags.DIRECT_TRIANGLES) && VoxelIntersect.PointInsideVoxel(voxel, p.Info.System.Session.TmpStorage, p.Beam.From)) { voxelHit = p.Beam.From; } } } if (voxelHit.HasValue && p.Info.IsShrapnel && p.Info.Age == 0) { if (!VoxelIntersect.PointInsideVoxel(voxel, p.Info.System.Session.TmpStorage, voxelHit.Value + (p.Beam.Direction * 1.25f))) { voxelHit = null; } } } else if (branch == VoxelIntersectBranch.DeferedMissUpdate) { using (voxel.Pin()) { if (!voxel.GetIntersectionWithLine(ref p.Beam, out voxelHit, true, IntersectionFlags.DIRECT_TRIANGLES) && VoxelIntersect.PointInsideVoxel(voxel, p.Info.System.Session.TmpStorage, p.Beam.From)) { voxelHit = p.Beam.From; } } } if (!voxelHit.HasValue) { if (p.Info.VoxelCache.MissSphere.Contains(p.Beam.To) == ContainmentType.Disjoint) { p.Info.VoxelCache.MissSphere.Center = p.Beam.To; } continue; } p.Info.VoxelCache.Update(voxel, ref voxelHit, p.Info.System.Session.Tick); if (voxelHit == null) { continue; } if (!p.FinalizeIntersection) { p.FinalizeIntersection = true; FinalHitCheck.Add(p); } var hitEntity = HitEntityPool.Get(); var lineCheck = p.Info.ConsumableDef.Const.CollisionIsLine && !p.Info.EwarAreaPulse; hitEntity.Info = p.Info; hitEntity.Entity = voxel; hitEntity.Intersection = p.Beam; hitEntity.SphereCheck = !lineCheck; hitEntity.PruneSphere = p.PruneSphere; hitEntity.DamageOverTime = p.Info.ConsumableDef.Const.AreaEffect == DotField; var hitPos = voxelHit.Value; hitEntity.HitPos = hitPos; double dist; Vector3D.Distance(ref p.Beam.From, ref hitPos, out dist); hitEntity.HitDist = dist; hitEntity.EventType = Voxel; p.Info.HitList.Add(hitEntity); } DeferedVoxels.ClearImmediate(); }