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); }
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); }
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); }