private void OnUnequipped(EntityUid uid, StethoscopeComponent component, GotUnequippedEvent args) { if (!component.IsActive) { return; } RemComp <WearingStethoscopeComponent>(args.Equipee); component.IsActive = false; }
// construct the doafter and start it private void StartListening(EntityUid user, EntityUid target, StethoscopeComponent comp) { comp.CancelToken = new CancellationTokenSource(); _doAfterSystem.DoAfter(new DoAfterEventArgs(user, comp.Delay, comp.CancelToken.Token, target: target) { BroadcastFinishedEvent = new ListenSuccessfulEvent(user, target, comp), BroadcastCancelledEvent = new ListenCancelledEvent(user, comp), BreakOnTargetMove = true, BreakOnUserMove = true, BreakOnStun = true, NeedHand = true }); }
/// <summary> /// Add the component the verb event subs to if the equippee is wearing the stethoscope. /// </summary> private void OnEquipped(EntityUid uid, StethoscopeComponent component, GotEquippedEvent args) { if (!TryComp <ClothingComponent>(uid, out var clothing)) { return; } // Is the clothing in its actual slot? if (!clothing.Slots.HasFlag(args.SlotFlags)) { return; } component.IsActive = true; var wearingComp = EnsureComp <WearingStethoscopeComponent>(args.Equipee); wearingComp.Stethoscope = uid; }
private void OnGetActions(EntityUid uid, StethoscopeComponent component, GetItemActionsEvent args) { args.Actions.Add(component.Action); }
private void OnStethoscopeAction(EntityUid uid, StethoscopeComponent component, StethoscopeActionEvent args) { StartListening(args.Performer, args.Target, component); }