From 93a34186cc56ed72320bb86998492ede07445ada Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 28 May 2019 13:33:42 +0200 Subject: [PATCH] Make the camera kick when hit by a bullet. --- .../Projectiles/ProjectileComponent.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs index 0b1b6730b4..eb21642190 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs @@ -1,11 +1,10 @@ -using Robust.Shared.GameObjects; +using System.Collections.Generic; +using Robust.Server.GameObjects; +using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.GameObjects.Components; -using System; -using System.Collections.Generic; -using YamlDotNet.RepresentationModel; -using Robust.Shared.Utility; +using Content.Server.GameObjects.Components.Mobs; using Content.Shared.GameObjects; namespace Content.Server.GameObjects.Components.Projectiles @@ -47,16 +46,25 @@ namespace Content.Server.GameObjects.Components.Projectiles /// void ICollideBehavior.CollideWith(List collidedwith) { - foreach(var entity in collidedwith) + foreach (var entity in collidedwith) { - if(entity.TryGetComponent(out DamageableComponent damage)) + if (entity.TryGetComponent(out DamageableComponent damage)) { damage.TakeDamage(DamageType.Brute, 10); } + + if (entity.TryGetComponent(out CameraRecoilComponent recoilComponent) + && Owner.TryGetComponent(out PhysicsComponent physicsComponent)) + { + var direction = physicsComponent.LinearVelocity.Normalized; + recoilComponent.Kick(direction); + } } if (collidedwith.Count > 0) + { Owner.Delete(); + } } } }