2021-07-17 02:37:09 +02:00
|
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.ActionBlocker;
|
2020-12-20 04:31:04 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-06-25 15:52:24 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Shared.EffectBlocker
|
2020-06-25 15:52:24 +02:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Utility methods to check if an effect is allowed to affect a specific entity.
|
|
|
|
|
|
/// For actions see <see cref="ActionBlockerSystem"/>
|
|
|
|
|
|
/// </summary>
|
2020-12-20 04:31:04 +01:00
|
|
|
|
[UsedImplicitly]
|
2020-06-25 15:52:24 +02:00
|
|
|
|
public class EffectBlockerSystem : EntitySystem
|
|
|
|
|
|
{
|
2021-09-28 11:47:41 +02:00
|
|
|
|
// TODO: Make these methods not static. Maybe move them to their relevant EntitySystems?
|
|
|
|
|
|
// TODO: Add EntityUid overloads.
|
|
|
|
|
|
|
2020-06-25 15:52:24 +02:00
|
|
|
|
public static bool CanFall(IEntity entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
var canFall = true;
|
2020-12-20 04:31:04 +01:00
|
|
|
|
|
2020-06-25 15:52:24 +02:00
|
|
|
|
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
|
|
|
|
|
{
|
|
|
|
|
|
canFall &= blocker.CanFall(); // Sets var to false if false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return canFall;
|
|
|
|
|
|
}
|
2020-07-11 16:49:54 -05:00
|
|
|
|
|
|
|
|
|
|
public static bool CanSlip(IEntity entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
var canSlip = true;
|
2020-12-20 04:31:04 +01:00
|
|
|
|
|
2020-07-11 16:49:54 -05:00
|
|
|
|
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
|
|
|
|
|
{
|
|
|
|
|
|
canSlip &= blocker.CanSlip(); // Sets var to false if false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return canSlip;
|
|
|
|
|
|
}
|
2020-06-25 15:52:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|