IgnitionSourceComponent added (#13555)

Co-authored-by: Jezithyr <6192499+Jezithyr@users.noreply.github.com>
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
gus
2023-01-18 00:45:54 -08:00
committed by GitHub
parent df81da7041
commit 76498fcc54
7 changed files with 86 additions and 7 deletions

View File

@@ -0,0 +1,15 @@
namespace Content.Server.IgnitionSource;
/// <summary>
/// This is used for...
/// </summary>
[RegisterComponent]
[Access(typeof(IgnitionSourceSystem))]
public sealed class IgnitionSourceComponent : Component
{
[DataField("ignited")]
public bool Ignited = false;
[DataField("temperature", required: true)]
public int Temperature;
}

View File

@@ -0,0 +1,53 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
namespace Content.Server.IgnitionSource;
/// <summary>
/// This handles ignition, Jez basically coded this.
/// </summary>
///
public sealed class IgnitionSourceSystem : EntitySystem
{
/// <inheritdoc/>
///
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IgnitionSourceComponent,IsHotEvent>(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<IgnitionSourceComponent,TransformComponent>())
{
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);
}
}
}
}

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -62,6 +62,8 @@
- type: RequiresEyeProtection
- type: StaticPrice
price: 40
- type: IgnitionSource
temperature: 700
- type: entity
name: industrial welding tool