Fix collisions passing firestacks between mobs (#9324)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
|
using Robust.Shared.Physics.Collision.Shapes;
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Components
|
namespace Content.Server.Atmos.Components
|
||||||
{
|
{
|
||||||
@@ -28,5 +29,11 @@ namespace Content.Server.Atmos.Components
|
|||||||
[DataField("damage", required: true)]
|
[DataField("damage", required: true)]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public DamageSpecifier Damage = new(); // Empty by default, we don't want any funny NREs.
|
public DamageSpecifier Damage = new(); // Empty by default, we don't want any funny NREs.
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used for the fixture created to handle passing firestacks when two flammable objects collide.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("flammableCollisionShape")]
|
||||||
|
public IPhysShape FlammableCollisionShape = new PhysShapeCircle() { Radius = 0.35f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Content.Shared.Atmos;
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Temperature;
|
using Content.Shared.Temperature;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -32,6 +33,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||||
|
[Dependency] private readonly FixtureSystem _fixture = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
private const float MinimumFireStacks = -10f;
|
private const float MinimumFireStacks = -10f;
|
||||||
@@ -39,16 +41,17 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
private const float UpdateTime = 1f;
|
private const float UpdateTime = 1f;
|
||||||
|
|
||||||
private const float MinIgnitionTemperature = 373.15f;
|
private const float MinIgnitionTemperature = 373.15f;
|
||||||
|
public const string FlammableFixtureID = "flammable";
|
||||||
|
|
||||||
private float _timer = 0f;
|
private float _timer = 0f;
|
||||||
|
|
||||||
private Dictionary<FlammableComponent, float> _fireEvents = new();
|
private Dictionary<FlammableComponent, float> _fireEvents = new();
|
||||||
|
|
||||||
// TODO: Port the rest of Flammable.
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
UpdatesAfter.Add(typeof(AtmosphereSystem));
|
UpdatesAfter.Add(typeof(AtmosphereSystem));
|
||||||
|
|
||||||
|
SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit);
|
||||||
SubscribeLocalEvent<FlammableComponent, InteractUsingEvent>(OnInteractUsingEvent);
|
SubscribeLocalEvent<FlammableComponent, InteractUsingEvent>(OnInteractUsingEvent);
|
||||||
SubscribeLocalEvent<FlammableComponent, StartCollideEvent>(OnCollideEvent);
|
SubscribeLocalEvent<FlammableComponent, StartCollideEvent>(OnCollideEvent);
|
||||||
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHotEvent);
|
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHotEvent);
|
||||||
@@ -81,13 +84,30 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
Ignite(otherFixture, flammable);
|
Ignite(otherFixture, flammable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMapInit(EntityUid uid, FlammableComponent component, MapInitEvent args)
|
||||||
|
{
|
||||||
|
// Sets up a fixture for flammable collisions.
|
||||||
|
// TODO: Should this be generalized into a general non-hard 'effects' fixture or something? I can't think of other use cases for it.
|
||||||
|
// This doesn't seem great either (lots more collisions generated) but there isn't a better way to solve it either that I can think of.
|
||||||
|
|
||||||
|
if (!TryComp<PhysicsComponent>(uid, out var body))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_fixture.TryCreateFixture(body, new Fixture(body, component.FlammableCollisionShape)
|
||||||
|
{
|
||||||
|
Hard = false,
|
||||||
|
ID = FlammableFixtureID,
|
||||||
|
CollisionMask = (int) CollisionGroup.FullTileLayer
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void OnInteractUsingEvent(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
|
private void OnInteractUsingEvent(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var isHotEvent = new IsHotEvent();
|
var isHotEvent = new IsHotEvent();
|
||||||
RaiseLocalEvent(args.Used, isHotEvent, false);
|
RaiseLocalEvent(args.Used, isHotEvent);
|
||||||
|
|
||||||
if (!isHotEvent.IsHot)
|
if (!isHotEvent.IsHot)
|
||||||
return;
|
return;
|
||||||
@@ -99,6 +119,12 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
private void OnCollideEvent(EntityUid uid, FlammableComponent flammable, StartCollideEvent args)
|
private void OnCollideEvent(EntityUid uid, FlammableComponent flammable, StartCollideEvent args)
|
||||||
{
|
{
|
||||||
var otherUid = args.OtherFixture.Body.Owner;
|
var otherUid = args.OtherFixture.Body.Owner;
|
||||||
|
|
||||||
|
// Normal hard collisions, though this isn't generally possible since most flammable things are mobs
|
||||||
|
// which don't collide with one another, shouldn't work here.
|
||||||
|
if (args.OtherFixture.ID != FlammableFixtureID && args.OurFixture.ID != FlammableFixtureID)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(otherUid, out FlammableComponent? otherFlammable))
|
if (!EntityManager.TryGetComponent(otherUid, out FlammableComponent? otherFlammable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -119,7 +145,8 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
otherFlammable.FireStacks += flammable.FireStacks;
|
otherFlammable.FireStacks += flammable.FireStacks;
|
||||||
Ignite(otherUid, otherFlammable);
|
Ignite(otherUid, otherFlammable);
|
||||||
}
|
}
|
||||||
} else if (otherFlammable.OnFire)
|
}
|
||||||
|
else if (otherFlammable.OnFire)
|
||||||
{
|
{
|
||||||
otherFlammable.FireStacks /= 2;
|
otherFlammable.FireStacks /= 2;
|
||||||
flammable.FireStacks += otherFlammable.FireStacks;
|
flammable.FireStacks += otherFlammable.FireStacks;
|
||||||
|
|||||||
Reference in New Issue
Block a user