Files
OldThink/Content.Shared/ActionBlocker/ActionBlockerSystem.cs

118 lines
2.9 KiB
C#
Raw Normal View History

using Content.Shared.Body.Events;
using Content.Shared.DragDrop;
2021-06-09 22:19:39 +02:00
using Content.Shared.Emoting;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.Movement;
2021-06-09 22:19:39 +02:00
using Content.Shared.Speech;
using Content.Shared.Throwing;
2020-12-20 04:31:04 +01:00
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
2020-12-20 04:26:21 +01:00
2021-06-09 22:19:39 +02:00
namespace Content.Shared.ActionBlocker
2020-12-20 04:26:21 +01:00
{
/// <summary>
/// Utility methods to check if a specific entity is allowed to perform an action.
/// </summary>
[UsedImplicitly]
public class ActionBlockerSystem : EntitySystem
{
public bool CanMove(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new MovementAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanInteract(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new InteractionAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
2020-12-20 04:26:21 +01:00
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanUse(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new UseAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
2020-12-20 04:26:21 +01:00
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanThrow(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new ThrowAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanSpeak(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new SpeakAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
2020-12-20 04:26:21 +01:00
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanDrop(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new DropAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanPickup(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new PickupAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanEmote(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new EmoteAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
2020-12-20 04:26:21 +01:00
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanAttack(EntityUid uid, EntityUid? target = null)
2020-12-20 04:26:21 +01:00
{
var ev = new AttackAttemptEvent(uid, target);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanChangeDirection(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new ChangeDirectionAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanShiver(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new ShiverAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
public bool CanSweat(EntityUid uid)
2020-12-20 04:26:21 +01:00
{
var ev = new SweatAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
2020-12-20 04:26:21 +01:00
}
}
}