diff --git a/Content.Server/IgnitionSource/IgnitionSourceComponent.cs b/Content.Server/IgnitionSource/IgnitionSourceComponent.cs new file mode 100644 index 0000000000..2251013cbe --- /dev/null +++ b/Content.Server/IgnitionSource/IgnitionSourceComponent.cs @@ -0,0 +1,15 @@ +namespace Content.Server.IgnitionSource; + +/// +/// This is used for... +/// +[RegisterComponent] +[Access(typeof(IgnitionSourceSystem))] +public sealed class IgnitionSourceComponent : Component +{ + [DataField("ignited")] + public bool Ignited = false; + + [DataField("temperature", required: true)] + public int Temperature; +} diff --git a/Content.Server/IgnitionSource/IgnitionSourceSystem.cs b/Content.Server/IgnitionSource/IgnitionSourceSystem.cs new file mode 100644 index 0000000000..19e28038c4 --- /dev/null +++ b/Content.Server/IgnitionSource/IgnitionSourceSystem.cs @@ -0,0 +1,53 @@ +using Content.Server.Atmos.EntitySystems; +using Content.Shared.Temperature; +using Robust.Server.GameObjects; + +namespace Content.Server.IgnitionSource; + +/// +/// This handles ignition, Jez basically coded this. +/// +/// +public sealed class IgnitionSourceSystem : EntitySystem +{ + /// + /// + [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; + [Dependency] private readonly TransformSystem _transformSystem = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnIsHot); + } + + private void OnIsHot(EntityUid uid, IgnitionSourceComponent component, IsHotEvent args) + { + Logger.Debug(args.IsHot.ToString()); + SetIgnited(uid,component,args.IsHot); + } + + private void SetIgnited(EntityUid uid, IgnitionSourceComponent component, bool newState) + { + component.Ignited = newState; + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + + foreach (var (component,transform) in EntityQuery()) + { + var source = component.Owner; + if (!component.Ignited) + continue; + + if (transform.GridUid is { } gridUid) + { + var position = _transformSystem.GetGridOrMapTilePosition(source, transform); + _atmosphereSystem.HotspotExpose(gridUid, position, component.Temperature, 50, true); + } + } + + } +} diff --git a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs index 9a2bf1194b..809fa0710d 100644 --- a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs +++ b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Light.Component; using Content.Shared.Tag; +using Content.Shared.Temperature; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -120,6 +121,8 @@ namespace Content.Server.Light.EntitySystems case ExpendableLightState.Dead: appearance.SetData(ExpendableLightVisuals.Behavior, string.Empty); + var isHotEvent = new IsHotEvent() {IsHot = true}; + RaiseLocalEvent(component.Owner, isHotEvent); break; } } @@ -160,7 +163,8 @@ namespace Content.Server.Light.EntitySystems private void OnExpLightUse(EntityUid uid, ExpendableLightComponent component, UseInHandEvent args) { if (args.Handled) return; - + var isHotEvent = new IsHotEvent() {IsHot = true}; + RaiseLocalEvent(uid, isHotEvent); if (TryActivate(component)) args.Handled = true; } diff --git a/Content.Server/Tools/ToolSystem.Welder.cs b/Content.Server/Tools/ToolSystem.Welder.cs index 8166164a85..ebd0d6d763 100644 --- a/Content.Server/Tools/ToolSystem.Welder.cs +++ b/Content.Server/Tools/ToolSystem.Welder.cs @@ -148,6 +148,9 @@ namespace Content.Server.Tools var ev = new WelderToggledEvent(false); RaiseLocalEvent(welder.Owner, ev, false); + var hotEvent = new IsHotEvent() {IsHot = false}; + RaiseLocalEvent(uid, hotEvent); + // Layer 1 is the flame. _appearanceSystem.SetData(uid, WelderVisuals.Lit, false); _appearanceSystem.SetData(uid, ToggleableLightVisuals.Enabled, false); @@ -204,6 +207,8 @@ namespace Content.Server.Tools private void OnWelderActivate(EntityUid uid, WelderComponent welder, ActivateInWorldEvent args) { args.Handled = TryToggleWelder(uid, args.User, welder); + var hotEvent = new IsHotEvent() {IsHot = true}; + RaiseLocalEvent(uid, hotEvent); } private void OnWelderAfterInteract(EntityUid uid, WelderComponent welder, AfterInteractEvent args) @@ -313,6 +318,7 @@ namespace Content.Server.Tools if (_welderTimer < WelderUpdateTimer) return; + // TODO Use an "active welder" component instead, EntityQuery over that. foreach (var tool in _activeWelders.ToArray()) { @@ -324,12 +330,6 @@ namespace Content.Server.Tools if (!_solutionContainerSystem.TryGetSolution(tool, welder.FuelSolution, out var solution, solutionContainer)) continue; - if (transform.GridUid is { } gridUid) - { - var position = _transformSystem.GetGridOrMapTilePosition(tool, transform); - _atmosphereSystem.HotspotExpose(gridUid, position, 700, 50, true); - } - solution.RemoveReagent(welder.FuelReagent, welder.FuelConsumption * _welderTimer); if (solution.GetReagentQuantity(welder.FuelReagent) <= FixedPoint2.Zero) diff --git a/Resources/Prototypes/Entities/Objects/Misc/torch.yml b/Resources/Prototypes/Entities/Objects/Misc/torch.yml index 89e253f543..5faaf1b2ae 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/torch.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/torch.yml @@ -42,6 +42,9 @@ radius: 1.0 energy: 5.0 netsync: false + - type: IgnitionSource + temperature: 400 + ignited: false - type: LightBehaviour behaviours: - !type:RandomizeBehaviour # immediately make it bright and flickery diff --git a/Resources/Prototypes/Entities/Objects/Tools/flare.yml b/Resources/Prototypes/Entities/Objects/Tools/flare.yml index aabf0f406c..71261cc8a9 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/flare.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/flare.yml @@ -47,6 +47,8 @@ radius: 1.0 energy: 9.0 netsync: false + - type: IgnitionSource + temperature: 1000 - type: LightBehaviour behaviours: - !type:RandomizeBehaviour # immediately make it bright and flickery diff --git a/Resources/Prototypes/Entities/Objects/Tools/welders.yml b/Resources/Prototypes/Entities/Objects/Tools/welders.yml index c0a15dbf30..f08bbb8f91 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/welders.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/welders.yml @@ -62,6 +62,8 @@ - type: RequiresEyeProtection - type: StaticPrice price: 40 + - type: IgnitionSource + temperature: 700 - type: entity name: industrial welding tool