/// <summary> /// Checks if any of the registered sabers are clashing. /// </summary> /// <param name="clashingPoint">The point that the sabers are clashing at.</param> /// <returns>Are any sabers clashing?</returns> public override bool AreSabersClashing(out Vector3 clashingPoint) { if (!MultiSaberMode) { return(base.AreSabersClashing(out clashingPoint)); } _sabers.RemoveWhere(x => x == null); if (_leftSaber.movementData.lastAddedData.time < 0.1f) { clashingPoint = _clashingPoint; return(false); } if (_prevGetFrameNum == Time.frameCount) { clashingPoint = _clashingPoint; return(_sabersAreClashing); } _prevGetFrameNum = Time.frameCount; for (int i = 0; i < _sabers.Count; i++) { for (int h = 0; h < _sabers.Count; h++) { if (i > h) { Saber saberA = _sabers.ElementAt(i); Saber saberB = _sabers.ElementAt(h); if (saberA == saberB || saberA == null || saberB == null) { break; } Vector3 saberBladeTopPos = saberA.saberBladeTopPos; Vector3 saberBladeTopPos2 = saberB.saberBladeTopPos; Vector3 saberBladeBottomPos = saberA.saberBladeBottomPos; Vector3 saberBladeBottomPos2 = saberB.saberBladeBottomPos; if (SegmentToSegmentDist(saberBladeBottomPos, saberBladeTopPos, saberBladeBottomPos2, saberBladeTopPos2, out var clashingPoint2) < 0.08f && saberA.isActiveAndEnabled && saberB.isActiveAndEnabled) { if (_lastSaberA == null && _lastSaberB == null) { _lastSaberA = saberA; _lastSaberB = saberB; // pseudo-lock dep var clashEffect = _container.Resolve <SaberClashEffect>(); var glowPS = GlowParticles(ref clashEffect).main; var sparkPS = SparkleParticles(ref clashEffect).main; sparkPS.startColor = glowPS.startColor = Color.Lerp(_lastSaberA.GetColor(), _lastSaberB.GetColor(), 0.5f); } _clashingPoint = clashingPoint2; clashingPoint = _clashingPoint; _sabersAreClashing = true; return(_sabersAreClashing); } else { _lastSaberA = null; _lastSaberB = null; _sabersAreClashing = false; } } } } clashingPoint = _clashingPoint; return(_sabersAreClashing); }