internal void VoxelIntersect() { foreach (var item in VoxelsToIntersect) { var voxelBase = item.Key; var newVoxel = item.Value == 1; var stage1Check = false; if (item.Value > 1) { stage1Check = true; } else if (newVoxel) { var aabb = (BoundingBox)ShieldEnt.PositionComp.WorldAABB; aabb.Translate(-voxelBase.RootVoxel.PositionLeftBottomCorner); if (voxelBase.RootVoxel.Storage.Intersect(ref aabb, false) != ContainmentType.Disjoint) { stage1Check = true; } } if (!stage1Check) { int oldValue; VoxelsToIntersect.TryRemove(voxelBase, out oldValue); continue; } var collision = CustomCollision.VoxelEllipsoidCheck(MyGrid, ShieldComp.PhysicsOutsideLow, voxelBase); if (collision.HasValue) { ComputeVoxelPhysics(voxelBase, MyGrid, collision.Value); VoxelsToIntersect[voxelBase]++; if (_isServer) { var mass = MyGrid.GetCurrentMass(); var sPhysics = Shield.CubeGrid.Physics; var momentum = mass * sPhysics.GetVelocityAtPoint(collision.Value); var damage = (momentum.Length() / 500) * DsState.State.ModulateEnergy; var voxelEvent = Session.Instance.VoxelCollisionDmgPool.Get(); voxelEvent.Init(voxelBase, this, damage, collision.Value); Session.Instance.ThreadEvents.Enqueue(voxelEvent); } } else { VoxelsToIntersect[voxelBase] = 0; } } }
internal void VoxelIntersect() { foreach (var item in VoxelsToIntersect) { var voxelBase = item.Key; var newVoxel = item.Value == 1; var stage1Check = false; if (item.Value > 1) { stage1Check = true; } else if (newVoxel) { var aabb = (BoundingBox)ShieldEnt.PositionComp.WorldAABB; aabb.Translate(-voxelBase.RootVoxel.PositionLeftBottomCorner); if (voxelBase.RootVoxel.Storage.Intersect(ref aabb, false) != ContainmentType.Disjoint) { stage1Check = true; } } if (!stage1Check) { int oldValue; VoxelsToIntersect.TryRemove(voxelBase, out oldValue); continue; } var collision = CustomCollision.VoxelEllipsoidCheck(MyGrid, ShieldComp.PhysicsOutsideLow, voxelBase); if (collision.HasValue) { VoxelsToIntersect[voxelBase]++; if (_isServer) { var mass = MyGrid.GetCurrentMass(); var sPhysics = Shield.CubeGrid.Physics; var momentum = mass * sPhysics.LinearVelocity; Absorb += (momentum.Length() / 500) * DsState.State.ModulateEnergy; } ImpactSize = 12000; WorldImpactPosition = collision.Value; WebDamage = true; } else { VoxelsToIntersect[voxelBase] = 0; } } }