Fix issues with exploding items from own hand (#645)

* Fix crash in CameraRecoilComponent from NaN values

Doesn't proceed with camera shake if either component of recoil is NaN.

* Log NaN recoil value in CameraRecoilComponent

* Fix ExplosionHelper passing NaN recoil values when exploding from hand

With other commits CameraRecoilComponent now won't crash from NaN recoil values. Still want to fix this so explosions shake the camera. Just sets a value slightly greater than 0.0 for distance if it is (0.0, 0.0)
This commit is contained in:
moneyl
2020-02-08 14:46:12 -05:00
committed by GitHub
parent eb7c80ba7a
commit a2a3e5e2e4
2 changed files with 18 additions and 2 deletions

View File

@@ -1,9 +1,10 @@
using System;
using System;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Log;
using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Mobs
@@ -42,6 +43,12 @@ namespace Content.Client.GameObjects.Components.Mobs
public override void Kick(Vector2 recoil)
{
if (float.IsNaN(recoil.X) || float.IsNaN(recoil.Y))
{
Logger.Error($"CameraRecoilComponent on entity {Owner.Uid} passed a NaN recoil value. Ignoring.");
return;
}
// Use really bad math to "dampen" kicks when we're already kicked.
var existing = _currentKick.Length;
var dampen = existing/KickMagnitudeMax;