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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user