Bullet impact effects (#9530)

This commit is contained in:
metalgearsloth
2022-07-09 13:46:11 +10:00
committed by GitHub
parent 1b5f88e4d0
commit 5107bc3be7
14 changed files with 175 additions and 85 deletions

View File

@@ -1,13 +1,17 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Projectiles
{
[NetworkedComponent()]
[NetworkedComponent, Access(typeof(SharedProjectileSystem))]
public abstract class SharedProjectileComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("impactEffect", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? ImpactEffect;
private bool _ignoreShooter = true;
public EntityUid Shooter { get; protected set; }
public EntityUid Shooter { get; set; }
public bool IgnoreShooter
{
@@ -20,18 +24,5 @@ namespace Content.Shared.Projectiles
Dirty();
}
}
[NetSerializable, Serializable]
protected sealed class ProjectileComponentState : ComponentState
{
public ProjectileComponentState(EntityUid shooter, bool ignoreShooter)
{
Shooter = shooter;
IgnoreShooter = ignoreShooter;
}
public EntityUid Shooter { get; }
public bool IgnoreShooter { get; }
}
}
}

View File

@@ -1,4 +1,6 @@
using Robust.Shared.Map;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization;
namespace Content.Shared.Projectiles
{
@@ -20,5 +22,39 @@ namespace Content.Shared.Projectiles
return;
}
}
public void SetShooter(SharedProjectileComponent component, EntityUid uid)
{
if (component.Shooter == uid) return;
component.Shooter = uid;
Dirty(component);
}
[NetSerializable, Serializable]
protected sealed class ProjectileComponentState : ComponentState
{
public ProjectileComponentState(EntityUid shooter, bool ignoreShooter)
{
Shooter = shooter;
IgnoreShooter = ignoreShooter;
}
public EntityUid Shooter { get; }
public bool IgnoreShooter { get; }
}
[Serializable, NetSerializable]
protected sealed class ImpactEffectEvent : EntityEventArgs
{
public string Prototype;
public EntityCoordinates Coordinates;
public ImpactEffectEvent(string prototype, EntityCoordinates coordinates)
{
Prototype = prototype;
Coordinates = coordinates;
}
}
}
}

View File

@@ -8,6 +8,7 @@ using Content.Shared.Examine;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Projectiles;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Components;
@@ -43,7 +44,8 @@ public abstract partial class SharedGunSystem : EntitySystem
[Dependency] protected readonly SharedPhysicsSystem Physics = default!;
[Dependency] protected readonly SharedPopupSystem PopupSystem = default!;
[Dependency] protected readonly ThrowingSystem ThrowingSystem = default!;
[Dependency] protected readonly TagSystem _tagSystem = default!;
[Dependency] protected readonly TagSystem TagSystem = default!;
[Dependency] protected readonly SharedProjectileSystem Projectiles = default!;
protected ISawmill Sawmill = default!;
@@ -88,7 +90,7 @@ public abstract partial class SharedGunSystem : EntitySystem
private void OnGunMeleeAttempt(EntityUid uid, GunComponent component, ref MeleeAttackAttemptEvent args)
{
if (_tagSystem.HasTag(args.User, "GunsDisabled"))
if (TagSystem.HasTag(args.User, "GunsDisabled"))
return;
args.Cancelled = true;
@@ -186,7 +188,7 @@ public abstract partial class SharedGunSystem : EntitySystem
if (toCoordinates == null) return;
if (_tagSystem.HasTag(user, "GunsDisabled"))
if (TagSystem.HasTag(user, "GunsDisabled"))
{
Popup(Loc.GetString("gun-disabled"), user, user);
return;