ECS StunnableProjectile (#4309)
* ECS StunnableProjectile Also renamed it to the more generic component for stunning on collision * Reviews
This commit is contained in:
@@ -78,7 +78,7 @@ namespace Content.Client.Entry
|
|||||||
"SpeedLoader",
|
"SpeedLoader",
|
||||||
"Hitscan",
|
"Hitscan",
|
||||||
"ExplosiveProjectile",
|
"ExplosiveProjectile",
|
||||||
"StunnableProjectile",
|
"StunOnCollide",
|
||||||
"RandomPottedPlant",
|
"RandomPottedPlant",
|
||||||
"CommunicationsConsole",
|
"CommunicationsConsole",
|
||||||
"BarSign",
|
"BarSign",
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
|
||||||
|
namespace Content.Server.Stunnable.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Adds stun when it collides with an entity
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
internal sealed class StunOnCollideComponent : Component
|
||||||
|
{
|
||||||
|
// TODO: Can probably predict this.
|
||||||
|
public override string Name => "StunOnCollide";
|
||||||
|
|
||||||
|
// See stunnable for what these do
|
||||||
|
[DataField("stunAmount")]
|
||||||
|
internal int StunAmount = default;
|
||||||
|
[DataField("knockdownAmount")]
|
||||||
|
internal int KnockdownAmount = default;
|
||||||
|
[DataField("slowdownAmount")]
|
||||||
|
internal int SlowdownAmount = default;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using Content.Server.Projectiles.Components;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Physics.Collision;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
|
|
||||||
namespace Content.Server.Stunnable.Components
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Adds stun when it collides with an entity
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent]
|
|
||||||
public sealed class StunnableProjectileComponent : Component, IStartCollide
|
|
||||||
{
|
|
||||||
public override string Name => "StunnableProjectile";
|
|
||||||
|
|
||||||
// See stunnable for what these do
|
|
||||||
[DataField("stunAmount")]
|
|
||||||
private int _stunAmount = default;
|
|
||||||
[DataField("knockdownAmount")]
|
|
||||||
private int _knockdownAmount = default;
|
|
||||||
[DataField("slowdownAmount")]
|
|
||||||
private int _slowdownAmount = default;
|
|
||||||
|
|
||||||
protected override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
Owner.EnsureComponentWarn(out ProjectileComponent _);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
|
|
||||||
{
|
|
||||||
if (otherFixture.Body.Owner.TryGetComponent(out StunnableComponent? stunnableComponent))
|
|
||||||
{
|
|
||||||
stunnableComponent.Stun(_stunAmount);
|
|
||||||
stunnableComponent.Knockdown(_knockdownAmount);
|
|
||||||
stunnableComponent.Slowdown(_slowdownAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
27
Content.Server/Stunnable/StunOnCollideSystem.cs
Normal file
27
Content.Server/Stunnable/StunOnCollideSystem.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Content.Server.Stunnable.Components;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
|
||||||
|
namespace Content.Server.Stunnable
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
internal sealed class StunOnCollideSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<StunOnCollideComponent, StartCollideEvent>(HandleCollide);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCollide(EntityUid uid, StunOnCollideComponent component, StartCollideEvent args)
|
||||||
|
{
|
||||||
|
if (args.OtherFixture.Body.Owner.TryGetComponent(out StunnableComponent? stunnableComponent))
|
||||||
|
{
|
||||||
|
stunnableComponent.Stun(component.StunAmount);
|
||||||
|
stunnableComponent.Knockdown(component.KnockdownAmount);
|
||||||
|
stunnableComponent.Slowdown(component.SlowdownAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
- type: Projectile
|
- type: Projectile
|
||||||
damages:
|
damages:
|
||||||
Blunt: 10
|
Blunt: 10
|
||||||
- type: StunnableProjectile
|
- type: StunOnCollide
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PelletShotgun
|
id: PelletShotgun
|
||||||
|
|||||||
@@ -71,8 +71,9 @@
|
|||||||
soundHit: /Audio/Weapons/Guns/Hits/snap.ogg
|
soundHit: /Audio/Weapons/Guns/Hits/snap.ogg
|
||||||
damages:
|
damages:
|
||||||
Blunt: 3
|
Blunt: 3
|
||||||
- type: StunnableProjectile
|
- type: StunOnCollide
|
||||||
paralyzeAmount: 2
|
stunAmount: 2
|
||||||
|
knockdownAmount: 2
|
||||||
|
|
||||||
# Energy projectiles
|
# Energy projectiles
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
soundHitSpecies: "/Audio/Weapons/Guns/Hits/taser_hit.ogg"
|
soundHitSpecies: "/Audio/Weapons/Guns/Hits/taser_hit.ogg"
|
||||||
damages:
|
damages:
|
||||||
Heat: 5
|
Heat: 5
|
||||||
- type: StunnableProjectile
|
- type: StunOnCollide
|
||||||
stunAmount: 5
|
stunAmount: 5
|
||||||
knockdownAmount: 5
|
knockdownAmount: 5
|
||||||
|
|
||||||
@@ -175,8 +176,9 @@
|
|||||||
- type: Projectile
|
- type: Projectile
|
||||||
deleteOnCollide: false
|
deleteOnCollide: false
|
||||||
soundHit: /Audio/Effects/gen_hit.ogg
|
soundHit: /Audio/Effects/gen_hit.ogg
|
||||||
- type: StunnableProjectile
|
- type: StunOnCollide
|
||||||
paralyzeAmount: 8
|
stunAmount: 8
|
||||||
|
knockdownAmount: 8
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: BulletGrenadeBlast
|
id: BulletGrenadeBlast
|
||||||
|
|||||||
Reference in New Issue
Block a user