public void OnHitVehicle(PlayerEntity srcPlayer, VehicleEntity targetVehicle, IBulletEntity bulletEntity, RaycastHit hit) { if (srcPlayer.gamePlay.IsDead()) { return; } Collider collider = hit.collider; VehiclePartIndex partIndex; var hitBoxFactor = VehicleEntityUtility.GetHitFactor(targetVehicle, collider, out partIndex); var totalDamage = GetBulletDamage(bulletEntity, hitBoxFactor, Vector3.Distance(hit.point, bulletEntity.GunEmitPosition)); var gameData = targetVehicle.GetGameData(); gameData.DecreaseHp(partIndex, totalDamage, srcPlayer.entityKey.Value); srcPlayer.statisticsData.Statistics.TotalDamage += totalDamage; bulletEntity.IsValid = false; srcPlayer.statisticsData.Statistics.ShootingSuccCount++; _logger.DebugFormat("bullet from {0} hit vehicle {1}, part {2}", bulletEntity.OwnerEntityKey, targetVehicle.entityKey.Value, collider.name); ClientEffectFactory.AddHitVehicleEffectEvent(srcPlayer, targetVehicle.entityKey.Value, hit.point, hit.point - targetVehicle.position.Value, hit.normal); }
public void OnHitVehicle(Contexts contexts, PlayerEntity src, VehicleEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { VehiclePartIndex partIndex; var baseDamage = GetVehicleFactor(hit, target, out partIndex) * GetBaseDamage(attackInfo, config); var gameData = target.GetGameData(); gameData.DecreaseHp(partIndex, baseDamage); if (!src.WeaponController().IsHeldSlotEmpty) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AddHitVehicleEffectEvent(src, target.entityKey.Value, effectHit.point, effectHit.point - target.position.Value, effectHit.normal); } } }