/// <summary> /// Checks if a tool can change the anchored status. /// </summary> /// <returns>true if it is valid, false otherwise</returns> private async Task <bool> Valid(EntityUid uid, EntityUid userUid, EntityUid usingUid, bool anchoring, AnchorableComponent?anchorable = null, ToolComponent?usingTool = null) { if (!Resolve(uid, ref anchorable)) { return(false); } if (!Resolve(usingUid, ref usingTool)) { return(false); } BaseAnchoredAttemptEvent attempt = anchoring ? new AnchorAttemptEvent(userUid, usingUid) : new UnanchorAttemptEvent(userUid, usingUid); // Need to cast the event or it will be raised as BaseAnchoredAttemptEvent. if (anchoring) { RaiseLocalEvent(uid, (AnchorAttemptEvent)attempt, false); } else { RaiseLocalEvent(uid, (UnanchorAttemptEvent)attempt, false); } if (attempt.Cancelled) { return(false); } return(await _toolSystem.UseTool(usingUid, userUid, uid, 0f, 0.5f + attempt.Delay, anchorable.Tool, toolComponent:usingTool)); }
/// <summary> /// Checks if a tool can change the anchored status. /// </summary> /// <returns>true if it is valid, false otherwise</returns> private bool Valid(EntityUid uid, EntityUid userUid, EntityUid usingUid, bool anchoring, AnchorableComponent?anchorable = null, ToolComponent?usingTool = null) { if (!Resolve(uid, ref anchorable) || anchorable.CancelToken != null) { return(false); } if (!Resolve(usingUid, ref usingTool)) { return(false); } BaseAnchoredAttemptEvent attempt = anchoring ? new AnchorAttemptEvent(userUid, usingUid) : new UnanchorAttemptEvent(userUid, usingUid); // Need to cast the event or it will be raised as BaseAnchoredAttemptEvent. if (anchoring) { RaiseLocalEvent(uid, (AnchorAttemptEvent)attempt, false); } else { RaiseLocalEvent(uid, (UnanchorAttemptEvent)attempt, false); } if (attempt.Cancelled) { return(false); } return(true); }
private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args) { // cancel any anchor attempt without nuke disk if (!component.DiskSlot.HasItem) { var msg = Loc.GetString("nuke-component-cant-anchor"); _popups.PopupEntity(msg, uid, Filter.Entities(args.User)); args.Cancel(); } }
private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args) { // cancel any anchor attempt if armed if (component.Status == NukeStatus.ARMED) { var msg = Loc.GetString("nuke-component-cant-anchor"); _popups.PopupEntity(msg, uid, Filter.Entities(args.User)); args.Cancel(); } }