Flare gun 1984 (#15807)

This commit is contained in:
metalgearsloth
2023-05-04 12:46:02 +10:00
committed by GitHub
parent 6408e69fe7
commit 06efff2b2d
4 changed files with 82 additions and 40 deletions

View File

@@ -1,9 +1,16 @@
namespace Content.Server.Atmos.Components using Content.Server.Atmos.EntitySystems;
namespace Content.Server.Atmos.Components;
[RegisterComponent, Access(typeof(FlammableSystem))]
public sealed class IgniteOnCollideComponent : Component
{ {
[RegisterComponent] /// <summary>
public sealed class IgniteOnCollideComponent : Component /// How many more times the ignition can be applied.
{ /// </summary>
[DataField("fireStacks")] [ViewVariables(VVAccess.ReadWrite), DataField("count")]
public float FireStacks { get; set; } public int Count = 1;
}
[ViewVariables(VVAccess.ReadWrite), DataField("fireStacks")]
public float FireStacks;
} }

View File

@@ -13,6 +13,7 @@ using Content.Shared.Physics;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Rejuvenate; using Content.Shared.Rejuvenate;
using Content.Shared.Temperature; using Content.Shared.Temperature;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Events; using Content.Shared.Weapons.Melee.Events;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Physics; using Robust.Shared.Physics;
@@ -58,7 +59,10 @@ namespace Content.Server.Atmos.EntitySystems
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHot); SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHot);
SubscribeLocalEvent<FlammableComponent, TileFireEvent>(OnTileFire); SubscribeLocalEvent<FlammableComponent, TileFireEvent>(OnTileFire);
SubscribeLocalEvent<FlammableComponent, RejuvenateEvent>(OnRejuvenate); SubscribeLocalEvent<FlammableComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<IgniteOnCollideComponent, StartCollideEvent>(IgniteOnCollide); SubscribeLocalEvent<IgniteOnCollideComponent, StartCollideEvent>(IgniteOnCollide);
SubscribeLocalEvent<IgniteOnCollideComponent, LandEvent>(OnIgniteLand);
SubscribeLocalEvent<IgniteOnMeleeHitComponent, MeleeHitEvent>(OnMeleeHit); SubscribeLocalEvent<IgniteOnMeleeHitComponent, MeleeHitEvent>(OnMeleeHit);
} }
@@ -74,15 +78,27 @@ namespace Content.Server.Atmos.EntitySystems
} }
} }
private void OnIgniteLand(EntityUid uid, IgniteOnCollideComponent component, ref LandEvent args)
{
RemCompDeferred<IgniteOnCollideComponent>(uid);
}
private void IgniteOnCollide(EntityUid uid, IgniteOnCollideComponent component, ref StartCollideEvent args) private void IgniteOnCollide(EntityUid uid, IgniteOnCollideComponent component, ref StartCollideEvent args)
{ {
var otherFixture = args.OtherFixture.Body.Owner; if (!args.OtherFixture.Hard || component.Count == 0)
return;
if (!EntityManager.TryGetComponent(otherFixture, out FlammableComponent? flammable)) var otherEnt = args.OtherEntity;
if (!EntityManager.TryGetComponent(otherEnt, out FlammableComponent? flammable))
return; return;
flammable.FireStacks += component.FireStacks; flammable.FireStacks += component.FireStacks;
Ignite(otherFixture, flammable); Ignite(otherEnt, flammable);
component.Count--;
if (component.Count == 0)
RemCompDeferred<IgniteOnCollideComponent>(uid);
} }
private void OnMapInit(EntityUid uid, FlammableComponent component, MapInitEvent args) private void OnMapInit(EntityUid uid, FlammableComponent component, MapInitEvent args)

View File

@@ -116,17 +116,9 @@ public sealed partial class GunSystem : SharedGunSystem
foreach (var (ent, shootable) in ammo) foreach (var (ent, shootable) in ammo)
{ {
// pneumatic cannon doesn't shoot bullets it just throws them, ignore ammo handling // pneumatic cannon doesn't shoot bullets it just throws them, ignore ammo handling
if (throwItems) if (throwItems && ent != null)
{ {
if (!HasComp<ProjectileComponent>(ent!.Value)) ShootOrThrow(ent.Value, mapDirection, gunVelocity, gun, user);
{
RemComp<AmmoComponent>(ent.Value);
// TODO: Someone can probably yeet this a billion miles so need to pre-validate input somewhere up the call stack.
ThrowingSystem.TryThrow(ent.Value, mapDirection, gun.ProjectileSpeed, user);
continue;
}
ShootProjectile(ent.Value, mapDirection, gunVelocity, user, gun.ProjectileSpeed);
continue; continue;
} }
@@ -144,14 +136,14 @@ public sealed partial class GunSystem : SharedGunSystem
for (var i = 0; i < cartridge.Count; i++) for (var i = 0; i < cartridge.Count; i++)
{ {
var uid = Spawn(cartridge.Prototype, fromEnt); var uid = Spawn(cartridge.Prototype, fromEnt);
ShootProjectile(uid, angles[i].ToVec(), gunVelocity, user, gun.ProjectileSpeed); ShootOrThrow(uid, angles[i].ToVec(), gunVelocity, gun, user);
shotProjectiles.Add(uid); shotProjectiles.Add(uid);
} }
} }
else else
{ {
var uid = Spawn(cartridge.Prototype, fromEnt); var uid = Spawn(cartridge.Prototype, fromEnt);
ShootProjectile(uid, mapDirection, gunVelocity, user, gun.ProjectileSpeed); ShootOrThrow(uid, mapDirection, gunVelocity, gun, user);
shotProjectiles.Add(uid); shotProjectiles.Add(uid);
} }
@@ -183,17 +175,7 @@ public sealed partial class GunSystem : SharedGunSystem
shotProjectiles.Add(ent!.Value); shotProjectiles.Add(ent!.Value);
MuzzleFlash(gunUid, newAmmo, user); MuzzleFlash(gunUid, newAmmo, user);
Audio.PlayPredicted(gun.SoundGunshot, gunUid, user); Audio.PlayPredicted(gun.SoundGunshot, gunUid, user);
ShootOrThrow(ent.Value, mapDirection, gunVelocity, gun, user);
// Do a throw
if (!HasComp<ProjectileComponent>(ent.Value))
{
RemComp<AmmoComponent>(ent.Value);
// TODO: Someone can probably yeet this a billion miles so need to pre-validate input somewhere up the call stack.
ThrowingSystem.TryThrow(ent.Value, mapDirection, gun.ProjectileSpeed, user);
break;
}
ShootProjectile(ent.Value, mapDirection, gunVelocity, user, gun.ProjectileSpeed);
break; break;
case HitscanPrototype hitscan: case HitscanPrototype hitscan:
@@ -283,6 +265,20 @@ public sealed partial class GunSystem : SharedGunSystem
}); });
} }
private void ShootOrThrow(EntityUid uid, Vector2 mapDirection, Vector2 gunVelocity, GunComponent gun, EntityUid? user)
{
// Do a throw
if (!HasComp<ProjectileComponent>(uid))
{
RemComp<AmmoComponent>(uid);
// TODO: Someone can probably yeet this a billion miles so need to pre-validate input somewhere up the call stack.
ThrowingSystem.TryThrow(uid, mapDirection, gun.ProjectileSpeed, user);
return;
}
ShootProjectile(uid, mapDirection, gunVelocity, user, gun.ProjectileSpeed);
}
public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid? user = null, float speed = 20f) public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid? user = null, float speed = 20f)
{ {
var physics = EnsureComp<PhysicsComponent>(uid); var physics = EnsureComp<PhysicsComponent>(uid);

View File

@@ -108,19 +108,42 @@
id: PelletShotgunFlare id: PelletShotgunFlare
name: pellet (.50 flare) name: pellet (.50 flare)
noSpawn: true noSpawn: true
parent: BaseBullet
components: components:
- type: CollisionWake
- type: TileFrictionModifier
modifier: 0.5
- type: Physics
bodyType: Dynamic
fixedRotation: false
- type: Fixtures
fixtures:
- shape:
!type:PhysShapeAabb
bounds: "-0.25,-0.25,0.25,0.25"
density: 20
mask:
- ItemMask
restitution: 0.3
friction: 0.2
- type: Sprite - type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
state: buckshot-flare state: buckshot-flare
- type: Projectile - type: IgnitionSource
damage: temperature: 1000
groups: - type: TimedDespawn
Burn: 14 lifetime: 240
- type: AmbientSound
enabled: true
volume: 0
range: 7
sound:
path: /Audio/Items/Flare/flare_burn.ogg
params:
loop: true
- type: IgniteOnCollide
fireStacks: 1
- type: PointLight - type: PointLight
enabled: true enabled: true
color: "#FF8080" color: "#FF8080"
radius: 15.0 radius: 15.0
energy: 9.0 energy: 9.0
- type: IgniteOnCollide
fireStacks: 4