Shitty combat mode & animations. (#367)

* Combat mode UI & targeting zones.

* Fix inventory hud positioning.

* Crappy attack animations.

* Import TG combat sounds

* More work on arcs.

* Implement hit sounds.

* Lunging, hit effects, some more stuff.
This commit is contained in:
Pieter-Jan Briers
2019-09-26 22:32:32 +02:00
committed by GitHub
parent ac55ccf46e
commit 02d509fc5f
47 changed files with 1231 additions and 35 deletions

View File

@@ -29,6 +29,10 @@ namespace Content.Client.GameObjects.Components.Mobs
private EyeComponent _eye;
// Basically I needed a way to chain this effect for the attack lunge animation.
// Sorry!
public Vector2 BaseOffset { get; set; }
public override void Initialize()
{
base.Initialize();
@@ -95,7 +99,7 @@ namespace Content.Client.GameObjects.Components.Mobs
private void _updateEye()
{
_eye.Offset = _currentKick;
_eye.Offset = BaseOffset + _currentKick;
}
}
}

View File

@@ -0,0 +1,59 @@
using Content.Client.UserInterface;
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.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
public sealed class CombatModeComponent : SharedCombatModeComponent
{
[ViewVariables(VVAccess.ReadWrite)]
public bool IsInCombatMode { get; private set; }
[ViewVariables(VVAccess.ReadWrite)]
public TargetingZone ActiveZone { get; private set; }
#pragma warning disable 649
[Dependency] private readonly IGameHud _gameHud;
#pragma warning restore 649
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
base.HandleComponentState(curState, nextState);
var state = (CombatModeComponentState) curState;
IsInCombatMode = state.IsInCombatMode;
ActiveZone = state.TargetingZone;
UpdateHud();
}
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
{
base.HandleMessage(message, netChannel, component);
switch (message)
{
case PlayerAttachedMsg _:
_gameHud.CombatPanelVisible = true;
UpdateHud();
break;
case PlayerDetachedMsg _:
_gameHud.CombatPanelVisible = false;
break;
}
}
private void UpdateHud()
{
_gameHud.CombatModeActive = IsInCombatMode;
_gameHud.TargetingZone = ActiveZone;
}
}
}

View File

@@ -0,0 +1,65 @@
using Robust.Client.GameObjects;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
public sealed class MeleeLungeComponent : Component
{
public override string Name => "MeleeLunge";
private const float ResetTime = 0.3f;
private const float BaseOffset = 0.25f;
private Angle _angle;
private float _time;
public void SetData(Angle angle)
{
_angle = angle;
_time = 0;
}
public void Update(float frameTime)
{
_time += frameTime;
var offset = Vector2.Zero;
var deleteSelf = false;
if (_time > ResetTime)
{
deleteSelf = true;
}
else
{
offset = _angle.RotateVec((BaseOffset, 0));
offset *= (ResetTime - _time) / ResetTime;
}
if (Owner.TryGetComponent(out CameraRecoilComponent recoilComponent))
{
recoilComponent.BaseOffset = offset;
}
else if (Owner.TryGetComponent(out EyeComponent eyeComponent))
{
eyeComponent.Offset = offset;
}
if (Owner.TryGetComponent(out ISpriteComponent spriteComponent))
{
// We have to account for rotation so the offset still checks out.
// SpriteComponent.Offset is applied before transform rotation (as expected).
var worldRotation = Owner.Transform.WorldRotation;
spriteComponent.Offset = new Angle(-worldRotation).RotateVec(offset);
}
if (deleteSelf)
{
Owner.RemoveComponent<MeleeLungeComponent>();
}
}
}
}