示例#1
0
        public void OnOutsitePanelAccess(ActivatingWarheadPanelEventArgs ev)
        {
            if (!RemoteKeycard.instance.PatchedSuccessfully)
            {
                return;
            }

            if (!CanInteract(ev.Player) || !RKConfig.HandleOutsidePanelAccess)
            {
                return;
            }

            const Keycard.Permissions PANEL_PERMISSION = Keycard.Permissions.ContainmentLevelThree;

            RemoteKeycard.Debug($"Player {ev.Player.Nickname} ({ev.Player.UserId}) is trying to access the outside panel");
            RemoteKeycard.Debug($"Outsite panel permissions: {PANEL_PERMISSION}");

            if (ev.IsAllowed)
            {
                RemoteKeycard.Debug("Outsite panel access is allowed");
                return;
            }

            RemoteKeycard.Debug("Further processing is allowed...");

            var pInv = ev.Player.Inventory.items;

            ev.IsAllowed = Handle(pInv, PANEL_PERMISSION);
        }
示例#2
0
        public void OnDoorAccess(InteractingDoorEventArgs ev)
        {
            if (!CanInteract(ev.Player))
            {
                return;
            }

            RemoteKeycard.Debug($"Player {ev.Player.Nickname} ({ev.Player.UserId}) is trying to access the door");
            RemoteKeycard.Debug($"Door permission: {ev.Door.RequiredPermissions.RequiredPermissions}");

            DoorLockMode lockMode = DoorLockUtils.GetMode((DoorLockReason)ev.Door.ActiveLocks);

            RemoteKeycard.Debug($"Door lock mode: {lockMode}");

            if (ev.IsAllowed ||
                ((ev.Door is IDamageableDoor damageableDoor) && damageableDoor.IsDestroyed) ||
                (ev.Door.NetworkTargetState && !lockMode.HasFlagFast(DoorLockMode.CanClose)) ||
                (!ev.Door.NetworkTargetState && !lockMode.HasFlagFast(DoorLockMode.CanOpen)) ||
                lockMode == DoorLockMode.FullLock)
            {
                RemoteKeycard.Debug("Door is locked, destroyed, or the player has access to open it");
                return;
            }

            RemoteKeycard.Debug("Further processing is allowed...");

            var playerIntentory = ev.Player.Inventory.items;

            ev.IsAllowed = Handle(playerIntentory, ev.Door.RequiredPermissions.RequiredPermissions.ToTruthyPermissions(), ev.Door.RequiredPermissions.RequireAll);
        }
示例#3
0
        public override void OnEnable()
        {
            enabled = Config.GetBool("rkc_enable", true);
            if (!enabled)
            {
                return;
            }
            plugin = this;

            Plugin.Info("Registering events...");
            LocalEvents = new EventHandlers();
            Events.DoorInteractEvent += LocalEvents.OnDoorAccess;

            ConfigManagers.Manager.ReloadConfig();
        }
示例#4
0
        private bool Handle(Inventory.SyncListItemInfo inv, Keycard.Permissions perms, bool requireAll = true)
        {
            if (perms == Keycard.Permissions.None)
            {
                return(true);
            }

            foreach (var item in inv)
            {
                RemoteKeycard.Debug($"Processing an item in the player’s inventory: {item.id} ({(int)item.id})");

                if (RKConfig.Cards?.Length > 0 && !RKConfig.Cards.Contains(item.id))
                {
                    continue;
                }

                var gameItem = Array.Find(GetItems(), i => i.id == item.id);

                RemoteKeycard.Debug($"Game item is null: {gameItem == null}");
                // Relevant for items whose type was not found
                if (gameItem == null)
                {
                    continue;
                }

                var itemPerms = Keycard.ToTruthyPermissions(gameItem.permissions);
                RemoteKeycard.Debug($"Game item processing: C {gameItem.itemCategory} ({(int)gameItem.itemCategory}) | T {item.id} ({(int)item.id}) | P {itemPerms} | P:string[] {string.Join(", ", gameItem.permissions)}");

                if (itemPerms.HasFlagFast(perms, requireAll))
                {
                    RemoteKeycard.Debug($"Item has successfully passed permission validation: {gameItem.id} ({(int)gameItem.id})");
                    return(true);
                }
            }

            return(false);
        }
示例#5
0
        public void OnGeneratorAccess(UnlockingGeneratorEventArgs ev)
        {
            if (!CanInteract(ev.Player) || !RKConfig.HandleGeneratorsAccess)
            {
                return;
            }

            const Keycard.Permissions GENERATOR_ACCESS = Keycard.Permissions.ArmoryLevelTwo;

            RemoteKeycard.Debug($"Player {ev.Player.Nickname} ({ev.Player.UserId}) is trying to access the generator");
            RemoteKeycard.Debug($"Generator permissions: {GENERATOR_ACCESS}");

            if (ev.IsAllowed)
            {
                RemoteKeycard.Debug("Unlocking is allowed");
                return;
            }

            RemoteKeycard.Debug("Further processing is allowed...");

            var playerIntentory = ev.Player.Inventory.items;

            ev.IsAllowed = Handle(playerIntentory, GENERATOR_ACCESS);
        }
示例#6
0
        public void OnLockerAccess(InteractingLockerEventArgs ev)
        {
            if (!CanInteract(ev.Player) || !RKConfig.HandleLockersAccess)
            {
                return;
            }

            RemoteKeycard.Debug($"Player {ev.Player.Nickname} ({ev.Player.UserId}) is trying to access the locker");
            RemoteKeycard.Debug($"Locker permissions: {(!string.IsNullOrEmpty(ev.Chamber.accessToken) ? "(null)" : ev.Chamber.accessToken)}");

            if (ev.IsAllowed)
            {
                RemoteKeycard.Debug("Locker access is allowed");
                return;
            }

            RemoteKeycard.Debug("Further processing is allowed...");

            var permissions = Keycard.ToTruthyPermissions(ev.Chamber.accessToken);

            var playerIntentory = ev.Player.Inventory.items;

            ev.IsAllowed = Handle(playerIntentory, permissions);
        }
示例#7
0
 public RemoteKeycard()
 {
     instance = this;
 }