Skip to content

Commit

Permalink
Merge pull request #1613 from Darkmajia/bonfire-update
Browse files Browse the repository at this point in the history
bonfire building, lighting, and extinguishing
  • Loading branch information
mqole authored Feb 10, 2025
2 parents b7e4ad4 + 2d246da commit 08a43c4
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 18 deletions.
7 changes: 7 additions & 0 deletions Content.Server/Atmos/Components/FlammableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,12 @@ public sealed partial class FlammableComponent : Component

[DataField]
public ProtoId<AlertPrototype> FireAlert = "Fire";

// imp edit
/// <summary>
/// Should the entity enable an AmbientSound component when lit, and disable it when unlit?
/// </summary>
[DataField]
public bool ToggleAmbientSound;
}
}
28 changes: 26 additions & 2 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Server.Audio;
using Content.Server.IgnitionSource;
using Content.Server.Stunnable;
using Content.Server.Temperature.Components;
Expand All @@ -9,6 +10,7 @@
using Content.Shared.Alert;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
Expand All @@ -24,6 +26,7 @@
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.FixedPoint;
using Robust.Server.Audio;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
Expand All @@ -47,6 +50,7 @@ public sealed class FlammableSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly AmbientSoundSystem _ambient = default!;
[Dependency] private readonly IRobustRandom _random = default!;

private EntityQuery<InventoryComponent> _inventoryQuery;
Expand Down Expand Up @@ -137,6 +141,10 @@ private void OnMapInit(EntityUid uid, FlammableComponent component, MapInitEvent

_fixture.TryCreateFixture(uid, component.FlammableCollisionShape, component.FlammableFixtureID, hard: false,
collisionMask: (int) CollisionGroup.FullTileLayer, body: body);

// imp edit, disables AmbientSound if it's meant to be handled with a toggle
if (component.ToggleAmbientSound && TryComp<AmbientSoundComponent>(uid, out var ambient))
_ambient.SetAmbience(uid, false, ambient);
}

private void OnInteractUsing(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
Expand Down Expand Up @@ -211,8 +219,14 @@ private void OnCollide(EntityUid uid, FlammableComponent flammable, ref StartCol
var mass2 = 1f;
if (_physicsQuery.TryComp(uid, out var physics) && _physicsQuery.TryComp(otherUid, out var otherPhys))
{
mass1 = physics.Mass;
mass2 = otherPhys.Mass;
// imp edit - if either entity has a static BodyType then it has no mass, so just equalise instead
var anyStatic = physics.BodyType == BodyType.Static || otherPhys.BodyType == BodyType.Static;

if (!anyStatic)
{
mass1 = physics.Mass;
mass2 = otherPhys.Mass;
}
}

// when the thing on fire is more massive than the other, the following happens:
Expand Down Expand Up @@ -315,6 +329,10 @@ public void Extinguish(EntityUid uid, FlammableComponent? flammable = null)

_ignitionSourceSystem.SetIgnited(uid, false);

// imp edit
if (flammable.ToggleAmbientSound && TryComp<AmbientSoundComponent>(uid, out var ambient))
_ambient.SetAmbience(uid, false, ambient);

UpdateAppearance(uid, flammable);
}

Expand All @@ -338,6 +356,12 @@ public void Ignite(EntityUid uid, EntityUid ignitionSource, FlammableComponent?
flammable.OnFire = true;
}

// imp edit
if (flammable.ToggleAmbientSound &&
TryComp<AmbientSoundComponent>(uid, out var ambient) &&
!ambient.Enabled)
_ambient.SetAmbience(uid, true, ambient);

UpdateAppearance(uid, flammable);
}

Expand Down
102 changes: 88 additions & 14 deletions Resources/Prototypes/Entities/Structures/Decoration/bonfire.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,119 @@
# imp edit - base bonfire so legionnaire bonfire and other static bonfires can parent off this
- type: entity
id: Bonfire
id: BonfireBase
parent: BaseStructure
name: bonfire
description: What can be better than a late evening under the sky with guitar and friends?
abstract: true
components:
- type: Sprite
noRot: true
sprite: Structures/Decoration/bonfire.rsi
layers:
- state: bonfire
- state: burning
- type: PointLight
radius: 5
energy: 3
color: "#FFC90C"
- state: bonfire
- state: burning
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: Wood
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 50
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: AmbientSound
volume: -5
range: 5
sound:
path: /Audio/Ambience/Objects/fireplace.ogg

# imp edit - most of these components are new, with old ones rolled into BaseBonfire. and yet, we are still in an upstream file
- type: entity
id: Bonfire
parent: BonfireBase
name: bonfire
description: What can be better than a late evening under the sky with guitar and friends?
components:
- type: Sprite
layers:
- state: bonfire
- type: Appearance
- type: Fixtures
fixtures:
fix1:
shape:
!type:PhysShapeCircle
radius: 0.35
density: 130
mask:
- MachineMask
layer:
- MidImpassable
- LowImpassable
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 100
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
- trigger:
!type:DamageTrigger
damage: 50
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: AmbientSound
volume: -5
range: 5
sound:
path: /Audio/Ambience/Objects/fireplace.ogg
- type: AlwaysHot
- !type:PlaySoundBehavior
sound:
collection: WoodDestroy
- !type:SpawnEntitiesBehavior
spawn:
MaterialWoodPlank1:
min: 6
max: 10
- type: Reactive
groups:
Flammable: [ Touch ]
Extinguish: [ Touch ]
- type: Climbable
- type: Flammable
damage:
types:
Heat: 0 # adding any damage would make it break loudly into pieces, which feels weird
flammableCollisionShape:
!type:PhysShapeCircle
radius: 0.25
maximumFireStacks: 6
fireSpread: true
alwaysCombustible: true
firestacksOnIgnite: 2
firestackFade: 0.05 # gets hotter the longer it's on
toggleAmbientSound: true
- type: FireVisuals
sprite: Structures/Decoration/bonfire.rsi
normalState: burning
maxLightRadius: 8
maxLightEnergy: 5
- type: Construction
graph: Bonfire
node: bonfire

- type: entity
id: LegionnaireBonfire
parent: Bonfire
parent: BonfireBase
name: legionnaire bonfire
description: There, in the land of lava and ash, place to to cook marshmallow and potato.
components:
- type: Sprite
layers:
- state: legionnaire_bonfire
# imp edits
- type: PointLight
radius: 5
energy: 3
color: "#FF5601"
- type: AlwaysHot
# end imp edits
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- type: constructionGraph
id: Bonfire
start: start
graph:
- node: start
edges:
- to: bonfire
steps:
- material: WoodPlank
amount: 10
doAfter: 6
- node: bonfire
entity: Bonfire
actions:
- !type:SnapToGrid {}
edges:
- to: start
completed:
- !type:SpawnPrototype
prototype: MaterialWoodPlank1
amount: 10
- !type:DeleteEntity {}
steps:
- tool: Prying
doAfter: 3
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,21 @@
sprite: Structures/Windows/directional.rsi
state: uranium_reinforced_window
objectType: Structure
placementMode: SnapgridCenter
placementMode: SnapgridCenter

- type: construction
id: Bonfire
name: bonfire
description: What can be better than a late evening under the sky with guitar and friends?
graph: Bonfire
startNode: start
targetNode: bonfire
category: construction-category-structures
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: false
icon:
sprite: Structures/Decoration/bonfire.rsi
state: bonfire
conditions:
- !type:TileNotBlocked
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/Textures/Structures/Decoration/bonfire.rsi/burning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from /tg/station at commit 28b476ab6d17014e6f9e18a748d7c96be28de9a1",
"copyright": "Taken from /tg/station at commit 28b476ab6d17014e6f9e18a748d7c96be28de9a1, extinguished/burning edited by Darkmajia",
"size": {
"x": 32,
"y": 32
Expand Down

0 comments on commit 08a43c4

Please sign in to comment.