mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Add modifier post assignment-check
This commit is contained in:
1 parent
8750e5c894
commit
7c085b1072
2 files changed
+13
-1
No files matched your search
@@ -152,7 +152,7 @@ public static class ModifierManager
|
||||
}
|
||||
|
||||
var candidates = availablePlayers
|
||||
.Where(x => IsGameModifierValid(x, modifier, modifier.TypeId))
|
||||
.Where(x => IsGameModifierPostCheck(x, modifier, modifier.TypeId))
|
||||
.ToList();
|
||||
|
||||
if (candidates.Count == 0)
|
||||
@@ -181,4 +181,9 @@ public static class ModifierManager
|
||||
!player.HasModifier(modifierId) && modifier.IsModifierValidOn(player.Data.Role) &&
|
||||
modifier.CanSpawnOnCurrentMode();
|
||||
}
|
||||
private static bool IsGameModifierPostCheck(PlayerControl player, GameModifier modifier, uint modifierId)
|
||||
{
|
||||
return (player.Data.Role is not ICustomRole role || role.IsModifierApplicable(modifier)) &&
|
||||
!player.HasModifier(modifierId) && modifier.IsModifierValidOnPostCheck(player.Data.Role);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,13 @@ public abstract class GameModifier : BaseModifier
|
||||
/// <returns><see langword="true"/> if the modifier is valid on the role, otherwise <see langword="false"/>.</returns>
|
||||
public virtual bool IsModifierValidOn(RoleBehaviour role) => true;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the modifier is valid on a role, which runs after players are determined but before the modifiers are given.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to be checked.</param>
|
||||
/// <returns><see langword="true"/> if the modifier is valid on the role, otherwise <see langword="false"/>.</returns>
|
||||
public virtual bool IsModifierValidOnPostCheck(RoleBehaviour role) => IsModifierValidOn(role);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the player won the game with this modifier. The modifier with the highest priority will override other modifiers.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user