Exemplo n.º 1
0
        private void TryToggleLock(HandApply interaction)
        {
            /* --ACCESS REWORK--
             *  TODO Remove the AccessRestriction check when we finish migrating!
             *
             */
            if (accessRestrictions.CheckAccessCard(interaction.HandObject))
            {
                ToggleEmitter();
                return;                 //we found access, skip clearance check
            }

            if (clearanceCheckable.HasClearance(interaction.Performer))
            {
                ToggleEmitter();
            }

            void ToggleEmitter()
            {
                isLocked = !isLocked;

                Chat.AddActionMsgToChat(interaction.Performer,
                                        $"You {(isLocked ? "lock" : "unlock" )} the emitter",
                                        $"{interaction.Performer.ExpensiveName()} {(isLocked ? "locks" : "unlocks" )} the emitter");
            }
        }
Exemplo n.º 2
0
 public void ServerPerformInteraction(HandApply interaction)
 {
     // Is the player trying to put something in the closet
     if (interaction.HandObject != null)
     {
         if (!IsClosed)
         {
             Vector3 targetPosition    = interaction.TargetObject.WorldPosServer().RoundToInt();
             Vector3 performerPosition = interaction.Performer.WorldPosServer();
             Inventory.ServerDrop(interaction.HandSlot, targetPosition - performerPosition);
         }
         else if (IsLockable && AccessRestrictions != null)
         {
             if (AccessRestrictions.CheckAccessCard(interaction.HandObject))
             {
                 if (isLocked)
                 {
                     SyncLocked(isLocked, false);
                 }
                 else
                 {
                     SyncLocked(isLocked, true);
                 }
             }
         }
     }
     else if (!isLocked)
     {
         ServerToggleClosed();
     }
 }
Exemplo n.º 3
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        // Is the player trying to put something in the closet?
        if (interaction.HandObject != null)
        {
            if (!IsClosed)
            {
                Vector3 targetPosition    = interaction.TargetObject.WorldPosServer().RoundToInt();
                Vector3 performerPosition = interaction.Performer.WorldPosServer();
                Inventory.ServerDrop(interaction.HandSlot, targetPosition - performerPosition);
            }
            else if (IsClosed && !isEmagged && Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Emag))
            {
                SoundManager.PlayNetworkedAtPos(soundOnEmag, registerTile.WorldPositionServer, 1f, sourceObj: gameObject);
                ServerHandleContentsOnStatusChange(false);
                isEmagged = true;
                SyncLocked(isLocked, false);
                SyncStatus(statusSync, ClosetStatus.Open);
            }
        }
        else
        {
            // player want to close locker?
            if (!isLocked && !isEmagged)
            {
                ServerToggleClosed();
            }
        }


        // player trying to unlock locker?
        if (IsLockable && AccessRestrictions != null)
        {
            // player trying to open lock by card?
            if (AccessRestrictions.CheckAccessCard(interaction.HandObject))
            {
                if (isLocked)
                {
                    SyncLocked(isLocked, false);
                }
                else
                {
                    SyncLocked(isLocked, true);
                }
            }
            // player with access can unlock just by click
            else if (AccessRestrictions.CheckAccess(interaction.Performer))
            {
                if (isLocked)
                {
                    SyncLocked(isLocked, false);
                }
            }
        }
    }
Exemplo n.º 4
0
        private void TryToggleLock(HandApply interaction)
        {
            if (accessRestrictions.CheckAccessCard(interaction.HandObject))
            {
                isLocked = !isLocked;

                Chat.AddActionMsgToChat(interaction.Performer,
                                        $"You {(isLocked ? "lock" : "unlock" )} the emitter",
                                        $"{interaction.Performer.ExpensiveName()} {(isLocked ? "locks" : "unlocks" )} the emitter");
            }
        }
Exemplo n.º 5
0
        public void ServerPerformInteraction(HandApply interaction)
        {
            if (accessRestrictions.CheckAccessCard(interaction.HandObject))
            {
                IsLocked = !IsLocked;

                Chat.AddActionMsgToChat(interaction.Performer,
                                        $"You {(IsLocked ? "lock" : "unlock")} the air controller unit.",
                                        $"{interaction.PerformerPlayerScript.visibleName} {(IsLocked ? "locks" : "unlocks")} the air controller unit.");

                OnStateChanged?.Invoke();
            }
        }
Exemplo n.º 6
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        // Is the player trying to put something in the closet?
        if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Emag))
        {
            if (IsClosed && !isEmagged)
            {
                SoundManager.PlayNetworkedAtPos(soundOnEmag, registerTile.WorldPositionServer, 1f, gameObject);
                //ServerHandleContentsOnStatusChange(false);
                isEmagged = true;

                //SyncStatus(statusSync, ClosetStatus.Open);
                BreakLock();
            }
        }
        else if (Validations.HasUsedActiveWelder(interaction))
        {
            // Is the player trying to weld closet?
            if (IsWeldable && interaction.Intent == Intent.Harm)
            {
                ToolUtils.ServerUseToolWithActionMessages(
                    interaction, weldTime,
                    $"You start {(IsWelded ? "unwelding" : "welding")} the {closetName} door...",
                    $"{interaction.Performer.ExpensiveName()} starts {(IsWelded ? "unwelding" : "welding")} the {closetName} door...",
                    $"You {(IsWelded ? "unweld" : "weld")} the {closetName} door.",
                    $"{interaction.Performer.ExpensiveName()} {(IsWelded ? "unwelds" : "welds")} the {closetName} door.",
                    ServerTryWeld);
            }
        }
        else if (interaction.HandObject != null)
        {
            // If nothing in the players hand can be used on the closet, drop it in the closet
            if (!IsClosed)
            {
                Vector3 targetPosition    = interaction.TargetObject.WorldPosServer().RoundToInt();
                Vector3 performerPosition = interaction.Performer.WorldPosServer();
                Inventory.ServerDrop(interaction.HandSlot, targetPosition - performerPosition);
            }
        }
        else if (interaction.HandObject == null)
        {
            // player want to close locker?
            if (!isLocked && !isWelded)
            {
                ServerToggleClosed();
            }
            else if (isLocked || isWelded)
            {
                if (IsLockable)
                {                 //This is to stop cant open msg even though you can
                    if (!AccessRestrictions.CheckAccess(interaction.Performer))
                    {
                        Chat.AddExamineMsg(
                            interaction.Performer,
                            $"Can\'t open {closetName}");
                    }
                }
                else
                {
                    Chat.AddExamineMsg(
                        interaction.Performer,
                        $"Can\'t open {closetName}");
                }
            }
        }

        // player trying to unlock locker?
        if (IsLockable && AccessRestrictions != null)
        {
            // player trying to open lock by card?
            if (AccessRestrictions.CheckAccessCard(interaction.HandObject))
            {
                if (isLocked)
                {
                    SyncLocked(isLocked, false);
                }
                else
                {
                    SyncLocked(isLocked, true);
                }
            }
            // player with access can unlock just by click
            else if (AccessRestrictions.CheckAccess(interaction.Performer))
            {
                if (isLocked)
                {
                    SyncLocked(isLocked, false);
                }
            }
        }
    }