Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fireplaces are warm, books are burnable, burn papers with fireplaces #32087

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Content.Client/Paper/UI/PaperVisualizerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Tag;
using Robust.Client.GameObjects;

using static Content.Shared.Paper.PaperComponent;
Expand All @@ -6,9 +7,11 @@ namespace Content.Client.Paper.UI;

public sealed class PaperVisualizerSystem : VisualizerSystem<PaperVisualsComponent>
{
[Dependency] private readonly TagSystem _tagSystem = default!;

protected override void OnAppearanceChange(EntityUid uid, PaperVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
if (args.Sprite == null || _tagSystem.HasTag(uid, "Book"))
return;

if (AppearanceSystem.TryGetData<PaperStatus>(uid, PaperVisuals.Status , out var writingStatus, args.Component))
Expand Down
20 changes: 20 additions & 0 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public override void Initialize()
_physicsQuery = GetEntityQuery<PhysicsComponent>();

SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<FlammableComponent, AfterInteractEvent>(OnInteract);
SubscribeLocalEvent<FlammableComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<FlammableComponent, StartCollideEvent>(OnCollide);
SubscribeLocalEvent<FlammableComponent, IsHotEvent>(OnIsHot);
Expand Down Expand Up @@ -139,6 +140,25 @@ private void OnMapInit(EntityUid uid, FlammableComponent component, MapInitEvent
collisionMask: (int) CollisionGroup.FullTileLayer, body: body);
}

/// <summary>
/// Using something flammable on something that's hot (fireplace, e-sword, lighter) will ignite the item
/// Example: burning paper by using it on a fireplace
/// </summary>
private void OnInteract(Entity<FlammableComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled || args.Target == null)
return;

var isHotEvent = new IsHotEvent();
RaiseLocalEvent(args.Target.Value, isHotEvent);

if (!isHotEvent.IsHot)
return;

Ignite(entity, args.Used, entity.Comp, args.User);
args.Handled = true;
}

private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
{
if (args.Handled)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.Atmos;

namespace Content.Server.Temperature.Components;

/// <summary>
/// The entity will cause the surrounding air temperature to change passively without
/// any need for power or anything else.
/// </summary>
[RegisterComponent]
public sealed partial class RadiantTemperatureComponent : Component
{
/// <summary>
/// The temperature that the entity will try to reach
/// </summary>
[DataField]
public float GoalTemperature = Atmospherics.T20C;

/// <summary>
/// How much energy (in joules) to add to or remove from the surrounding air per second
/// </summary>
[DataField]
public float EnergyChangedPerSecond = 1f;
}
58 changes: 58 additions & 0 deletions Content.Server/Temperature/Systems/RadiantTemperatureSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Temperature.Components;
using Robust.Server.GameObjects;

namespace Content.Server.Temperature.Systems;

public sealed class RadiantTemperatureSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _xform = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RadiantTemperatureComponent, AtmosDeviceUpdateEvent>(OnAtmosUpdate);
}

private void OnAtmosUpdate(Entity<RadiantTemperatureComponent> entity, ref AtmosDeviceUpdateEvent args)
{
var entXform = Transform(entity);
var grid = entXform.GridUid;
var map = entXform.MapUid;
var indices = _xform.GetGridTilePositionOrDefault((entity, entXform));
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);

if (mixture is null)
return;

// do not continue heating if air is hotter than goal temperature,
// and the entity is a radiant HEAT source (positive temp changes)
if (mixture.Temperature > entity.Comp.GoalTemperature && entity.Comp.EnergyChangedPerSecond > 0)
return;

// do not continue cooling if air is colder than goal temperature
// and the entity is a radiant COOLING source (negative temp changes)
if (mixture.Temperature < entity.Comp.GoalTemperature && entity.Comp.EnergyChangedPerSecond < 0)
return;

var dQ = entity.Comp.EnergyChangedPerSecond * args.dt;

// Clamps the heat transferred to not overshoot
// This is just taken straight from GasThermoMachineSystem.cs
var Cin = _atmosphere.GetHeatCapacity(mixture, true);
var dT = entity.Comp.GoalTemperature - mixture.Temperature;
var dQLim = dT * Cin;
var scale = 1f;
if (Math.Abs(dQ) > Math.Abs(dQLim))
{
scale = dQLim / dQ;
}

var dQActual = dQ * scale;
_atmosphere.AddHeat(mixture, dQActual);

}
}
27 changes: 27 additions & 0 deletions Resources/Prototypes/Entities/Objects/Misc/books.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@
damage:
types:
Blunt: 1
- type: Flammable
fireSpread: true
canResistFire: false
alwaysCombustible: true
canExtinguish: true # save the books!
damage:
types:
Heat: 1
- type: Appearance
- type: FireVisuals
sprite: Effects/fire.rsi
normalState: fire
- type: Damageable
damageModifierSet: Wood
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 40 # sure does take a lot longer to burn a book than a piece of paper
behaviors:
- !type:SpawnEntitiesBehavior
spawn:
Ash:
min: 1
max: 1
- !type:DoActsBehavior
acts: [ "Destruction" ]

- type: entity
parent: BaseItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
sound:
path: /Audio/Ambience/Objects/fireplace.ogg
- type: AlwaysHot
- type: IgnitionSource
ignited: true
- type: AtmosDevice
- type: RadiantTemperature
goalTemperature: 305
energyChangedPerSecond: 2500

- type: entity
id: LegionnaireBonfire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: AlwaysHot
- type: IgnitionSource
ignited: true
- type: AtmosDevice
- type: RadiantTemperature
goalTemperature: 305
energyChangedPerSecond: 2500
Loading