Exemplo n.º 1
0
        /// <summary>
        /// Checks to see if a door can be emagged, does checks for BumpInteraction and Hand Interactions.
        /// </summary>
        /// <param name="itemStorage">The player's inventory that may contain the emag</param>
        /// <param name="interaction">If we're calling this from ClosedInteraction() to provide a HandApply</param>
        /// <param name="States">Door process states</param>
        /// <returns>Either hacked or ModuleSignal.Continue</returns>
        private ModuleSignal EmagChecks(DynamicItemStorage itemStorage, HandApply interaction, HashSet <DoorProcessingStates> States)
        {
            if (itemStorage != null)
            {
                try
                {
                    Emag emagInHand = itemStorage.GetActiveHandSlot().Item?.OrNull().gameObject.GetComponent <Emag>()?.OrNull();
                    if (emagInHand != null)
                    {
                        if (interaction != null)
                        {
                            if (emagInHand.UseCharge(interaction))
                            {
                                return(EmagSuccessLogic(States));
                            }
                        }
                        if (emagInHand.UseCharge(gameObject, itemStorage.registerPlayer.PlayerScript.gameObject))
                        {
                            return(EmagSuccessLogic(States));
                        }
                    }

                    foreach (var item in itemStorage.GetNamedItemSlots(NamedSlot.id))
                    {
                        Emag emagInIdSlot = item.Item?.OrNull().gameObject.GetComponent <Emag>()?.OrNull();
                        if (emagInIdSlot == null)
                        {
                            continue;
                        }
                        if (interaction != null)
                        {
                            if (emagInIdSlot.UseCharge(interaction))
                            {
                                return(EmagSuccessLogic(States));
                            }
                        }
                        if (emagInIdSlot.UseCharge(gameObject, itemStorage.registerPlayer.PlayerScript.gameObject))
                        {
                            return(EmagSuccessLogic(States));
                        }
                    }
                }
                catch (NullReferenceException exception)
                {
                    Logger.LogError(
                        $"A NRE was caught in EmagInteractionModule.ClosedInteraction() {exception.Message} \n {exception.StackTrace}",
                        Category.Interaction);
                }
            }

            return(ModuleSignal.Continue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks to see if a door can be emagged, does checks for BumpInteraction and Hand Interactions.
        /// </summary>
        /// <param name="itemStorage">The player's inventory that may contain the emag</param>
        /// <param name="interaction">If we're calling this from ClosedInteraction() to provide a HandApply</param>
        /// <param name="States">Door process states</param>
        /// <returns>Either hacked or ModuleSignal.Continue</returns>
        private ModuleSignal EmagChecks(DynamicItemStorage itemStorage, HandApply interaction,
                                        HashSet <DoorProcessingStates> States)
        {
            if (itemStorage != null)
            {
                Emag emagInHand = itemStorage.OrNull()?.GetActiveHandSlot()?.Item.OrNull()?.gameObject.OrNull()?.GetComponent <Emag>()?.OrNull();
                if (emagInHand != null)
                {
                    if (interaction != null)
                    {
                        if (emagInHand.UseCharge(interaction))
                        {
                            return(EmagSuccessLogic(States));
                        }
                    }

                    if (emagInHand.UseCharge(gameObject, itemStorage.registerPlayer.PlayerScript.gameObject))
                    {
                        return(EmagSuccessLogic(States));
                    }
                }

                foreach (var item in itemStorage.GetNamedItemSlots(NamedSlot.id))
                {
                    Emag emagInIdSlot = item?.Item.OrNull()?.gameObject.GetComponent <Emag>()?.OrNull();
                    if (emagInIdSlot == null)
                    {
                        continue;
                    }
                    if (interaction != null)
                    {
                        if (emagInIdSlot.UseCharge(interaction))
                        {
                            return(EmagSuccessLogic(States));
                        }
                    }

                    if (emagInIdSlot.UseCharge(gameObject, itemStorage.registerPlayer.PlayerScript.gameObject))
                    {
                        return(EmagSuccessLogic(States));
                    }
                }
            }

            return(ModuleSignal.Continue);
        }
Exemplo n.º 3
0
 public void PerformEmag(Emag emag, HandApply interaction)
 {
     if (MobController == null)
     {
         return;
     }
     MobController.IsEmagged = true;
     if (EMAGGED_SPRITE != null && spriteHandler != null)
     {
         spriteHandler.SetSprite(EMAGGED_SPRITE);
     }
     emag.UseCharge(interaction);
 }
Exemplo n.º 4
0
        public void PerformEmag(Emag emag, HandApply interaction)
        {
            if (MobController == null)
            {
                return;
            }

            MobController.IsEmagged = true;
            emag.UseCharge(interaction);
            Chat.AddActionMsgToChat(interaction,
                                    "The bot's behavior controls disengage. The bot begins to rattle and smolder",
                                    "You can smell caustic smoke from somewhere...");

            if (spriteHandler == null)
            {
                Logger.LogWarning($"{nameof(SpriteHandler)} missing on {gameObject}!", Category.Mobs);
                return;
            }

            spriteHandler.ChangeSprite(1, true);
        }
Exemplo n.º 5
0
        public void ServerPerformInteraction(HandApply interaction)
        {
            if (interaction.HandSlot.Item.TryGetComponent <IDCard>(out var id))
            {
                CheckID(id.JobType, interaction.Performer);
                return;
            }
            Emag mag = interaction.HandSlot.Item.GetComponent <Emag>();

            if (mag == null || Emagged)
            {
                return;
            }
            if (mag.UseCharge(interaction))
            {
                Emagged   = true;
                CorrectID = true;
                if (cargoGUI)
                {
                    cargoGUI.pageCart.UpdateTab();
                }
            }
        }
Exemplo n.º 6
0
        private void TryEmag(HandApply interaction, Emag emag)
        {
            if (emag.EmagHasCharges() == false)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, "The emag is out of charges!");
                return;
            }

            if (lockState == Lock.Broken)
            {
                Chat.AddExamineMsgFromServer(
                    interaction.Performer,
                    "You wave the emag over the panel, but it looks to be already destroyed...");
                return;
            }

            SoundManager.PlayNetworkedAtPos(soundOnEmag, registerObject.WorldPositionServer, sourceObj: gameObject);

            emag.UseCharge(interaction);
            BreakLock();
            Chat.AddActionMsgToChat(interaction,
                                    "The access panel errors. A slight amount of smoke pours from behind the panel...",
                                    "You can smell caustic smoke from somewhere...");
        }