From c2a201d998830b36fa525c5ee9bb1375bf41d732 Mon Sep 17 00:00:00 2001 From: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com> Date: Thu, 19 Sep 2024 03:23:50 +0300 Subject: [PATCH] Make fire leave burnt decals on the tiles (#31939) * Make fire leave burnt decals on the tiles * License * Yes * Update * Spelling error * Prototypes reload support * To array --- .../EntitySystems/AtmosphereSystem.Hotspot.cs | 33 +++++++++++++++--- .../Atmos/EntitySystems/AtmosphereSystem.cs | 19 ++++++++++ Resources/Prototypes/Decals/burnt.yml | 31 ++++++++++++++++ .../Textures/Decals/burnt.rsi/burnt1.png | Bin 0 -> 896 bytes .../Textures/Decals/burnt.rsi/burnt2.png | Bin 0 -> 938 bytes .../Textures/Decals/burnt.rsi/burnt3.png | Bin 0 -> 928 bytes .../Textures/Decals/burnt.rsi/burnt4.png | Bin 0 -> 1041 bytes Resources/Textures/Decals/burnt.rsi/meta.json | 27 ++++++++++++++ 8 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 Resources/Prototypes/Decals/burnt.yml create mode 100644 Resources/Textures/Decals/burnt.rsi/burnt1.png create mode 100644 Resources/Textures/Decals/burnt.rsi/burnt2.png create mode 100644 Resources/Textures/Decals/burnt.rsi/burnt3.png create mode 100644 Resources/Textures/Decals/burnt.rsi/burnt4.png create mode 100644 Resources/Textures/Decals/burnt.rsi/meta.json diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs index db95223733..a03f27b561 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs @@ -1,19 +1,21 @@ using Content.Server.Atmos.Components; -using Content.Server.Atmos.Reactions; +using Content.Server.Decals; using Content.Shared.Atmos; using Content.Shared.Atmos.Components; using Content.Shared.Atmos.Reactions; -using Content.Shared.Audio; using Content.Shared.Database; using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Player; +using Robust.Shared.Random; namespace Content.Server.Atmos.EntitySystems { public sealed partial class AtmosphereSystem { + [Dependency] private readonly DecalSystem _decalSystem = default!; + [Dependency] private readonly IRobustRandom _random = default!; + private const int HotspotSoundCooldownCycles = 200; private int _hotspotSoundCooldown = 0; @@ -56,7 +58,30 @@ namespace Content.Server.Atmos.EntitySystems if (tile.Hotspot.Bypassing) { tile.Hotspot.State = 3; - // TODO ATMOS: Burn tile here + + var gridUid = ent.Owner; + var tilePos = tile.GridIndices; + + // Get the existing decals on the tile + var tileDecals = _decalSystem.GetDecalsInRange(gridUid, tilePos); + + // Count the burnt decals on the tile + var tileBurntDecals = 0; + + foreach (var set in tileDecals) + { + if (Array.IndexOf(_burntDecals, set.Decal.Id) == -1) + continue; + + tileBurntDecals++; + + if (tileBurntDecals > 4) + break; + } + + // Add a random burned decal to the tile only if there are less than 4 of them + if (tileBurntDecals < 4) + _decalSystem.TryAddDecal(_burntDecals[_random.Next(_burntDecals.Length)], new EntityCoordinates(gridUid, tilePos), out _, cleanable: true); if (tile.Air.Temperature > Atmospherics.FireMinimumTemperatureToSpread) { diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs index 44bfa4cc10..13d8f73dc5 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Body.Systems; using Content.Server.Fluids.EntitySystems; using Content.Server.NodeContainer.EntitySystems; using Content.Shared.Atmos.EntitySystems; +using Content.Shared.Decals; using Content.Shared.Doors.Components; using Content.Shared.Maps; using JetBrains.Annotations; @@ -12,7 +13,9 @@ using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Physics.Systems; +using Robust.Shared.Prototypes; using Robust.Shared.Random; +using System.Linq; namespace Content.Server.Atmos.EntitySystems; @@ -36,6 +39,7 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly TileSystem _tile = default!; [Dependency] private readonly MapSystem _map = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] public readonly PuddleSystem Puddle = default!; private const float ExposedUpdateDelay = 1f; @@ -47,6 +51,8 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem private EntityQuery _firelockQuery; private HashSet _entSet = new(); + private string[] _burntDecals = []; + public override void Initialize() { base.Initialize(); @@ -66,7 +72,9 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem _firelockQuery = GetEntityQuery(); SubscribeLocalEvent(OnTileChanged); + SubscribeLocalEvent(OnPrototypesReloaded); + CacheDecals(); } public override void Shutdown() @@ -81,6 +89,12 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem InvalidateTile(ev.NewTile.GridUid, ev.NewTile.GridIndices); } + private void OnPrototypesReloaded(PrototypesReloadedEventArgs ev) + { + if (ev.WasModified()) + CacheDecals(); + } + public override void Update(float frameTime) { base.Update(frameTime); @@ -107,4 +121,9 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem _exposedTimer -= ExposedUpdateDelay; } + + private void CacheDecals() + { + _burntDecals = _prototypeManager.EnumeratePrototypes().Where(x => x.Tags.Contains("burnt")).Select(x => x.ID).ToArray(); + } } diff --git a/Resources/Prototypes/Decals/burnt.yml b/Resources/Prototypes/Decals/burnt.yml new file mode 100644 index 0000000000..d9d500e1aa --- /dev/null +++ b/Resources/Prototypes/Decals/burnt.yml @@ -0,0 +1,31 @@ +- type: decal + id: burnt1 + tags: ["burnt"] + defaultCleanable: true + sprite: + sprite: Decals/burnt.rsi + state: burnt1 + +- type: decal + id: burnt2 + tags: ["burnt"] + defaultCleanable: true + sprite: + sprite: Decals/burnt.rsi + state: burnt2 + +- type: decal + id: burnt3 + tags: ["burnt"] + defaultCleanable: true + sprite: + sprite: Decals/burnt.rsi + state: burnt3 + +- type: decal + id: burnt4 + tags: ["burnt"] + defaultCleanable: true + sprite: + sprite: Decals/burnt.rsi + state: burnt4 diff --git a/Resources/Textures/Decals/burnt.rsi/burnt1.png b/Resources/Textures/Decals/burnt.rsi/burnt1.png new file mode 100644 index 0000000000000000000000000000000000000000..3fcb7a4949b5bd561e68d784d47d9de20a5411d2 GIT binary patch literal 896 zcmV-`1AqL9P)_`sikSPhHe~3@fwDqi`!27YaPdN z#XAQ{Mbb&qIqVecW=VHRx3Ec4r4L^n0fb{a_q`;oVHMzdNk>T+Sc&%@lCF||0?2Ft z@TYMc*YYNKA9lck1x~sM{t=mf#{D6J5x9NYmwnV>7*yT_FA<=R=W95g?Z)O zXSr#2Y=Ql?;o%@8o6DVb-DIUOt;rA7Zqkdr_f#YackO{-WHbkhbz#xIZKXZvnvEm5 zqy=1*J0rIo$w#m!1hcO>t!)7E3@{KcA~AFJ1mfTv&z_QJ?G^KYLr)tTSp~V56pmai zijU>lBbsI)jXMU>N%|82%xnYVQR|G~sBqFV0d4O6tE9hS-})Wbk4UT*l<1YPa0dME z%4dp2&wEZnHs9=N?ya7z8ydklV$1s3jzCLe6r|b5_i)Oi)aKYqGeBI^ZuBez`a(2a-$50Ok=tVpxs0ZTk;p WW37K`!OrIZ0000C literal 0 HcmV?d00001 diff --git a/Resources/Textures/Decals/burnt.rsi/burnt2.png b/Resources/Textures/Decals/burnt.rsi/burnt2.png new file mode 100644 index 0000000000000000000000000000000000000000..01f8f220b2ddae1a13fac2b816531109a5b848d9 GIT binary patch literal 938 zcmV;b16BNqP)18A2vnpw(ar z1~qsht;3vCD6w`Ao}uGYnUsA1aPJrnOd)6t3!DMiI$6ER(;`s9#u7N6pd4cTwdf`G z2_S*!hJ`)wbZg_0F*v6MHg>;GCHx+Tzwt=JH}-T(U;23XN71bm6J#p9IFTkcm5gqK z^tAwduWz%!Cu7Bw`%{PCis#BPcvk^T9Mi6`N4!4&RvUe%3k*DgXzsb>EVX7P2z~>G z2Krrr1)9=8G5B6W`vj{g4YsN1zcPIW zV5X|>9a}N0^|cQ3pfrEhjEwHJG@W?V`+P6qA}w&JCyhP*2=lg}bc01jVF^I8;Vi)i z$25J`1XEDr2dgllPFL=UA+3cqy1hLF*B(=5xn)$H0500m$U z0e2oTkWELyx%aGmdnf@ivuFkGjjv`jofKps$SYI+o{QLmWYm8K086<%#GyXvdo6YO3$m!Aax?qf)&Kwi M07*qoM6N<$f@T`Jp8x;= literal 0 HcmV?d00001 diff --git a/Resources/Textures/Decals/burnt.rsi/burnt3.png b/Resources/Textures/Decals/burnt.rsi/burnt3.png new file mode 100644 index 0000000000000000000000000000000000000000..e9dcbe37533f6e1aa9f17dca58d5c2b15973408a GIT binary patch literal 928 zcmV;R17G}!P)a;W5Jit{9MAGY^Z#EoHA`ZHfq9@0+$c_ss#F3Yb>H5b2K)d9;0(;b2;6I(YfiwU zR-b2J0b1Sv3Va8?0W0tZ+=|v(^sm5|IuEc8z_0pnEn*Eg)rHngikQ=J>b^JNQUKjM z124sV@V=U@}kW6B%Z?YOXZZ67&`UX#a^V zgRKSR6c-ac9NCPJ)+sP}?|AZ=OUQfLXypjSnJtYb^FAr12DEu*x(wYpR<-;Fy!M$X z52e%uQ@veg?pTLhLe{bD$dvbOccIXcG>9sFVDbZAW`p^r92HlsY)$oI$1Dm>^mDco)UP^r= zL+Z-M(9I&I26LR!R#}p>toG$s2_8XIFDGbZO=)!|&3&SZk+GSTFg37rL_af6-vjic z595{^=*`gg1HNabOX;%Sr-W)pb9q;Pne_ox{7lkJJQ?RL?wAwc2x0GCII8SaXXUwA zh|&jo5Hh~96&b6gen5aShX_!KrDrZs^V{%1UMzI3){{b2u`{;`kj?~;+p#!H6W9Q($&N#+@YmG_~VwO}MVq9HEt4ibR! zhh*Y?R!gSl{1)dNci=DZ8~9Uv+L^73v7BmCYqohITkDjrUwzIW5+(lw{H*!6G_W@$ zHWYejpJ=k8`QHCOJc`y>tLoMXe;4Cdwq9TXUb2K5Mw&zu=pPS`GTPfadjU^`5@AN8LXHrEQ@sW!o?S0000>5u66hM z4m^NiHO3eX*Z_Or0K5TPU{`Y+mg`cwewV(X0aFctb1gUnw^Fnz1$haG6`-ls3TRhj zTWcO=&?oQ*m|9r)0Oqp#TJM`0+fp{iP&x4|kXCy(F~*WRg|4yHm7O$Z3@hZC3%Q7b1Bh-dPs1$Qf@v`@_y9w&{#5aS4fRjqi1w0A)j?W*E(IU2gdNo z9N$d7p$suMngBj(^BcWn-b(pC1mEZxK88gPUSprtVEGXMrT{QD;1|8_{{_AmfH!*V z9dig8R{->c-pl3Y{#o_0o=P(3&A0uY&rB&Y*RmE;*Pk8zpt(CK!dC-Q9t-uZ#*1$#Q# zs9XRl_pag=_br{6ZoGQw63>Rr!|sEk;zL-tKE)=HtaD)P_Uwv=$Pjo*@23L$0)Vhy z04mMrG43W-@<$#%bt*m^j@A9H?@Bob9$)( zcjIm5%Yuhml7uSvU*J%ik1Ql~q4#|OWM7xEbH9mg zc=V!P9)U|X7FkdrQz<{vf5mjU9`M~HvpasHv#E72-S5h)6L9_u9x#X3!t};m00000 LNkvXXu0mjfo00E? literal 0 HcmV?d00001 diff --git a/Resources/Textures/Decals/burnt.rsi/meta.json b/Resources/Textures/Decals/burnt.rsi/meta.json new file mode 100644 index 0000000000..48a8f33138 --- /dev/null +++ b/Resources/Textures/Decals/burnt.rsi/meta.json @@ -0,0 +1,27 @@ +{ + "version": 1, + "size": { + "x": 32, + "y": 32 + }, + "license": "CC-BY-SA-3.0", + "copyright": "From https://github.com/BeeStation/BeeStation-Hornet/blob/master/icons/turf/turf_damage.dmi at f2d6fbdf36aa0951049498cf28e028a38e32fe0b", + "states": [ + { + "name": "burnt1" + + }, + { + "name": "burnt2" + + }, + { + "name": "burnt3" + + }, + { + "name": "burnt4" + + } + ] +} -- 2.52.0