private IEnumerator <float> ChangeTo035(Player player) { RoleType playerRole = player.Role; yield return(Timing.WaitForSeconds(TransformationDelay)); if (player.Role != playerRole) { Log.Debug($"{nameof(ChangeTo035)}: {player.Nickname} picked up 035 as {playerRole} but they are now {player.Role}, cancelling change.", Plugin.Instance.Config.Debug); yield break; } ChangedPlayers.Add(player); foreach (Item item in player.Items.ToList()) { if (Check(item)) { player.RemoveItem(item); } } CustomRole.Get(typeof(Scp035Role)).AddRole(player); }
/// <inheritdoc/> public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { Player player = Player.Get((CommandSender)sender); int abilityNumber = 0; if (arguments.Count > 0) { int.TryParse(arguments.At(0), out abilityNumber); } ReadOnlyCollection <CustomRole> roles = player.GetCustomRoles(); if (roles.Count == 0) { response = "You do not have any custom roles."; return(false); } if (arguments.Count > 1) { CustomRole role = CustomRole.Get(arguments.At(1)); if (role == null) { response = $"The specified role {arguments.At(1)} does not exist."; return(false); } if (role.CustomAbilities.Count >= abilityNumber + 1) { if (role.CustomAbilities[abilityNumber] is ActiveAbility active) { if (!active.CanUseAbility(player, out response)) { return(false); } active.UseAbility(player); response = $"Ability {active.Name} used."; return(true); } } } response = "Could not find an ability that was able to be used."; foreach (CustomRole customRole in roles) { if (customRole.CustomAbilities.Count < abilityNumber + 1 || !(customRole.CustomAbilities[abilityNumber] is ActiveAbility activeAbility) || !activeAbility.CanUseAbility(player, out response)) { continue; } activeAbility.UseAbility(player); response = $"Ability {activeAbility.Name} used."; return(true); } return(false); }