using Content.Server.Nutrition.Components; using Content.Shared.Interaction; using Content.Shared.Nutrition.Components; using Content.Shared.Smoking; using Content.Shared.Temperature; namespace Content.Server.Nutrition.EntitySystems { public sealed partial class SmokingSystem { private void InitializeCigars() { SubscribeLocalEvent(OnCigarActivatedEvent); SubscribeLocalEvent(OnCigarInteractUsingEvent); SubscribeLocalEvent(OnCigarSolutionEmptyEvent); SubscribeLocalEvent(OnCigarAfterInteract); } private void OnCigarActivatedEvent(Entity entity, ref ActivateInWorldEvent args) { if (args.Handled || !args.Complex) return; if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable)) return; if (smokable.State != SmokableState.Lit) return; SetSmokableState(entity, SmokableState.Burnt, smokable); args.Handled = true; } private void OnCigarInteractUsingEvent(Entity entity, ref InteractUsingEvent args) { if (args.Handled) return; if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable)) return; if (smokable.State != SmokableState.Unlit) return; var isHotEvent = new IsHotEvent(); RaiseLocalEvent(args.Used, isHotEvent, false); if (!isHotEvent.IsHot) return; SetSmokableState(entity, SmokableState.Lit, smokable); args.Handled = true; } public void OnCigarAfterInteract(Entity entity, ref AfterInteractEvent args) { var targetEntity = args.Target; if (targetEntity == null || !args.CanReach || !EntityManager.TryGetComponent(entity, out SmokableComponent? smokable) || smokable.State == SmokableState.Lit) return; var isHotEvent = new IsHotEvent(); RaiseLocalEvent(targetEntity.Value, isHotEvent, true); if (!isHotEvent.IsHot) return; SetSmokableState(entity, SmokableState.Lit, smokable); args.Handled = true; } private void OnCigarSolutionEmptyEvent(Entity entity, ref SmokableSolutionEmptyEvent args) { SetSmokableState(entity, SmokableState.Burnt); } } }