From 0fd003558188a3f444a7612f180f947a896109ba Mon Sep 17 00:00:00 2001 From: JustinTime <41876089+JustinTether@users.noreply.github.com> Date: Fri, 24 Dec 2021 04:59:14 -0700 Subject: [PATCH] Light Cigars when interacting with hot stuff (#5879) Co-authored-by: metalgearsloth --- .../EntitySystems/SmokingSystem.Cigar.cs | 19 +++++++++++++++++++ .../Shuttles/Components/ThrusterComponent.cs | 2 +- .../Shuttles/EntitySystems/ThrusterSystem.cs | 8 +++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs b/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs index 0fc638fd2e..0af7869a11 100644 --- a/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs +++ b/Content.Server/Nutrition/EntitySystems/SmokingSystem.Cigar.cs @@ -13,6 +13,7 @@ namespace Content.Server.Nutrition.EntitySystems SubscribeLocalEvent(OnCigarActivatedEvent); SubscribeLocalEvent(OnCigarInteractUsingEvent); SubscribeLocalEvent(OnCigarSolutionEmptyEvent); + SubscribeLocalEvent(OnCigarAfterInteract); } private void OnCigarActivatedEvent(EntityUid uid, CigarComponent component, ActivateInWorldEvent args) @@ -51,6 +52,24 @@ namespace Content.Server.Nutrition.EntitySystems args.Handled = true; } + public void OnCigarAfterInteract(EntityUid uid, CigarComponent component, AfterInteractEvent args) + { + var targetEntity = args.Target; + if (targetEntity == null || + !EntityManager.TryGetComponent(uid, out SmokableComponent? smokable) || + smokable.State == SmokableState.Lit) + return; + + var isHotEvent = new IsHotEvent(); + RaiseLocalEvent(targetEntity.Value, isHotEvent); + + if (!isHotEvent.IsHot) + return; + + SetSmokableState(uid, SmokableState.Lit, smokable); + args.Handled = true; + } + private void OnCigarSolutionEmptyEvent(EntityUid uid, CigarComponent component, SmokableSolutionEmptyEvent args) { SetSmokableState(uid, SmokableState.Burnt); diff --git a/Content.Server/Shuttles/Components/ThrusterComponent.cs b/Content.Server/Shuttles/Components/ThrusterComponent.cs index 44be1f4b43..c052e7ed92 100644 --- a/Content.Server/Shuttles/Components/ThrusterComponent.cs +++ b/Content.Server/Shuttles/Components/ThrusterComponent.cs @@ -17,7 +17,7 @@ namespace Content.Server.Shuttles.Components public override string Name => "Thruster"; /// - /// Whether the thruster has been force to be enabled / disable (e.g. VV, interaction, etc.) + /// Whether the thruster has been force to be enabled / disabled (e.g. VV, interaction, etc.) /// [ViewVariables(VVAccess.ReadWrite)] [DataField("enabled")] diff --git a/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs b/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs index 347e863e4f..aad1134431 100644 --- a/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ThrusterSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Maps; using Content.Shared.Physics; +using Content.Shared.Temperature; using Content.Shared.Shuttles.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; @@ -52,7 +53,7 @@ namespace Content.Server.Shuttles.EntitySystems SubscribeLocalEvent(OnPowerChange); SubscribeLocalEvent(OnAnchorChange); SubscribeLocalEvent(OnRotate); - + SubscribeLocalEvent(OnIsHotEvent); SubscribeLocalEvent(OnStartCollide); SubscribeLocalEvent(OnEndCollide); @@ -95,6 +96,11 @@ namespace Content.Server.Shuttles.EntitySystems _mapManager.TileChanged -= OnTileChange; } + private void OnIsHotEvent(EntityUid uid, ThrusterComponent component, IsHotEvent args) + { + args.IsHot = component.Type != ThrusterType.Angular && component.IsOn; + } + private void OnTileChange(object? sender, TileChangedEventArgs e) { // If the old tile was space but the new one isn't then disable all adjacent thrusters