예제 #1
0
 private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
 {
     if (args.User.InRangeUnobstructed(args.Target) && Get <ActionBlockerSystem>().CanInteract(args.User))
     {
         Toggle(uid, component);
     }
 }
예제 #2
0
        private void OnActivate(EntityUid uid, UplinkComponent component, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // check if uplinks activates directly or use some proxy, like a PDA
            if (!component.ActivatesInHands)
            {
                return;
            }
            if (component.UplinkAccount == null)
            {
                return;
            }

            if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
            {
                return;
            }

            ToggleUplinkUI(component, actor.PlayerSession);
            args.Handled = true;
        }
        private void InteractionActivate(IEntity user, IEntity used)
        {
            var actionBlocker = Get <ActionBlockerSystem>();

            if (!actionBlocker.CanInteract(user) || !actionBlocker.CanUse(user))
            {
                return;
            }

            // all activates should only fire when in range / unobstructed
            if (!InRangeUnobstructed(user, used, ignoreInsideBlocker: true, popup: true))
            {
                return;
            }

            var activateMsg = new ActivateInWorldEvent(user, used);

            RaiseLocalEvent(used.Uid, activateMsg);
            if (activateMsg.Handled)
            {
                return;
            }

            if (!used.TryGetComponent(out IActivate? activateComp))
            {
                return;
            }

            var activateEventArgs = new ActivateEventArgs(user, used);

            activateComp.Activate(activateEventArgs);
        }
예제 #4
0
 private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
 {
     if (args.User.InRangeUnobstructed(args.Target) && _actionBlockerSystem.CanInteract(args.User))
     {
         Toggle(uid, component);
         SoundSystem.Play(Filter.Pvs(component.Owner), component.ValveSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.25f));
     }
 }
예제 #5
0
 private void OnActivateInWorld(EntityUid uid, PDAComponent pda, ActivateInWorldEvent args)
 {
     if (args.Handled)
     {
         return;
     }
     args.Handled = OpenUI(pda, args.User);
 }
예제 #6
0
 private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
 {
     if (TryComp <WiresComponent>(uid, out var wiresComponent) && wiresComponent.IsPanelOpen &&
         EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
     {
         wiresComponent.OpenInterface(actor.PlayerSession);
         args.Handled = true;
     }
 }
예제 #7
0
 private void OnActivate(EntityUid uid, AirlockPainterComponent component, ActivateInWorldEvent args)
 {
     if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
     {
         return;
     }
     DirtyUI(uid, component);
     component.Owner.GetUIOrNull(AirlockPainterUiKey.Key)?.Open(actor.PlayerSession);
     args.Handled = true;
 }
        private void OnActivate(EntityUid uid, HandLabelerComponent handLabeler, ActivateInWorldEvent args)
        {
            if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
            {
                return;
            }

            handLabeler.Owner.GetUIOrNull(HandLabelerUiKey.Key)?.Open(actor.PlayerSession);
            args.Handled = true;
        }
예제 #9
0
        private void OnActivateInWorld(EntityUid uid, ItemCabinetComponent comp, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            args.Handled = true;
            ToggleItemCabinet(uid, comp);
        }
    private void OnInteract(EntityUid uid, EntityStorageComponent component, ActivateInWorldEvent args)
    {
        if (args.Handled)
        {
            return;
        }

        args.Handled = true;
        ToggleOpen(args.User, uid, component);
    }
예제 #11
0
        private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args)
        {
            TogglePinpointer(uid, component);

            // try to find target from whitelist
            if (component.IsActive && component.Whitelist != null)
            {
                var target = FindTargetFromWhitelist(uid, component.Whitelist);
                SetTarget(uid, target, component);
            }
        }
예제 #12
0
    protected override void OnActivate(EntityUid uid, DoorComponent door, ActivateInWorldEvent args)
    {
        // TODO once access permissions are shared, move this back to shared.
        if (args.Handled || !door.ClickOpen)
        {
            return;
        }

        TryToggleDoor(uid, door, args.User);
        args.Handled = true;
    }
 private void OnActivate(EntityUid uid, ActivatableUIComponent component, ActivateInWorldEvent args)
 {
     if (args.Handled)
     {
         return;
     }
     if (component.InHandsOnly)
     {
         return;
     }
     args.Handled = InteractUI(args.User, component);
 }
        private void OnActivated(EntityUid uid, SignalSwitchComponent component, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            component.State = !component.State;
            _signalSystem.InvokePort(uid, component.State ? component.OnPort : component.OffPort);
            SoundSystem.Play(component.ClickSound.GetSound(), Filter.Pvs(component.Owner), component.Owner,
                             AudioHelpers.WithVariation(0.125f).WithVolume(8f));

            args.Handled = true;
        }
예제 #15
0
        /// <summary>
        /// Sends a message to open the storage UI
        /// </summary>
        /// <returns></returns>
        private void OnActivate(EntityUid uid, ServerStorageComponent storageComp, ActivateInWorldEvent args)
        {
            if (!TryComp <ActorComponent>(args.User, out var actor))
            {
                return;
            }

            if (TryComp(uid, out LockComponent? lockComponent) && lockComponent.Locked)
            {
                return;
            }

            OpenStorageUI(uid, args.User, storageComp);
        }
예제 #16
0
 private void OnActivated(EntityUid eUI, LockComponent lockComp, ActivateInWorldEvent args)
 {
     // Only attempt an unlock by default on Activate
     if (lockComp.Locked)
     {
         DoUnlock(lockComp, args);
     }
     else
     {
         if (lockComp.LockOnClick)
         {
             DoLock(lockComp, args);
         }
     }
 }
예제 #17
0
        private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args)
        {
            TogglePinpointer(uid, component);

            // try to find target from whitelist
            if (component.IsActive && component.Component != null)
            {
                if (!EntityManager.ComponentFactory.TryGetRegistration(component.Component, out var reg))
                {
                    Logger.Error($"Unable to find component registration for {component.Component} for pinpointer!");
                    DebugTools.Assert(false);
                    return;
                }

                var target = FindTargetFromComponent(uid, reg.Type);
                SetTarget(uid, target, component);
            }
        }
예제 #18
0
        private void OnActivated(EntityUid uid, LockComponent lockComp, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            // Only attempt an unlock by default on Activate
            if (lockComp.Locked)
            {
                TryUnlock(uid, args.User, lockComp);
                args.Handled = true;
            }
            else if (lockComp.LockOnClick)
            {
                TryLock(uid, args.User, lockComp);
                args.Handled = true;
            }
        }
        private void OnCigarActivatedEvent(EntityUid uid, CigarComponent component, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            if (!EntityManager.TryGetComponent(uid, out SmokableComponent? smokable))
            {
                return;
            }

            if (smokable.State != SmokableState.Lit)
            {
                return;
            }

            SetSmokableState(uid, SmokableState.Burnt, smokable);
            args.Handled = true;
        }
예제 #20
0
            protected override void Activate(IEntity user, LockComponent component)
            {
                // Do checks
                if (!EntitySystem.Get <ActionBlockerSystem>().CanInteract(user) ||
                    !user.InRangeUnobstructed(component))
                {
                    return;
                }

                // Call relevant entity system
                var lockSystem = user.EntityManager.EntitySysManager.GetEntitySystem <LockSystem>();
                var eventData  = new ActivateInWorldEvent(user, component.Owner);

                if (component.Locked)
                {
                    lockSystem.DoUnlock(component, eventData);
                }
                else
                {
                    lockSystem.DoLock(component, eventData);
                }
            }
        private void OnActivated(EntityUid uid, TwoWayLeverComponent component, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            component.State = component.State switch
            {
                TwoWayLeverState.Middle => component.NextSignalLeft ? TwoWayLeverState.Left : TwoWayLeverState.Right,
                TwoWayLeverState.Right => TwoWayLeverState.Middle,
                TwoWayLeverState.Left => TwoWayLeverState.Middle,
                _ => throw new ArgumentOutOfRangeException()
            };

            if (component.State == TwoWayLeverState.Middle)
            {
                component.NextSignalLeft = !component.NextSignalLeft;
            }

            if (TryComp(uid, out AppearanceComponent? appearanceComponent))
            {
                appearanceComponent.SetData(TwoWayLeverVisuals.State, component.State);
            }

            var port = component.State switch
            {
                TwoWayLeverState.Left => component.LeftPort,
                TwoWayLeverState.Right => component.RightPort,
                TwoWayLeverState.Middle => component.MiddlePort,
                _ => throw new ArgumentOutOfRangeException()
            };

            _signalSystem.InvokePort(uid, port);
            args.Handled = true;
        }
    }
}
예제 #22
0
        public void DoLock(LockComponent lockComp, ActivateInWorldEvent args)
        {
            if (!HasUserAccess(lockComp, args.User))
            {
                return;
            }

            lockComp.Owner.PopupMessage(args.User, Loc.GetString("lock-comp-do-lock-success", ("entityName", lockComp.Owner.Name)));
            lockComp.Locked = true;
            if (lockComp.LockSound != null)
            {
                SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5));
            }

            if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp))
            {
                appearanceComp.SetData(StorageVisuals.Locked, true);
            }

            RaiseLocalEvent(lockComp.Owner.Uid, new LockToggledEvent(true));

            args.Handled = true;
        }
예제 #23
0
        private void InteractionActivate(IEntity user, IEntity used)
        {
            var activateMsg = new ActivateInWorldEvent(user, used);

            RaiseLocalEvent(used.Uid, activateMsg);
            if (activateMsg.Handled)
            {
                return;
            }

            if (!used.TryGetComponent(out IActivate? activateComp))
            {
                return;
            }

            // all activates should only fire when in range / unbostructed
            var activateEventArgs = new ActivateEventArgs(user, used);

            if (activateEventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
            {
                activateComp.Activate(activateEventArgs);
            }
        }
        private void OnTabletopActivate(EntityUid uid, TabletopGameComponent component, ActivateInWorldEvent args)
        {
            // Check that a player is attached to the entity.
            if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
            {
                return;
            }

            // Check that the entity can interact with the game board.
            if (_actionBlockerSystem.CanInteract(args.User))
            {
                OpenSessionFor(actor.PlayerSession, uid);
            }
        }
        private void OnActivated(EntityUid uid, MedicalScannerComponent scannerComponent, ActivateInWorldEvent args)
        {
            if (!TryComp <ActorComponent>(args.User, out var actor) || !IsPowered(scannerComponent))
            {
                return;
            }

            scannerComponent.UserInterface?.Toggle(actor.PlayerSession);
            UpdateUserInterface(uid, scannerComponent);
        }
예제 #26
0
 private void OnActivate(EntityUid uid, DiceComponent component, ActivateInWorldEvent args)
 {
     Roll(uid, component);
 }
예제 #27
0
        /// <summary>
        /// For now pilots just interact with the console and can start piloting with wasd.
        /// </summary>
        private void HandleConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, ActivateInWorldEvent args)
        {
            if (!args.User.HasTag("CanPilot"))
            {
                return;
            }

            var pilotComponent = args.User.EnsureComponent <PilotComponent>();

            if (!component.Enabled)
            {
                args.User.PopupMessage($"Console is not powered.");
                return;
            }

            args.Handled = true;
            var console = pilotComponent.Console;

            if (console != null)
            {
                RemovePilot(pilotComponent);

                if (console != component)
                {
                    return;
                }
            }

            AddPilot(args.User, component);
        }
예제 #28
0
        private void OnCanisterActivate(EntityUid uid, GasCanisterComponent component, ActivateInWorldEvent args)
        {
            if (!args.User.TryGetComponent(out ActorComponent? actor))
            {
                return;
            }

            component.Owner.GetUIOrNull(GasCanisterUiKey.Key)?.Open(actor.PlayerSession);
            args.Handled = true;
        }
예제 #29
0
        private void OnMultipleToolActivated(EntityUid uid, MultipleToolComponent multiple, ActivateInWorldEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            args.Handled = CycleMultipleTool(uid, multiple);
        }
예제 #30
0
 private void OnBallisticActivate(EntityUid uid, BallisticAmmoProviderComponent component, ActivateInWorldEvent args)
 {
     ManualCycle(component, Transform(uid).MapPosition, args.User);
     args.Handled = true;
 }