Ejemplo n.º 1
0
        public void Flash(EntityUid target, EntityUid?user, EntityUid?used, float flashDuration, float slowTo, bool displayPopup = true, FlashableComponent?flashable = null)
        {
            if (!Resolve(target, ref flashable, false))
            {
                return;
            }

            var attempt = new FlashAttemptEvent(target, user, used);

            RaiseLocalEvent(target, attempt, true);

            if (attempt.Cancelled)
            {
                return;
            }

            flashable.LastFlash = _gameTiming.CurTime;
            flashable.Duration  = flashDuration / 1000f; // TODO: Make this sane...
            Dirty(flashable);

            _stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration / 1000f), true,
                                    slowTo, slowTo);

            if (displayPopup && user != null && target != user && EntityManager.EntityExists(user.Value))
            {
                user.Value.PopupMessage(target, Loc.GetString("flash-component-user-blinds-you",
                                                              ("user", Identity.Entity(user.Value, EntityManager))));
            }
        }
Ejemplo n.º 2
0
        public void Flash(EntityUid target, EntityUid?user, EntityUid?used, float flashDuration, float slowTo, bool displayPopup = true)
        {
            var attempt = new FlashAttemptEvent(target, user, used);

            RaiseLocalEvent(target, attempt);

            if (attempt.Cancelled)
            {
                return;
            }

            if (EntityManager.TryGetComponent <FlashableComponent>(target, out var flashable))
            {
                flashable.LastFlash = _gameTiming.CurTime;
                flashable.Duration  = flashDuration / 1000f; // TODO: Make this sane...
                flashable.Dirty();
            }

            _stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration / 1000f), true,
                                    slowTo, slowTo);

            if (displayPopup && user != null && target != user)
            {
                // TODO Resolving the EntityUidhere bad.
                if (EntityManager.EntityExists(user.Value) && EntityManager.EntityExists(target))
                {
                    user.Value.PopupMessage(target, Loc.GetString("flash-component-user-blinds-you",
                                                                  ("user", user.Value)));
                }
            }
        }
Ejemplo n.º 3
0
 private void OnFlashImmunityFlashAttempt(EntityUid uid, FlashImmunityComponent component, FlashAttemptEvent args)
 {
     if (component.Enabled)
     {
         args.Cancel();
     }
 }
Ejemplo n.º 4
0
 private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
 {
     foreach (var slot in new string[] { "head", "eyes", "mask" })
     {
         if (args.Cancelled)
         {
             break;
         }
         if (_inventorySystem.TryGetSlotEntity(uid, slot, out var item, component))
         {
             RaiseLocalEvent(item.Value, args, true);
         }
     }
 }
Ejemplo n.º 5
0
 private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
 {
     // Forward the event to the glasses, if any.
     if (component.TryGetSlotItem(EquipmentSlotDefines.Slots.EYES, out ItemComponent? glasses))
     {
         RaiseLocalEvent(glasses.Owner, args);
     }
 }
Ejemplo n.º 6
0
 private void OnInventoryFlashAttempt(EntityUid uid, InventoryComponent component, FlashAttemptEvent args)
 {
     // Forward the event to the glasses, if any.
     if (_inventorySystem.TryGetSlotEntity(uid, "eyes", out var slotEntity, component))
     {
         RaiseLocalEvent(slotEntity.Value, args);
     }
 }