2021-11-11 16:10:57 -07:00
|
|
|
|
using Content.Shared.Body.Events;
|
|
|
|
|
|
using Content.Shared.DragDrop;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Emoting;
|
2021-06-19 10:03:24 +02:00
|
|
|
|
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;
|
2021-06-19 10:03:24 +02:00
|
|
|
|
using Content.Shared.Throwing;
|
2020-12-20 04:31:04 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
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
|
|
|
|
|
|
{
|
2021-11-09 13:15:55 +01:00
|
|
|
|
public bool CanMove(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:15:55 +01:00
|
|
|
|
var ev = new MovementAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 14:54:00 +01:00
|
|
|
|
public bool CanInteract(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 14:54:00 +01:00
|
|
|
|
var ev = new InteractionAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2020-12-20 04:26:21 +01:00
|
|
|
|
|
2021-06-19 10:03:24 +02:00
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:19:56 +01:00
|
|
|
|
public bool CanUse(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:19:56 +01:00
|
|
|
|
var ev = new UseAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2020-12-20 04:26:21 +01:00
|
|
|
|
|
2021-06-19 10:03:24 +02:00
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:20:55 +01:00
|
|
|
|
public bool CanThrow(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:20:55 +01:00
|
|
|
|
var ev = new ThrowAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:21:52 +01:00
|
|
|
|
public bool CanSpeak(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:21:52 +01:00
|
|
|
|
var ev = new SpeakAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2020-12-20 04:26:21 +01:00
|
|
|
|
|
2021-06-19 10:03:24 +02:00
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
2021-11-09 13:40:27 +01:00
|
|
|
|
|
2021-11-09 13:23:50 +01:00
|
|
|
|
public bool CanDrop(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:23:50 +01:00
|
|
|
|
var ev = new DropAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:43:39 +01:00
|
|
|
|
public bool CanPickup(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:43:39 +01:00
|
|
|
|
var ev = new PickupAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:41:24 +01:00
|
|
|
|
public bool CanEmote(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:41:24 +01:00
|
|
|
|
var ev = new EmoteAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2020-12-20 04:26:21 +01:00
|
|
|
|
|
2021-06-19 10:03:24 +02:00
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-04 01:22:28 -08:00
|
|
|
|
public bool CanAttack(EntityUid uid, EntityUid? target = null)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2022-01-04 01:22:28 -08:00
|
|
|
|
var ev = new AttackAttemptEvent(uid, target);
|
2021-11-09 13:40:27 +01:00
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:48:59 +01:00
|
|
|
|
public bool CanChangeDirection(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:48:59 +01:00
|
|
|
|
var ev = new ChangeDirectionAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:51:12 +01:00
|
|
|
|
public bool CanShiver(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:51:12 +01:00
|
|
|
|
var ev = new ShiverAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 13:52:27 +01:00
|
|
|
|
public bool CanSweat(EntityUid uid)
|
2020-12-20 04:26:21 +01:00
|
|
|
|
{
|
2021-11-09 13:52:27 +01:00
|
|
|
|
var ev = new SweatAttemptEvent(uid);
|
|
|
|
|
|
RaiseLocalEvent(uid, ev);
|
2021-06-19 10:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
return !ev.Cancelled;
|
2020-12-20 04:26:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|