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 2 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,24 @@
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 the temperature of the surrounding air will change in Kelvin per tick
/// Positive means it will only heat, negative means it will only cool
/// </summary>
[DataField]
public float TemperatureChangePerTick = 1f;
}
40 changes: 40 additions & 0 deletions Content.Server/Temperature/Systems/RadiantTemperatureSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Server.Atmos.EntitySystems;
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 Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<RadiantTemperatureComponent, TransformComponent>();
while (query.MoveNext(out var ent, out var comp, out var xform))
{
var grid = xform.GridUid;
var map = xform.MapUid;
var indices = _xform.GetGridTilePositionOrDefault((ent, xform));
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);

if (mixture is null)
continue;

// 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 > comp.GoalTemperature && comp.TemperatureChangePerTick > 0)
continue;

// 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 < comp.GoalTemperature && comp.TemperatureChangePerTick < 0)
continue;

mixture.Temperature += comp.TemperatureChangePerTick * frameTime;
Plykiya marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
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 @@ -43,6 +43,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,11 @@
sound:
path: /Audio/Ambience/Objects/fireplace.ogg
- type: AlwaysHot
- type: IgnitionSource
ignited: true
- type: RadiantTemperature
goalTemperature: 305
temperatureChangePerTick: 30

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