void ApplyDamage() { if (uLink.Network.isServer == false) { return; } // enumerate victims... Vector3 tmp; Vector3 pos = Position; int mask = ~(ObjectLayerMask.IgnoreRayCast | ObjectLayerMask.Ragdoll | ObjectLayerMask.Hat); Collider[] colliders = Physics.OverlapSphere(Position, damageRadius, mask); #if DEBUG DebugDraw.DepthTest = true; DebugDraw.DisplayTime = 8.0f; DebugDraw.Diamond(ColExp, 0.04f, pos); #endif // categorize victims... foreach (Collider c in colliders) { AgentHuman a = c.gameObject.GetFirstComponentUpward <AgentHuman>(); if (a == null) { m_Others.Add(c); } else if (m_Agents.Contains(a) == false) { m_Agents.Add(a); } } // process human-agents... foreach (AgentHuman a in m_Agents) { m_ObstacleNormalAccum = Vector3.zero; a.SampleDominantAnim(); if (ApplyDamage(a, pos, 1.0f) == false) { if ((m_ObstacleDamageReduction > 0.0f) && (m_ObstacleNormalAccum.sqrMagnitude > 0.0f)) { Vector3 u = Vector3.up; Vector3 v = Vector3.zero; Vector3 n = m_ObstacleNormalAccum; Vector3.OrthoNormalize(ref n, ref u, ref v); tmp = pos; tmp += 0.5f * n; // tmp += 1.0f * u; Vector3 diff = a.Position - pos; float dot = Vector3.Dot(diff, v); // if (Mathf.Abs(dot) > 0.3f) { tmp += 0.5f * Mathf.Sign(dot) * v; } #if DEBUG DebugDraw.LineOriented(ColExp, pos, tmp, 0.04f); #endif ApplyDamage(a, tmp, m_ObstacleDamageReduction); } } } // process other objects... foreach (Collider c in m_Others) { ApplyDamage(c, pos); } // clean-up... m_Agents.Clear(); m_Others.Clear(); }