void CheckInTrigger(Vector3 emitter) { Collider[] colls = Physics.OverlapSphere(transform.position, 0.1f, GameConfig.ProjectileDamageLayer); for (int i = 0; i < colls.Length; ++i) { Collider hitCol = colls[i]; if (hitCol.transform == null) { continue; } if (hitCol.transform.IsChildOf(transform)) { continue; } if (m_Caster != null && hitCol.transform.IsChildOf(m_Caster)) { continue; } if (hitCol.gameObject.tag == "EnergyShield") { EnergySheildHandler shield = hitCol.GetComponent <EnergySheildHandler>(); if (shield != null) { shield.Impact(emitter); } continue; } PEDefenceTrigger defencetrigger = hitCol.transform.GetComponent <PEDefenceTrigger>(); if (null != defencetrigger) { PECapsuleHitResult hitResult; if (!defencetrigger.GetClosest(emitter, (TriggerBounds.size / 2f).magnitude, out hitResult)) { continue; } Hit(hitResult.hitPos, -hitResult.hitDir, hitResult.hitTrans); if (!m_Trigger) { m_Valid = false; } } else if (!hitCol.isTrigger) { Hit(emitter, Vector3.Normalize(emitter - hitCol.transform.position), hitCol.transform); if (!m_Trigger) { m_Valid = false; } } return; } }
PECapsuleHitResult GetHitResult(Transform self, Collider other) { PECapsuleHitResult hitResult = null; PEDefenceTrigger defencetrigger = other.transform.GetComponent <PEDefenceTrigger>(); if (null == m_SelfCollider) { m_SelfCollider = GetComponentInChildren <Collider>(); } if (null != defencetrigger && (null == m_SelfCollider || !(m_SelfCollider is MeshCollider))) { float size = (TriggerBounds.size / 2f).magnitude; if (size <= Mathf.Epsilon) { size = 0.1f; } if (!defencetrigger.active || !defencetrigger.GetClosest(self.position, (TriggerBounds.size / 2f).magnitude, out hitResult)) { return(null); } } else { hitResult = new PECapsuleHitResult(); hitResult.hitTrans = other.transform; hitResult.selfTrans = self; hitResult.hitPos = other.ClosestPointOnBounds(self.position); Vector3 dir = hitResult.hitPos - self.position; if (dir == Vector3.zero) { dir = other.transform.position - self.position; } hitResult.distance = dir.magnitude; hitResult.hitDir = dir.normalized; SkEntity skEntity = other.transform.GetComponentInParent <SkEntity>(); if (null != skEntity) { if (skEntity is VFVoxelTerrain) { hitResult.hitDefenceType = DefenceType.Carrier; } else if (skEntity is WhiteCat.CreationSkEntity) { hitResult.hitDefenceType = DefenceType.Carrier; } } hitResult.damageScale = 1f; } hitResult.selfAttackForm = AttackForm.Bullet; return(hitResult); }