Fixes CameraRecoil runtime (#2662)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
using System;
|
#nullable enable
|
||||||
|
using System;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.ComponentDependencies;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
@@ -28,19 +30,13 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
private Vector2 _currentKick;
|
private Vector2 _currentKick;
|
||||||
private float _lastKickTime;
|
private float _lastKickTime;
|
||||||
|
|
||||||
private EyeComponent _eye;
|
[ComponentDependency]
|
||||||
|
private readonly EyeComponent? _eye;
|
||||||
|
|
||||||
// Basically I needed a way to chain this effect for the attack lunge animation.
|
// Basically I needed a way to chain this effect for the attack lunge animation.
|
||||||
// Sorry!
|
// Sorry!
|
||||||
public Vector2 BaseOffset { get; set; }
|
public Vector2 BaseOffset { get; set; }
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
_eye = Owner.GetComponent<EyeComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Kick(Vector2 recoil)
|
public override void Kick(Vector2 recoil)
|
||||||
{
|
{
|
||||||
if (float.IsNaN(recoil.X) || float.IsNaN(recoil.Y))
|
if (float.IsNaN(recoil.X) || float.IsNaN(recoil.Y))
|
||||||
@@ -62,7 +58,7 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
_updateEye();
|
_updateEye();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession session = null)
|
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null)
|
||||||
{
|
{
|
||||||
base.HandleNetworkMessage(message, channel, session);
|
base.HandleNetworkMessage(message, channel, session);
|
||||||
|
|
||||||
@@ -107,7 +103,7 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
|
|
||||||
private void _updateEye()
|
private void _updateEye()
|
||||||
{
|
{
|
||||||
_eye.Offset = BaseOffset + _currentKick;
|
if (_eye != null) _eye.Offset = BaseOffset + _currentKick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user