Esempio n. 1
0
        private void OnAnchorComplete(EntityUid uid, AnchorableComponent component, TryAnchorCompletedEvent args)
        {
            component.CancelToken = null;
            var xform = Transform(uid);

            // Snap rotation to cardinal (multiple of 90)
            var rot = xform.LocalRotation;

            xform.LocalRotation = Math.Round(rot / (Math.PI / 2)) * (Math.PI / 2);

            if (TryComp <SharedPullableComponent>(uid, out var pullable) && pullable.Puller != null)
            {
                _pullingSystem.TryStopPull(pullable);
            }

            if (component.Snap)
            {
                xform.Coordinates = xform.Coordinates.SnapToGrid();
            }

            RaiseLocalEvent(uid, new BeforeAnchoredEvent(args.User, args.Using), false);
            xform.Anchored = true;
            RaiseLocalEvent(uid, new UserAnchoredEvent(args.User, args.Using), false);

            _popup.PopupEntity(Loc.GetString("anchorable-anchored"), uid, Filter.Pvs(uid, entityManager: EntityManager));

            _adminLogger.Add(
                LogType.Action,
                LogImpact.Low,
                $"{EntityManager.ToPrettyString(args.User):user} anchored {EntityManager.ToPrettyString(uid):anchored} using {EntityManager.ToPrettyString(args.Using):using}"
                );
        }
Esempio n. 2
0
        private void OnAnchoredExamine(EntityUid uid, AnchorableComponent component, ExaminedEvent args)
        {
            var isAnchored = Comp <TransformComponent>(uid).Anchored;
            var messageId  = isAnchored ? "examinable-anchored" : "examinable-unanchored";

            args.PushMarkup(Loc.GetString(messageId, ("target", uid)));
        }
        private async void OnInteractUsing(EntityUid uid, AnchorableComponent anchorable, InteractUsingEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // If the used entity doesn't have a tool, return early.
            if (!EntityManager.TryGetComponent(args.Used, out ToolComponent? usedTool))
            {
                return;
            }

            args.Handled = await TryToggleAnchor(uid, args.User, args.Used, anchorable, usingTool : usedTool);
        }
Esempio n. 4
0
    private void OnInteractUsing(EntityUid uid, AnchorableComponent anchorable, InteractUsingEvent args)
    {
        if (args.Handled)
        {
            return;
        }

        // If the used entity doesn't have a tool, return early.
        if (!TryComp(args.Used, out ToolComponent? usedTool) || !usedTool.Qualities.Contains(anchorable.Tool))
        {
            return;
        }

        args.Handled = true;
        TryToggleAnchor(uid, args.User, args.Used, anchorable, usingTool: usedTool);
    }
Esempio n. 5
0
        private void OnUnanchorComplete(EntityUid uid, AnchorableComponent component, TryUnanchorCompletedEvent args)
        {
            component.CancelToken = null;
            var xform = Transform(uid);

            RaiseLocalEvent(uid, new BeforeUnanchoredEvent(args.User, args.Using), false);
            xform.Anchored = false;
            RaiseLocalEvent(uid, new UserUnanchoredEvent(args.User, args.Using), false);

            _popup.PopupEntity(Loc.GetString("anchorable-unanchored"), uid, Filter.Pvs(uid, entityManager: EntityManager));

            _adminLogger.Add(
                LogType.Action,
                LogImpact.Low,
                $"{EntityManager.ToPrettyString(args.User):user} unanchored {EntityManager.ToPrettyString(uid):anchored} using {EntityManager.ToPrettyString(args.Using):using}"
                );
        }
Esempio n. 6
0
 private void OnAnchorCancelled(EntityUid uid, AnchorableComponent component, TryAnchorCancelledEvent args)
 {
     component.CancelToken = null;
 }