private void Shoot(int spreadFactor) { var weaponFired = WeaponFired.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered); weaponFired.WeaponId = weapon.Id; weaponFired.Entity = weapon.Player; weaponFired.Send(); var weaponSound = WeaponSound.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable); weaponSound.Position = transform.position; weaponSound.Label = weapon.Label; weaponSound.Player = player.entity; weaponSound.Send(); var dir = Spread(spreadFactor); if (!Physics.Raycast(cameraTransform.transform.position, dir, out var hit, 100)) { return; } if (hit.transform.CompareTag("Stalin")) { AudioSource soundSource = hit.transform.GetComponent <AudioSource>(); if (!soundSource.isPlaying) { soundSource.Play(); } } var boltEntity = hit.transform.GetComponent <BoltEntity>(); if (boltEntity != null && boltEntity.GetState <IPlayer>() != null) { var playerHit = PlayerHit.Create(GlobalTargets.OnlyServer); playerHit.Target = boltEntity; playerHit.PlayerWhoShot = player.state.Username; playerHit.WeaponName = weapon.Label; playerHit.Damage = weapon.Damage; playerHit.Send(); var applyHitIndicator = ApplyHitIndicator.Create(ReliabilityModes.Unreliable); applyHitIndicator.Message = "Damage: " + weapon.Damage; applyHitIndicator.Position = hit.point; applyHitIndicator.Send(); } else { var impactEffect = ImpactEffect.Create(ReliabilityModes.Unreliable); impactEffect.Position = hit.point; impactEffect.Send(); } }