Better click attack effect

This commit is contained in:
Víctor Aguilera Puerto
2020-08-31 19:32:06 +02:00
parent 69bd44c94c
commit b927fddf4c
4 changed files with 17 additions and 55 deletions

View File

@@ -21,8 +21,7 @@ namespace Content.Client.GameObjects.EntitySystems
public override void Initialize()
{
SubscribeNetworkEvent<PlayMeleeWeaponArcAnimationMessage>(PlayWeaponArc);
SubscribeNetworkEvent<PlayMeleeWeaponAnimationMessage>(PlayWeapon);
SubscribeNetworkEvent<PlayMeleeWeaponAnimationMessage>(PlayWeaponArc);
}
public override void FrameUpdate(float frameTime)
@@ -35,7 +34,7 @@ namespace Content.Client.GameObjects.EntitySystems
}
}
private void PlayWeaponArc(PlayMeleeWeaponArcAnimationMessage msg)
private void PlayWeaponArc(PlayMeleeWeaponAnimationMessage msg)
{
if (!_prototypeManager.TryIndex(msg.ArcPrototype, out MeleeWeaponAnimationPrototype weaponArc))
{
@@ -81,32 +80,5 @@ namespace Content.Client.GameObjects.EntitySystems
});
}
}
private void PlayWeapon(PlayMeleeWeaponAnimationMessage msg)
{
var attacker = EntityManager.GetEntity(msg.Attacker);
var lunge = attacker.EnsureComponent<MeleeLungeComponent>();
lunge.SetData(msg.Angle);
if (!EntityManager.TryGetEntity(msg.Hit, out var hitEntity)
|| !hitEntity.TryGetComponent(out ISpriteComponent sprite))
{
return;
}
var originalColor = sprite.Color;
var newColor = Color.Red * originalColor;
sprite.Color = newColor;
Timer.Spawn(100, () =>
{
// Only reset back to the original color if something else didn't change the color in the mean time.
if (sprite.Color == newColor)
{
sprite.Color = originalColor;
}
});
}
}
}