예제 #1
0
        public override void ServerBehaviour(AimApply interaction, bool isSuicide)
        {
            /* --ACCESS REWORK--
             *  TODO Remove the AccessRestriction check when we finish migrating!
             *
             */
            if (AccessRestrictions.CheckAccess(interaction.Performer))
            {
                //TODO Commented out as client doesnt sync job, after mind rework see if job is now sync'd
                // JobType job = GetJobServer(interaction.Performer);
                //
                // if (clusmyMisfire && job == JobType.CLOWN)
                // {
                //  ClumsyShotServer(interaction, isSuicide);
                // }
                // else
                // {
                //  CallShotServer(interaction, isSuicide);
                // }

                CallShotServer(interaction, isSuicide);
                return;                 //we found access skip clearance check
            }

            if (clearanceCheckable.HasClearance(interaction.Performer))
            {
                CallShotServer(interaction, isSuicide);
                return;
            }

            Chat.AddExamineMsg(interaction.Performer, deniedMessage);
        }
예제 #2
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");
            }
        }
예제 #3
0
        // This region (Interaction-RightClick) shouldn't exist once TODO in class summary is done.
        #region Interaction-RightClick

        public RightClickableResult GenerateRightClickOptions()
        {
            RightClickableResult result = RightClickableResult.Create();

            if (drawerState == DrawerState.Open)
            {
                return(result);
            }

            /* --ACCESS REWORK--
             *  TODO Remove the AccessRestriction check when we finish migrating!
             *
             */

            if (accessRestrictions)
            {
                if (accessRestrictions.CheckAccess(PlayerManager.LocalPlayer) == false)
                {
                    return(result);
                }
            }
            else if (clearanceCheckable)
            {
                if (clearanceCheckable.HasClearance(PlayerManager.LocalPlayer) == false)
                {
                    return(result);
                }
            }

            var cremateInteraction = ContextMenuApply.ByLocalPlayer(gameObject, null);

            if (!WillInteract(cremateInteraction, NetworkSide.Client))
            {
                return(result);
            }

            return(result.AddElement("Activate", () => OnCremateClicked(cremateInteraction)));
        }
예제 #4
0
 private bool AttemptAccess(List <Clearance> clearances)
 {
     return(checkable.HasClearance(clearances));
 }
예제 #5
0
        private bool CanSell(VendorItem itemToSpawn, ConnectedPlayer player)
        {
            // check if selected item is valid
            var isSelectionValid = itemToSpawn != null && itemToSpawn.Stock > 0;

            if (isSelectionValid == false)
            {
                return(false);
            }

            // check if this player has vending cooldown right now
            if (VendingCooldown)
            {
                if (player != null && player.Script)
                {
                    var hasCooldown = !Cooldowns.TryStartServer(player.Script, VendingCooldown);
                    if (hasCooldown)
                    {
                        return(false);
                    }
                }
            }

            /* --ACCESS REWORK--
             *  TODO Remove the AccessRestriction check when we finish migrating!
             *
             */
            // check player access
            if (player != null && (accessRestrictions || clearanceCheckable) && !isEmagged)
            {
                var hasAccess = accessRestrictions
                                        ? accessRestrictions.CheckAccess(player.GameObject)
                                        : clearanceCheckable.HasClearance(player.GameObject);

                if (hasAccess == false && player.Script.PlayerState != PlayerScript.PlayerStates.Ai)
                {
                    Chat.AddWarningMsgFromServer(player.GameObject, noAccessMessage);
                    return(false);
                }
            }

            if (itemToSpawn.Price > 0)
            {
                var playerStorage = player.GameObject.GetComponent <DynamicItemStorage>();
                var itemSlotList  = playerStorage.GetNamedItemSlots(NamedSlot.id);
                foreach (var itemSlot in itemSlotList)
                {
                    if (itemSlot.ItemObject)
                    {
                        var idCard = AccessRestrictions.GetIDCard(itemSlot.ItemObject);
                        if (idCard.currencies[(int)itemToSpawn.Currency] >= itemToSpawn.Price)
                        {
                            idCard.currencies[(int)itemToSpawn.Currency] -= itemToSpawn.Price;
                            break;
                        }
                        else
                        {
                            Chat.AddWarningMsgFromServer(player.GameObject, tooExpensiveMessage);
                            return(false);
                        }
                    }
                }
            }

            return(isSelectionValid);
        }