private void ProcessServerHit(RaycastHit2D hit, int penetration, DamageModel model) { if (model == null) { return; } if (model.ColliderPartMap.ContainsKey(hit.collider)) { var part = model.ColliderPartMap[hit.collider]; if (part == null) { return; } // Deal damage to that part! switch (Data.DamageType) { case ProjectileDamageType.NORMAL: // Deal damage to only the hit part. part.Damage(damage); break; case ProjectileDamageType.EXPLOSIVE: // Do an explosion style damage that will harm parts around the inital hit point. // Does not spawn explosion effect or anything like that. model.DealExplosionDamage(damage, part.ID, Data.ExplosionCollateralDamage); break; default: Debug.LogError("Unhandled type of projectile damage!! ({0})".Form(Data.DamageType)); break; } if (ServerHit != null) { ServerHit.Invoke(hit, penetration, model); } } else { // Hit a collider that was part of a damage model, but the collider was not mapped. // This counted as a penetration hit, but it didn't deal damage. :( Debug.LogWarning("Unmapped collider on damage model '{0}'. Collider name: '{1}'. Hit with projectile, but could not deal damage. Please consider making unmapped colliders triggers so that they are not hit.".Form(model.name, hit.collider.name)); return; } }