Add an effect that shows the item you're using to attack with when attacking
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
using Content.Client.GameObjects.Components.Mobs;
|
using System;
|
||||||
|
using Content.Client.GameObjects.Components.Mobs;
|
||||||
using Content.Client.GameObjects.Components.Weapons.Melee;
|
using Content.Client.GameObjects.Components.Weapons.Melee;
|
||||||
using Content.Shared.GameObjects.Components.Weapons.Melee;
|
using Content.Shared.GameObjects.Components.Weapons.Melee;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Interfaces.GameObjects.Components;
|
using Robust.Client.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
@@ -18,6 +22,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
public sealed class MeleeWeaponSystem : EntitySystem
|
public sealed class MeleeWeaponSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -53,6 +58,26 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
var weaponArcAnimation = entity.GetComponent<MeleeWeaponArcAnimationComponent>();
|
var weaponArcAnimation = entity.GetComponent<MeleeWeaponArcAnimationComponent>();
|
||||||
weaponArcAnimation.SetData(weaponArc, msg.Angle, attacker);
|
weaponArcAnimation.SetData(weaponArc, msg.Angle, attacker);
|
||||||
|
|
||||||
|
// Due to ISpriteComponent limitations, weapons that don't use an RSI won't have this effect.
|
||||||
|
if (EntityManager.TryGetEntity(msg.Source, out var source) && msg.TextureEffect && source.TryGetComponent(out ISpriteComponent sourceSprite)
|
||||||
|
&& sourceSprite.BaseRSI?.Path != null)
|
||||||
|
{
|
||||||
|
var sys = Get<EffectSystem>();
|
||||||
|
var curTime = _gameTiming.CurTime;
|
||||||
|
var effect = new EffectSystemMessage
|
||||||
|
{
|
||||||
|
EffectSprite = sourceSprite.BaseRSI.Path.ToString(),
|
||||||
|
RsiState = sourceSprite.LayerGetState(0).Name,
|
||||||
|
Coordinates = attacker.Transform.GridPosition,
|
||||||
|
Color = Vector4.Multiply(new Vector4(255, 255, 255, 125), 1.0f),
|
||||||
|
ColorDelta = Vector4.Multiply(new Vector4(0, 0, 0, -10), 1.0f),
|
||||||
|
Velocity = msg.Angle.ToVec(),
|
||||||
|
Acceleration = msg.Angle.ToVec() * 5f,
|
||||||
|
Born = curTime,
|
||||||
|
DeathTime = curTime.Add(TimeSpan.FromMilliseconds(300f)),
|
||||||
|
};
|
||||||
|
sys.CreateEffect(effect);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var uid in msg.Hits)
|
foreach (var uid in msg.Hits)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ using Robust.Shared.Serialization;
|
|||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||||
{
|
{
|
||||||
@@ -24,7 +26,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
public class MeleeWeaponComponent : Component, IAttack
|
public class MeleeWeaponComponent : Component, IAttack
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
|
||||||
[Dependency] private readonly IPhysicsManager _physicsManager = default!;
|
[Dependency] private readonly IPhysicsManager _physicsManager = default!;
|
||||||
|
|
||||||
public override string Name => "MeleeWeapon";
|
public override string Name => "MeleeWeapon";
|
||||||
@@ -54,6 +55,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public DamageType DamageType { get; set; }
|
public DamageType DamageType { get; set; }
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool ClickAttackEffect { get; set; }
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
@@ -68,6 +72,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
serializer.DataField(this, x => x.ArcCooldownTime, "arcCooldownTime", 1f);
|
serializer.DataField(this, x => x.ArcCooldownTime, "arcCooldownTime", 1f);
|
||||||
serializer.DataField(this, x => x.CooldownTime, "cooldownTime", 1f);
|
serializer.DataField(this, x => x.CooldownTime, "cooldownTime", 1f);
|
||||||
serializer.DataField(this, x => x.DamageType, "damageType", DamageType.Blunt);
|
serializer.DataField(this, x => x.DamageType, "damageType", DamageType.Blunt);
|
||||||
|
serializer.DataField(this, x => x.ClickAttackEffect, "clickAttackEffect", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool OnHitEntities(IReadOnlyList<IEntity> entities, AttackEventArgs eventArgs)
|
protected virtual bool OnHitEntities(IReadOnlyList<IEntity> entities, AttackEventArgs eventArgs)
|
||||||
@@ -117,8 +122,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
|
|
||||||
if (Arc != null)
|
if (Arc != null)
|
||||||
{
|
{
|
||||||
var sys = _entitySystemManager.GetEntitySystem<MeleeWeaponSystem>();
|
var sys = EntitySystem.Get<MeleeWeaponSystem>();
|
||||||
sys.SendAnimation(Arc, angle, eventArgs.User, hitEntities);
|
sys.SendAnimation(Arc, angle, eventArgs.User, Owner, hitEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastAttackTime = curTime;
|
_lastAttackTime = curTime;
|
||||||
@@ -170,8 +175,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
|
|
||||||
if (ClickArc != null)
|
if (ClickArc != null)
|
||||||
{
|
{
|
||||||
var sys = _entitySystemManager.GetEntitySystem<MeleeWeaponSystem>();
|
var sys = EntitySystem.Get<MeleeWeaponSystem>();
|
||||||
sys.SendAnimation(ClickArc, angle, eventArgs.User, targets);
|
sys.SendAnimation(ClickArc, angle, eventArgs.User, Owner, targets, ClickAttackEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastAttackTime = curTime;
|
_lastAttackTime = curTime;
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
public sealed class MeleeWeaponSystem : EntitySystem
|
public sealed class MeleeWeaponSystem : EntitySystem
|
||||||
{
|
{
|
||||||
public void SendAnimation(string arc, Angle angle, IEntity attacker, IEnumerable<IEntity> hits)
|
public void SendAnimation(string arc, Angle angle, IEntity attacker, IEntity source, IEnumerable<IEntity> hits, bool textureEffect = false)
|
||||||
{
|
{
|
||||||
RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponAnimationMessage(arc, angle, attacker.Uid,
|
RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponAnimationMessage(arc, angle, attacker.Uid, source.Uid,
|
||||||
hits.Select(e => e.Uid).ToList()));
|
hits.Select(e => e.Uid).ToList(), textureEffect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,18 +11,22 @@ namespace Content.Shared.GameObjects.EntitySystemMessages
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage
|
public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage
|
||||||
{
|
{
|
||||||
public PlayMeleeWeaponAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, List<EntityUid> hits)
|
public PlayMeleeWeaponAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, EntityUid source, List<EntityUid> hits, bool textureEffect = false)
|
||||||
{
|
{
|
||||||
ArcPrototype = arcPrototype;
|
ArcPrototype = arcPrototype;
|
||||||
Angle = angle;
|
Angle = angle;
|
||||||
Attacker = attacker;
|
Attacker = attacker;
|
||||||
|
Source = source;
|
||||||
Hits = hits;
|
Hits = hits;
|
||||||
|
TextureEffect = textureEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ArcPrototype { get; }
|
public string ArcPrototype { get; }
|
||||||
public Angle Angle { get; }
|
public Angle Angle { get; }
|
||||||
public EntityUid Attacker { get; }
|
public EntityUid Attacker { get; }
|
||||||
|
public EntityUid Source { get; }
|
||||||
public List<EntityUid> Hits { get; }
|
public List<EntityUid> Hits { get; }
|
||||||
|
public bool TextureEffect { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ namespace Content.Shared.Interfaces.GameObjects.Components
|
|||||||
public GridCoordinates ClickLocation { get; }
|
public GridCoordinates ClickLocation { get; }
|
||||||
public bool WideAttack { get; }
|
public bool WideAttack { get; }
|
||||||
public EntityUid Target { get; }
|
public EntityUid Target { get; }
|
||||||
public IEntity? TargetEntity => IoCManager.Resolve<IEntityManager>()?.GetEntity(Target) ?? null;
|
public IEntity? TargetEntity => Target.IsValid() ? IoCManager.Resolve<IEntityManager>()?.GetEntity(Target) ?? null : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user