mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
* Add support for contextual information in EntityTables (#37737) * Add context support for entityTables * fix build fail * comments * Update Content.Shared/EntityTable/EntityTableSystem.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> (cherry picked from commit e92b6b6a7e2ed2e5f7473321e391394f28b9ee4a) * Multiantag Gamemode (#37783) Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: Southbridge <7013162+southbridge-fur@users.noreply.github.com> Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> (cherry picked from commit f23e8c286153b5742de258a4e722803a1a4fba78) * Гейммоды * Ребаланс цен * Фикс линтера * Баланс бюджета + фикс повторения --------- Co-authored-by: Nemanja <98561806+emogarbage404@users.noreply.github.com>
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Content.Shared.EntityTable.EntitySelectors;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.EntityTable.Conditions;
|
|
|
|
/// <summary>
|
|
/// Condition that passes only if the server player count is within a certain range.
|
|
/// </summary>
|
|
public sealed partial class PlayerCountCondition : EntityTableCondition
|
|
{
|
|
/// <summary>
|
|
/// Minimum players of needed for this condition to succeed. Inclusive.
|
|
/// </summary>
|
|
[DataField]
|
|
public int Min = int.MinValue;
|
|
|
|
/// <summary>
|
|
/// Maximum numbers of players there can be for this condition to succeed. Inclusive.
|
|
/// </summary>
|
|
[DataField]
|
|
public int Max = int.MaxValue;
|
|
|
|
private static ISharedPlayerManager? _playerManager;
|
|
|
|
protected override bool EvaluateImplementation(EntityTableSelector root, IEntityManager entMan, IPrototypeManager proto, EntityTableContext ctx)
|
|
{
|
|
// Don't resolve this repeatedly
|
|
_playerManager ??= IoCManager.Resolve<ISharedPlayerManager>();
|
|
|
|
var playerCount = _playerManager.PlayerCount;
|
|
|
|
return playerCount >= Min && playerCount <= Max;
|
|
}
|
|
}
|