Light Cigars when interacting with hot stuff (#5879)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
JustinTime
2021-12-24 04:59:14 -07:00
committed by GitHub
parent 105b38b7f4
commit 0fd0035581
3 changed files with 27 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<CigarComponent, ActivateInWorldEvent>(OnCigarActivatedEvent);
SubscribeLocalEvent<CigarComponent, InteractUsingEvent>(OnCigarInteractUsingEvent);
SubscribeLocalEvent<CigarComponent, SmokableSolutionEmptyEvent>(OnCigarSolutionEmptyEvent);
SubscribeLocalEvent<CigarComponent, AfterInteractEvent>(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);