Add EffectBlockerExtensions
This commit is contained in:
@@ -8,6 +8,7 @@ using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using Content.Shared.GameObjects.Components.Buckle;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Content.Shared.Utility;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Server.Interfaces.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Content.Shared.Interfaces;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Movement
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using Content.Shared.GameObjects.Components.Strap;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.ComponentDependencies;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JetBrains.Annotations;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
@@ -15,9 +16,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canMove = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canMove &= blockers.CanMove(); // Sets var to false if false
|
||||
canMove &= blocker.CanMove(); // Sets var to false if false
|
||||
}
|
||||
|
||||
return canMove;
|
||||
@@ -27,9 +28,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canInteract = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canInteract &= blockers.CanInteract();
|
||||
canInteract &= blocker.CanInteract();
|
||||
}
|
||||
|
||||
return canInteract;
|
||||
@@ -39,9 +40,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canUse = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canUse &= blockers.CanUse();
|
||||
canUse &= blocker.CanUse();
|
||||
}
|
||||
|
||||
return canUse;
|
||||
@@ -51,9 +52,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canThrow = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canThrow &= blockers.CanThrow();
|
||||
canThrow &= blocker.CanThrow();
|
||||
}
|
||||
|
||||
return canThrow;
|
||||
@@ -63,9 +64,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canSpeak = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canSpeak &= blockers.CanSpeak();
|
||||
canSpeak &= blocker.CanSpeak();
|
||||
}
|
||||
|
||||
return canSpeak;
|
||||
@@ -75,9 +76,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canDrop = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canDrop &= blockers.CanDrop();
|
||||
canDrop &= blocker.CanDrop();
|
||||
}
|
||||
|
||||
return canDrop;
|
||||
@@ -87,9 +88,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canPickup = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canPickup &= blockers.CanPickup();
|
||||
canPickup &= blocker.CanPickup();
|
||||
}
|
||||
|
||||
return canPickup;
|
||||
@@ -99,9 +100,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canEmote = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canEmote &= blockers.CanEmote();
|
||||
canEmote &= blocker.CanEmote();
|
||||
}
|
||||
|
||||
return canEmote;
|
||||
@@ -111,9 +112,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canAttack = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canAttack &= blockers.CanAttack();
|
||||
canAttack &= blocker.CanAttack();
|
||||
}
|
||||
|
||||
return canAttack;
|
||||
@@ -123,9 +124,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canEquip = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canEquip &= blockers.CanEquip();
|
||||
canEquip &= blocker.CanEquip();
|
||||
}
|
||||
|
||||
return canEquip;
|
||||
@@ -135,9 +136,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canUnequip = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canUnequip &= blockers.CanUnequip();
|
||||
canUnequip &= blocker.CanUnequip();
|
||||
}
|
||||
|
||||
return canUnequip;
|
||||
@@ -147,9 +148,9 @@ namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
var canChangeDirection = true;
|
||||
|
||||
foreach (var blockers in entity.GetAllComponents<IActionBlocker>())
|
||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
||||
{
|
||||
canChangeDirection &= blockers.CanChangeDirection();
|
||||
canChangeDirection &= blocker.CanChangeDirection();
|
||||
}
|
||||
|
||||
return canChangeDirection;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems.ActionBlocker
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface gives components the ability to block certain actions from
|
||||
@@ -34,4 +36,4 @@
|
||||
|
||||
bool CanSweat() => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,21 @@
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems
|
||||
namespace Content.Shared.GameObjects.EntitySystems.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;
|
||||
}
|
||||
|
||||
/// <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
|
||||
@@ -34,6 +27,7 @@ namespace Content.Shared.GameObjects.EntitySystems
|
||||
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
|
||||
@@ -0,0 +1,14 @@
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems.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;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user