void OnTriggerEnter(Collider other) { //delay timer is still going and we can't damage in delay time + make sure that no damage has been applied or damaging multiple times is enabled if (isActive == false || effectObjComp.CurrentState != EffectObj.State.running || delayTimer > 0.0f && damageInDelay == false && (didDamage == false || damageOnce == false)) { return; } if (RTSHelper.IsInLayerMask(obstacleLayerMask, other.gameObject.layer)) //Check if this is an obstacle that stops the attack object. { ApplyDamage(other.gameObject, null, transform.position); return; } SelectionEntity hitSelection = other.gameObject.GetComponent <SelectionEntity>(); //if the attack object didn't enter in collision with a selection entity or it did but it was one belonging to resource if (hitSelection == null || hitSelection.FactionEntity == null) { return; } //make sure the faction entity belongs to an enemy faction and that it's not dead yet: if ((hitSelection.FactionEntity.FactionID != sourceFactionID || damageFriendly) && hitSelection.FactionEntity.EntityHealthComp.IsDead() == false) { ApplyDamage(other.gameObject, hitSelection.FactionEntity, hitSelection.transform.position); } }