From 0995791d2e418e83a974c79e41b0f2fcc8781d20 Mon Sep 17 00:00:00 2001 From: Beck Date: Sat, 24 Aug 2024 22:22:25 -0700 Subject: [PATCH 1/8] First commit --- .../Lightning/ClientMatchstickSystem.cs | 7 + .../Light/Components/MatchboxComponent.cs | 9 -- .../Light/Components/MatchstickComponent.cs | 29 ---- .../Light/EntitySystems/MatchboxSystem.cs | 29 ---- .../Light/EntitySystems/MatchstickSystem.cs | 135 ++++-------------- .../Lightning/Components/MatchboxComponent.cs | 9 ++ .../Components/MatchstickComponent.cs | 35 +++++ .../Lightning/EntitySystems/MatchboxSystem.cs | 29 ++++ .../EntitySystems/SharedMatchstickSystem.cs | 86 +++++++++++ 9 files changed, 194 insertions(+), 174 deletions(-) create mode 100644 Content.Client/Lightning/ClientMatchstickSystem.cs delete mode 100644 Content.Server/Light/Components/MatchboxComponent.cs delete mode 100644 Content.Server/Light/Components/MatchstickComponent.cs delete mode 100644 Content.Server/Light/EntitySystems/MatchboxSystem.cs create mode 100644 Content.Shared/Lightning/Components/MatchboxComponent.cs create mode 100644 Content.Shared/Lightning/Components/MatchstickComponent.cs create mode 100644 Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs create mode 100644 Content.Shared/Lightning/EntitySystems/SharedMatchstickSystem.cs diff --git a/Content.Client/Lightning/ClientMatchstickSystem.cs b/Content.Client/Lightning/ClientMatchstickSystem.cs new file mode 100644 index 00000000000000..c05abb8ccc34bf --- /dev/null +++ b/Content.Client/Lightning/ClientMatchstickSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.Light.EntitySystems; + +namespace Content.Client.Light.EntitySystems; + +public sealed class MatchstickSystem : SharedMatchstickSystem +{ +} diff --git a/Content.Server/Light/Components/MatchboxComponent.cs b/Content.Server/Light/Components/MatchboxComponent.cs deleted file mode 100644 index 12cd4e38808169..00000000000000 --- a/Content.Server/Light/Components/MatchboxComponent.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Content.Server.Light.Components -{ - // TODO make changes in icons when different threshold reached - // e.g. different icons for 10% 50% 100% - [RegisterComponent] - public sealed partial class MatchboxComponent : Component - { - } -} diff --git a/Content.Server/Light/Components/MatchstickComponent.cs b/Content.Server/Light/Components/MatchstickComponent.cs deleted file mode 100644 index 3c47f4c18b3831..00000000000000 --- a/Content.Server/Light/Components/MatchstickComponent.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Content.Server.Light.EntitySystems; -using Content.Shared.Smoking; -using Robust.Shared.Audio; - -namespace Content.Server.Light.Components -{ - [RegisterComponent] - [Access(typeof(MatchstickSystem))] - public sealed partial class MatchstickComponent : Component - { - /// - /// Current state to matchstick. Can be Unlit, Lit or Burnt. - /// - [DataField("state")] - public SmokableState CurrentState = SmokableState.Unlit; - - /// - /// How long will matchstick last in seconds. - /// - [ViewVariables(VVAccess.ReadOnly)] - [DataField("duration")] - public int Duration = 10; - - /// - /// Sound played when you ignite the matchstick. - /// - [DataField("igniteSound", required: true)] public SoundSpecifier IgniteSound = default!; - } -} diff --git a/Content.Server/Light/EntitySystems/MatchboxSystem.cs b/Content.Server/Light/EntitySystems/MatchboxSystem.cs deleted file mode 100644 index 9a73e44f8783af..00000000000000 --- a/Content.Server/Light/EntitySystems/MatchboxSystem.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Content.Server.Light.Components; -using Content.Server.Storage.EntitySystems; -using Content.Shared.Interaction; -using Content.Shared.Smoking; - -namespace Content.Server.Light.EntitySystems -{ - public sealed class MatchboxSystem : EntitySystem - { - [Dependency] private readonly MatchstickSystem _stickSystem = default!; - - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnInteractUsing, before: new[] { typeof(StorageSystem) }); - } - - private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args) - { - if (!args.Handled - && EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick) - && matchstick.CurrentState == SmokableState.Unlit) - { - _stickSystem.Ignite((args.Used, matchstick), args.User); - args.Handled = true; - } - } - } -} diff --git a/Content.Server/Light/EntitySystems/MatchstickSystem.cs b/Content.Server/Light/EntitySystems/MatchstickSystem.cs index 96e4695784dd4f..1f37f7109b0c9e 100644 --- a/Content.Server/Light/EntitySystems/MatchstickSystem.cs +++ b/Content.Server/Light/EntitySystems/MatchstickSystem.cs @@ -1,124 +1,45 @@ -using Content.Server.Atmos.EntitySystems; -using Content.Server.Light.Components; -using Content.Shared.Audio; -using Content.Shared.Interaction; -using Content.Shared.Item; using Content.Shared.Smoking; -using Content.Shared.Temperature; +using Content.Shared.Light.Components; +using Content.Server.Atmos.EntitySystems; using Robust.Server.GameObjects; -using Robust.Shared.Audio; -using Robust.Shared.Audio.Systems; -using Robust.Shared.Player; - -namespace Content.Server.Light.EntitySystems -{ - public sealed class MatchstickSystem : EntitySystem - { - [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly SharedItemSystem _item = default!; - [Dependency] private readonly SharedPointLightSystem _lights = default!; - [Dependency] private readonly TransformSystem _transformSystem = default!; +using Robust.Shared.Timing; +using Content.Shared.Light.EntitySystems; - private readonly HashSet> _litMatches = new(); +namespace Content.Server.Light.EntitySystems; - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnInteractUsing); - SubscribeLocalEvent(OnIsHotEvent); - SubscribeLocalEvent(OnShutdown); - } - - private void OnShutdown(Entity ent, ref ComponentShutdown args) - { - _litMatches.Remove(ent); - } - - public override void Update(float frameTime) - { - base.Update(frameTime); - - foreach (var match in _litMatches) - { - if (match.Comp.CurrentState != SmokableState.Lit || Paused(match) || match.Comp.Deleted) - continue; - - var xform = Transform(match); - - if (xform.GridUid is not {} gridUid) - return; +public sealed class MatchstickSystem : SharedMatchstickSystem +{ + [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; + [Dependency] private readonly TransformSystem _transformSystem = default!; + [Dependency] private readonly IGameTiming _timing = default!; - var position = _transformSystem.GetGridOrMapTilePosition(match, xform); + public override void Initialize() + { + base.Initialize(); + } - _atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, match, true); - } - } + public override void Update(float frameTime) + { + var query = EntityQueryEnumerator(); - private void OnInteractUsing(Entity ent, ref InteractUsingEvent args) + while (query.MoveNext(out var uid, out var match)) { - if (args.Handled || ent.Comp.CurrentState != SmokableState.Unlit) - return; + if (match.CurrentState != SmokableState.Lit || Paused(uid) || match.Deleted) + continue; - var isHotEvent = new IsHotEvent(); - RaiseLocalEvent(args.Used, isHotEvent); + var xform = Transform(uid); - if (!isHotEvent.IsHot) + if (xform.GridUid is not { } gridUid) return; - Ignite(ent, args.User); - args.Handled = true; - } - - private void OnIsHotEvent(EntityUid uid, MatchstickComponent component, IsHotEvent args) - { - args.IsHot = component.CurrentState == SmokableState.Lit; - } - - public void Ignite(Entity matchstick, EntityUid user) - { - var component = matchstick.Comp; - - // Play Sound - _audio.PlayPvs(component.IgniteSound, matchstick, AudioParams.Default.WithVariation(0.125f).WithVolume(-0.125f)); - - // Change state - SetState(matchstick, component, SmokableState.Lit); - _litMatches.Add(matchstick); - matchstick.Owner.SpawnTimer(component.Duration * 1000, delegate - { - SetState(matchstick, component, SmokableState.Burnt); - _litMatches.Remove(matchstick); - }); - } - - private void SetState(EntityUid uid, MatchstickComponent component, SmokableState value) - { - component.CurrentState = value; - - if (_lights.TryGetLight(uid, out var pointLightComponent)) - { - _lights.SetEnabled(uid, component.CurrentState == SmokableState.Lit, pointLightComponent); - } + var position = _transformSystem.GetGridOrMapTilePosition(uid, xform); - if (EntityManager.TryGetComponent(uid, out ItemComponent? item)) - { - switch (component.CurrentState) - { - case SmokableState.Lit: - _item.SetHeldPrefix(uid, "lit", component: item); - break; - default: - _item.SetHeldPrefix(uid, "unlit", component: item); - break; - } - } + _atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, uid, true); - if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance)) - { - _appearance.SetData(uid, SmokingVisuals.Smoking, component.CurrentState, appearance); - } + // Check if the match has expired. + var burnoutTime = match.TimeMatchWillBurnOut; + if (burnoutTime != null && _timing.CurTime > burnoutTime) + SetState(uid, match, SmokableState.Burnt); } } } diff --git a/Content.Shared/Lightning/Components/MatchboxComponent.cs b/Content.Shared/Lightning/Components/MatchboxComponent.cs new file mode 100644 index 00000000000000..ec3ade871fbfad --- /dev/null +++ b/Content.Shared/Lightning/Components/MatchboxComponent.cs @@ -0,0 +1,9 @@ +namespace Content.Shared.Light.Components; + +// TODO make changes in icons when different threshold reached +// e.g. different icons for 10% 50% 100% +[RegisterComponent] +public sealed partial class MatchboxComponent : Component +{ +} + diff --git a/Content.Shared/Lightning/Components/MatchstickComponent.cs b/Content.Shared/Lightning/Components/MatchstickComponent.cs new file mode 100644 index 00000000000000..be241e6e2e2828 --- /dev/null +++ b/Content.Shared/Lightning/Components/MatchstickComponent.cs @@ -0,0 +1,35 @@ +using Content.Shared.Smoking; +using Robust.Shared.Audio; +using Robust.Shared.Serialization; +using Robust.Shared.GameStates; + +namespace Content.Shared.Light.Components; + +[NetworkedComponent, RegisterComponent] +[AutoGenerateComponentState] +public sealed partial class MatchstickComponent : Component +{ + /// + /// Current state to matchstick. Can be Unlit, Lit or Burnt. + /// + [DataField("state")] + [AutoNetworkedField] + public SmokableState CurrentState = SmokableState.Unlit; + + /// + /// How long will matchstick last in seconds. + /// + [ViewVariables(VVAccess.ReadOnly)] + public int Duration = 10; + + /// + /// Burnout + /// + [AutoNetworkedField] + public TimeSpan? TimeMatchWillBurnOut = null; + + /// + /// Sound played when you ignite the matchstick. + /// + [DataField("igniteSound", required: true)] public SoundSpecifier IgniteSound = default!; +} diff --git a/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs b/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs new file mode 100644 index 00000000000000..1babaae644fea6 --- /dev/null +++ b/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs @@ -0,0 +1,29 @@ +using Content.Shared.Light.Components; +using Content.Shared.Storage.EntitySystems; +using Content.Shared.Interaction; +using Content.Shared.Smoking; + +namespace Content.Shared.Light.EntitySystems +{ + public sealed class SharedMatchboxSystem : EntitySystem + { + [Dependency] private readonly SharedMatchstickSystem _stickSystem = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnInteractUsing, before: new[] { typeof(SharedStorageSystem) }); + } + + private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args) + { + if (args.Handled || !EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)) + return; + + if (matchstick.CurrentState == SmokableState.Unlit) + _stickSystem.Ignite((args.Used, matchstick), args.User); + + args.Handled = true; + } + } +} diff --git a/Content.Shared/Lightning/EntitySystems/SharedMatchstickSystem.cs b/Content.Shared/Lightning/EntitySystems/SharedMatchstickSystem.cs new file mode 100644 index 00000000000000..d7f80a978790ce --- /dev/null +++ b/Content.Shared/Lightning/EntitySystems/SharedMatchstickSystem.cs @@ -0,0 +1,86 @@ +using Content.Shared.Interaction; +using Content.Shared.Item; +using Content.Shared.Smoking; +using Content.Shared.Temperature; +using Robust.Shared.Audio; +using Robust.Shared.Audio.Systems; +using Robust.Shared.Player; +using Content.Shared.Light.Components; +using Robust.Shared.Timing; + +namespace Content.Shared.Light.EntitySystems; + +public abstract class SharedMatchstickSystem : EntitySystem +{ + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedItemSystem _item = default!; + [Dependency] private readonly SharedPointLightSystem _lights = default!; + [Dependency] private readonly IGameTiming _timing = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnIsHotEvent); + } + + private void OnInteractUsing(Entity ent, ref InteractUsingEvent args) + { + if (args.Handled || ent.Comp.CurrentState != SmokableState.Unlit) + return; + + var isHotEvent = new IsHotEvent(); + RaiseLocalEvent(args.Used, isHotEvent); + + if (!isHotEvent.IsHot) + return; + + Ignite(ent, args.User); + args.Handled = true; + } + + private void OnIsHotEvent(EntityUid uid, MatchstickComponent component, IsHotEvent args) + { + args.IsHot = component.CurrentState == SmokableState.Lit; + } + + public void Ignite(Entity matchstick, EntityUid user) + { + // Play Sound + _audio.PlayPredicted(matchstick.Comp.IgniteSound, matchstick, user, AudioParams.Default.WithVariation(0.125f).WithVolume(-0.125f)); + + // Change state + SetState(matchstick, matchstick.Comp, SmokableState.Lit); + matchstick.Comp.TimeMatchWillBurnOut = _timing.CurTime + TimeSpan.FromSeconds(matchstick.Comp.Duration); + + } + + protected void SetState(EntityUid uid, MatchstickComponent component, SmokableState value) + { + component.CurrentState = value; + + if (_lights.TryGetLight(uid, out var pointLightComponent)) + { + _lights.SetEnabled(uid, component.CurrentState == SmokableState.Lit, pointLightComponent); + } + + if (EntityManager.TryGetComponent(uid, out ItemComponent? item)) + { + switch (component.CurrentState) + { + case SmokableState.Lit: + _item.SetHeldPrefix(uid, "lit", component: item); + break; + default: + _item.SetHeldPrefix(uid, "unlit", component: item); + break; + } + } + + if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance)) + { + _appearance.SetData(uid, SmokingVisuals.Smoking, component.CurrentState, appearance); + } + } +} From d6683f47992b4789f9096a3c818ac96015bd750e Mon Sep 17 00:00:00 2001 From: Beck Date: Sat, 24 Aug 2024 22:57:25 -0700 Subject: [PATCH 2/8] Minor fixes please ymal error begone --- Content.Server/Light/EntitySystems/MatchstickSystem.cs | 3 +++ Content.Shared/Lightning/Components/MatchstickComponent.cs | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Server/Light/EntitySystems/MatchstickSystem.cs b/Content.Server/Light/EntitySystems/MatchstickSystem.cs index 1f37f7109b0c9e..da0fedf94228ff 100644 --- a/Content.Server/Light/EntitySystems/MatchstickSystem.cs +++ b/Content.Server/Light/EntitySystems/MatchstickSystem.cs @@ -39,7 +39,10 @@ public override void Update(float frameTime) // Check if the match has expired. var burnoutTime = match.TimeMatchWillBurnOut; if (burnoutTime != null && _timing.CurTime > burnoutTime) + { SetState(uid, match, SmokableState.Burnt); + match.TimeMatchWillBurnOut = null; + } } } } diff --git a/Content.Shared/Lightning/Components/MatchstickComponent.cs b/Content.Shared/Lightning/Components/MatchstickComponent.cs index be241e6e2e2828..1ea979a021fd5e 100644 --- a/Content.Shared/Lightning/Components/MatchstickComponent.cs +++ b/Content.Shared/Lightning/Components/MatchstickComponent.cs @@ -19,11 +19,10 @@ public sealed partial class MatchstickComponent : Component /// /// How long will matchstick last in seconds. /// - [ViewVariables(VVAccess.ReadOnly)] public int Duration = 10; /// - /// Burnout + /// The time that the match will burn out. If null, that means the match is unlit. /// [AutoNetworkedField] public TimeSpan? TimeMatchWillBurnOut = null; From 19ab5735574803dc761e108bad8962d664db8cd2 Mon Sep 17 00:00:00 2001 From: Beck Date: Sat, 24 Aug 2024 23:04:11 -0700 Subject: [PATCH 3/8] If this fixes it --- Content.Shared/Lightning/Components/MatchstickComponent.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Content.Shared/Lightning/Components/MatchstickComponent.cs b/Content.Shared/Lightning/Components/MatchstickComponent.cs index 1ea979a021fd5e..b7c349f6976064 100644 --- a/Content.Shared/Lightning/Components/MatchstickComponent.cs +++ b/Content.Shared/Lightning/Components/MatchstickComponent.cs @@ -19,6 +19,7 @@ public sealed partial class MatchstickComponent : Component /// /// How long will matchstick last in seconds. /// + [DataField("duration")] public int Duration = 10; /// From c0af80902906de4324d40e1c7e93d29b22f1c685 Mon Sep 17 00:00:00 2001 From: Beck Date: Sat, 24 Aug 2024 23:18:17 -0700 Subject: [PATCH 4/8] Last chance --- Content.Shared/Lightning/Components/MatchstickComponent.cs | 4 +--- Resources/Prototypes/Entities/Objects/Tools/matches.yml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Lightning/Components/MatchstickComponent.cs b/Content.Shared/Lightning/Components/MatchstickComponent.cs index b7c349f6976064..8dd73750a840d1 100644 --- a/Content.Shared/Lightning/Components/MatchstickComponent.cs +++ b/Content.Shared/Lightning/Components/MatchstickComponent.cs @@ -12,14 +12,12 @@ public sealed partial class MatchstickComponent : Component /// /// Current state to matchstick. Can be Unlit, Lit or Burnt. /// - [DataField("state")] [AutoNetworkedField] public SmokableState CurrentState = SmokableState.Unlit; /// /// How long will matchstick last in seconds. /// - [DataField("duration")] public int Duration = 10; /// @@ -31,5 +29,5 @@ public sealed partial class MatchstickComponent : Component /// /// Sound played when you ignite the matchstick. /// - [DataField("igniteSound", required: true)] public SoundSpecifier IgniteSound = default!; + [DataField(required: true)] public SoundSpecifier IgniteSound = default!; } diff --git a/Resources/Prototypes/Entities/Objects/Tools/matches.yml b/Resources/Prototypes/Entities/Objects/Tools/matches.yml index e8601fcf355dba..30c2749d3efdee 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/matches.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/matches.yml @@ -51,7 +51,7 @@ layers: - state: match_burnt - type: Matchstick - state: Burnt + currentState: Burnt - type: entity name: match box From 485861d28d1da1f5219eec488a4cea737a3e9ffc Mon Sep 17 00:00:00 2001 From: Beck Date: Sat, 24 Aug 2024 23:25:21 -0700 Subject: [PATCH 5/8] How --- Content.Shared/Lightning/Components/MatchstickComponent.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Lightning/Components/MatchstickComponent.cs b/Content.Shared/Lightning/Components/MatchstickComponent.cs index 8dd73750a840d1..b7c349f6976064 100644 --- a/Content.Shared/Lightning/Components/MatchstickComponent.cs +++ b/Content.Shared/Lightning/Components/MatchstickComponent.cs @@ -12,12 +12,14 @@ public sealed partial class MatchstickComponent : Component /// /// Current state to matchstick. Can be Unlit, Lit or Burnt. /// + [DataField("state")] [AutoNetworkedField] public SmokableState CurrentState = SmokableState.Unlit; /// /// How long will matchstick last in seconds. /// + [DataField("duration")] public int Duration = 10; /// @@ -29,5 +31,5 @@ public sealed partial class MatchstickComponent : Component /// /// Sound played when you ignite the matchstick. /// - [DataField(required: true)] public SoundSpecifier IgniteSound = default!; + [DataField("igniteSound", required: true)] public SoundSpecifier IgniteSound = default!; } From 92c686dba3cf42d7de05ddac2b042ee016760f49 Mon Sep 17 00:00:00 2001 From: Beck Date: Sat, 24 Aug 2024 23:25:40 -0700 Subject: [PATCH 6/8] Forgot --- Resources/Prototypes/Entities/Objects/Tools/matches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Prototypes/Entities/Objects/Tools/matches.yml b/Resources/Prototypes/Entities/Objects/Tools/matches.yml index 30c2749d3efdee..e8601fcf355dba 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/matches.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/matches.yml @@ -51,7 +51,7 @@ layers: - state: match_burnt - type: Matchstick - currentState: Burnt + state: Burnt - type: entity name: match box From 80c61b50c49c34beec645df5da5ea6df78f52033 Mon Sep 17 00:00:00 2001 From: Beck Date: Fri, 20 Sep 2024 11:56:49 -0700 Subject: [PATCH 7/8] First fixes --- .../Light/EntitySystems/MatchstickSystem.cs | 4 +-- .../Lightning/EntitySystems/MatchboxSystem.cs | 33 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Content.Server/Light/EntitySystems/MatchstickSystem.cs b/Content.Server/Light/EntitySystems/MatchstickSystem.cs index da0fedf94228ff..25f137611d5475 100644 --- a/Content.Server/Light/EntitySystems/MatchstickSystem.cs +++ b/Content.Server/Light/EntitySystems/MatchstickSystem.cs @@ -24,13 +24,13 @@ public override void Update(float frameTime) while (query.MoveNext(out var uid, out var match)) { - if (match.CurrentState != SmokableState.Lit || Paused(uid) || match.Deleted) + if (match.CurrentState != SmokableState.Lit) continue; var xform = Transform(uid); if (xform.GridUid is not { } gridUid) - return; + continue; var position = _transformSystem.GetGridOrMapTilePosition(uid, xform); diff --git a/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs b/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs index 1babaae644fea6..7bcbc654206df2 100644 --- a/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs +++ b/Content.Shared/Lightning/EntitySystems/MatchboxSystem.cs @@ -3,27 +3,26 @@ using Content.Shared.Interaction; using Content.Shared.Smoking; -namespace Content.Shared.Light.EntitySystems +namespace Content.Shared.Light.EntitySystems; + +public sealed class SharedMatchboxSystem : EntitySystem { - public sealed class SharedMatchboxSystem : EntitySystem - { - [Dependency] private readonly SharedMatchstickSystem _stickSystem = default!; + [Dependency] private readonly SharedMatchstickSystem _stickSystem = default!; - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnInteractUsing, before: new[] { typeof(SharedStorageSystem) }); - } + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnInteractUsing, before: new[] { typeof(SharedStorageSystem) }); + } - private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args) - { - if (args.Handled || !EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)) - return; + private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args) + { + if (args.Handled || !EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)) + return; - if (matchstick.CurrentState == SmokableState.Unlit) - _stickSystem.Ignite((args.Used, matchstick), args.User); + if (matchstick.CurrentState == SmokableState.Unlit) + _stickSystem.Ignite((args.Used, matchstick), args.User); - args.Handled = true; - } + args.Handled = true; } } From 6e7d4c2471f0218d8116884a0e125ce03035213d Mon Sep 17 00:00:00 2001 From: Beck Date: Fri, 20 Sep 2024 12:01:31 -0700 Subject: [PATCH 8/8] Added correct component tags --- Content.Shared/Lightning/Components/MatchboxComponent.cs | 4 +++- Content.Shared/Lightning/Components/MatchstickComponent.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Lightning/Components/MatchboxComponent.cs b/Content.Shared/Lightning/Components/MatchboxComponent.cs index ec3ade871fbfad..8747c231c0babb 100644 --- a/Content.Shared/Lightning/Components/MatchboxComponent.cs +++ b/Content.Shared/Lightning/Components/MatchboxComponent.cs @@ -1,8 +1,10 @@ +using Robust.Shared.GameStates; + namespace Content.Shared.Light.Components; // TODO make changes in icons when different threshold reached // e.g. different icons for 10% 50% 100% -[RegisterComponent] +[RegisterComponent, NetworkedComponent] public sealed partial class MatchboxComponent : Component { } diff --git a/Content.Shared/Lightning/Components/MatchstickComponent.cs b/Content.Shared/Lightning/Components/MatchstickComponent.cs index b7c349f6976064..e741b5d9aa4c01 100644 --- a/Content.Shared/Lightning/Components/MatchstickComponent.cs +++ b/Content.Shared/Lightning/Components/MatchstickComponent.cs @@ -6,7 +6,7 @@ namespace Content.Shared.Light.Components; [NetworkedComponent, RegisterComponent] -[AutoGenerateComponentState] +[AutoGenerateComponentState, AutoGenerateComponentPause] public sealed partial class MatchstickComponent : Component { /// @@ -25,7 +25,7 @@ public sealed partial class MatchstickComponent : Component /// /// The time that the match will burn out. If null, that means the match is unlit. /// - [AutoNetworkedField] + [AutoNetworkedField, AutoPausedField] public TimeSpan? TimeMatchWillBurnOut = null; ///