Re-organize all projects (#4166)
This commit is contained in:
18
Content.Shared/EffectBlocker/EffectBlockerExtensions.cs
Normal file
18
Content.Shared/EffectBlocker/EffectBlockerExtensions.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#nullable enable
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.EffectBlocker
|
||||
{
|
||||
public static class EffectBlockerExtensions
|
||||
{
|
||||
public static bool CanFall(this IEntity entity)
|
||||
{
|
||||
return EffectBlockerSystem.CanFall(entity);
|
||||
}
|
||||
|
||||
public static bool CanSlip(this IEntity entity)
|
||||
{
|
||||
return EffectBlockerSystem.CanSlip(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Content.Shared/EffectBlocker/EffectBlockerSystem.cs
Normal file
39
Content.Shared/EffectBlocker/EffectBlockerSystem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
#nullable enable
|
||||
using Content.Shared.ActionBlocker;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.EffectBlocker
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility methods to check if an effect is allowed to affect a specific entity.
|
||||
/// For actions see <see cref="ActionBlockerSystem"/>
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class EffectBlockerSystem : EntitySystem
|
||||
{
|
||||
public static bool CanFall(IEntity entity)
|
||||
{
|
||||
var canFall = true;
|
||||
|
||||
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
||||
{
|
||||
canFall &= blocker.CanFall(); // Sets var to false if false
|
||||
}
|
||||
|
||||
return canFall;
|
||||
}
|
||||
|
||||
public static bool CanSlip(IEntity entity)
|
||||
{
|
||||
var canSlip = true;
|
||||
|
||||
foreach (var blocker in entity.GetAllComponents<IEffectBlocker>())
|
||||
{
|
||||
canSlip &= blocker.CanSlip(); // Sets var to false if false
|
||||
}
|
||||
|
||||
return canSlip;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Content.Shared/EffectBlocker/IEffectBlocker.cs
Normal file
15
Content.Shared/EffectBlocker/IEffectBlocker.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#nullable enable
|
||||
using Content.Shared.ActionBlocker;
|
||||
|
||||
namespace Content.Shared.EffectBlocker
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components the ability to block certain effects
|
||||
/// from affecting the owning entity. For actions see <see cref="IActionBlocker"/>
|
||||
/// </summary>
|
||||
public interface IEffectBlocker
|
||||
{
|
||||
bool CanFall() => true;
|
||||
bool CanSlip() => true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user