Fire extinguishers can now extinguish items, including when held/worn (#36267)
* Fire extinguishers now put out candles This did not actually require any changes to flammable or extinguishers directly, the only necessary changes were to make the collision actually work. Vapor entities (also used for fire extinguishers) now have a collision layer, so they can hit items. Added a new FlammableSetCollisionWake component to actually enable collision on candles while they are lit, because otherwise CollisionWake on entities gets in the way too. * Extinguishing items is now relayed to held/worn items This means held candles get extinguished too. Involved moving the core logic of ExtinguishReaction into an event so that it can be relayed via the existing hand/inventory relay logic. * Add helper functions for subscribing to relayed events. Use these in FlammableSystem * Make extinguishers work on cigarettes too A bunch of renaming to make the rest of my code work with SmokableComponent --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
d0b4f4744c
commit
843d79be5f
@@ -17,6 +17,7 @@ using Content.Shared.Temperature;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using System.Linq;
|
||||
using Content.Shared.Atmos;
|
||||
|
||||
namespace Content.Server.Nutrition.EntitySystems
|
||||
{
|
||||
@@ -48,12 +49,19 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
SubscribeLocalEvent<SmokableComponent, IsHotEvent>(OnSmokableIsHotEvent);
|
||||
SubscribeLocalEvent<SmokableComponent, ComponentShutdown>(OnSmokableShutdownEvent);
|
||||
SubscribeLocalEvent<SmokableComponent, GotEquippedEvent>(OnSmokeableEquipEvent);
|
||||
Subs.SubscribeWithRelay<SmokableComponent, ExtinguishEvent>(OnExtinguishEvent);
|
||||
|
||||
InitializeCigars();
|
||||
InitializePipes();
|
||||
InitializeVapes();
|
||||
}
|
||||
|
||||
private void OnExtinguishEvent(Entity<SmokableComponent> ent, ref ExtinguishEvent args)
|
||||
{
|
||||
if (ent.Comp.State == SmokableState.Lit)
|
||||
SetSmokableState(ent, SmokableState.Burnt, ent);
|
||||
}
|
||||
|
||||
public void SetSmokableState(EntityUid uid, SmokableState state, SmokableComponent? smokable = null,
|
||||
AppearanceComponent? appearance = null, ClothingComponent? clothing = null)
|
||||
{
|
||||
@@ -74,9 +82,19 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
_items.SetHeldPrefix(uid, newState);
|
||||
|
||||
if (state == SmokableState.Lit)
|
||||
{
|
||||
var igniteEvent = new IgnitedEvent();
|
||||
RaiseLocalEvent(uid, ref igniteEvent);
|
||||
|
||||
_active.Add(uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
var igniteEvent = new ExtinguishedEvent();
|
||||
RaiseLocalEvent(uid, ref igniteEvent);
|
||||
|
||||
_active.Remove(uid);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSmokableIsHotEvent(Entity<SmokableComponent> entity, ref IsHotEvent args)
|
||||
|
||||
Reference in New Issue
Block a user