Deprecate a bunch of IActionBlocker (#4852)
* Deprecate IActionBlocker ChangeDirectionAttempt * Woops * Throw and interact * Deperacte speech * ActionBlocker in fucking shambles * CanEmote go byebye * CanAttack is GONE * IActionBlocker finally ded * DRY
This commit is contained in:
9
Content.Client/Cuffs/CuffableSystem.cs
Normal file
9
Content.Client/Cuffs/CuffableSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Content.Shared.Cuffs;
|
||||||
|
|
||||||
|
namespace Content.Client.Cuffs
|
||||||
|
{
|
||||||
|
public sealed class CuffableSystem : SharedCuffableSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ using Robust.Shared.Player;
|
|||||||
namespace Content.Server.Cuffs
|
namespace Content.Server.Cuffs
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal sealed class CuffableSystem : SharedCuffableSystem
|
public sealed class CuffableSystem : SharedCuffableSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Content.Server.Storage.Components
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(IActivate))]
|
[ComponentReference(typeof(IActivate))]
|
||||||
[ComponentReference(typeof(IStorageComponent))]
|
[ComponentReference(typeof(IStorageComponent))]
|
||||||
public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IActionBlocker, IExAct
|
public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IExAct
|
||||||
{
|
{
|
||||||
public override string Name => "EntityStorage";
|
public override string Name => "EntityStorage";
|
||||||
|
|
||||||
|
|||||||
@@ -42,15 +42,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanInteract())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,15 +56,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanUse())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,15 +70,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanThrow())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,15 +84,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanSpeak())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,15 +98,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanDrop())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,15 +112,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanPickup())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,15 +126,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanEmote())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,15 +140,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanAttack())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,15 +154,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanEquip())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,15 +168,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in ev.Entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanUnequip())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Content.Shared.EffectBlocker;
|
|
||||||
|
|
||||||
namespace Content.Shared.ActionBlocker
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This interface gives components the ability to block certain actions from
|
|
||||||
/// being done by the owning entity. For effects see <see cref="IEffectBlocker"/>
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use events instead")]
|
|
||||||
public interface IActionBlocker
|
|
||||||
{
|
|
||||||
[Obsolete("Use InteractAttemptEvent instead")]
|
|
||||||
bool CanInteract() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use UseAttemptEvent instead")]
|
|
||||||
bool CanUse() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use ThrowAttemptEvent instead")]
|
|
||||||
bool CanThrow() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use SpeakAttemptEvent instead")]
|
|
||||||
bool CanSpeak() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use DropAttemptEvent instead")]
|
|
||||||
bool CanDrop() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use PickupAttemptEvent instead")]
|
|
||||||
bool CanPickup() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use EmoteAttemptEvent instead")]
|
|
||||||
bool CanEmote() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use AttackAttemptEvent instead")]
|
|
||||||
bool CanAttack() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use EquipAttemptEvent instead")]
|
|
||||||
bool CanEquip() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use UnequipAttemptEvent instead")]
|
|
||||||
bool CanUnequip() => true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ using Robust.Shared.ViewVariables;
|
|||||||
namespace Content.Shared.Climbing
|
namespace Content.Shared.Climbing
|
||||||
{
|
{
|
||||||
[NetworkedComponent()]
|
[NetworkedComponent()]
|
||||||
public abstract class SharedClimbingComponent : Component, IActionBlocker
|
public abstract class SharedClimbingComponent : Component
|
||||||
{
|
{
|
||||||
public sealed override string Name => "Climbing";
|
public sealed override string Name => "Climbing";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Content.Shared.Pulling.Components;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
@@ -10,24 +8,13 @@ using Robust.Shared.ViewVariables;
|
|||||||
namespace Content.Shared.Cuffs.Components
|
namespace Content.Shared.Cuffs.Components
|
||||||
{
|
{
|
||||||
[NetworkedComponent()]
|
[NetworkedComponent()]
|
||||||
public class SharedCuffableComponent : Component, IActionBlocker
|
public class SharedCuffableComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "Cuffable";
|
public override string Name => "Cuffable";
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool CanStillInteract { get; set; } = true;
|
public bool CanStillInteract { get; set; } = true;
|
||||||
|
|
||||||
#region ActionBlockers
|
|
||||||
|
|
||||||
bool IActionBlocker.CanInteract() => CanStillInteract;
|
|
||||||
bool IActionBlocker.CanUse() => CanStillInteract;
|
|
||||||
bool IActionBlocker.CanPickup() => CanStillInteract;
|
|
||||||
bool IActionBlocker.CanDrop() => CanStillInteract;
|
|
||||||
bool IActionBlocker.CanAttack() => CanStillInteract;
|
|
||||||
bool IActionBlocker.CanEquip() => CanStillInteract;
|
|
||||||
bool IActionBlocker.CanUnequip() => CanStillInteract;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
protected sealed class CuffableComponentState : ComponentState
|
protected sealed class CuffableComponentState : ComponentState
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
using Content.Shared.Cuffs.Components;
|
using Content.Shared.Cuffs.Components;
|
||||||
|
using Content.Shared.DragDrop;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
|
using Content.Shared.Inventory.Events;
|
||||||
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Movement;
|
using Content.Shared.Movement;
|
||||||
using Content.Shared.Pulling.Components;
|
using Content.Shared.Pulling.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -12,6 +16,13 @@ namespace Content.Shared.Cuffs
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<SharedCuffableComponent, StopPullingEvent>(HandleStopPull);
|
SubscribeLocalEvent<SharedCuffableComponent, StopPullingEvent>(HandleStopPull);
|
||||||
SubscribeLocalEvent<SharedCuffableComponent, MovementAttemptEvent>(HandleMoveAttempt);
|
SubscribeLocalEvent<SharedCuffableComponent, MovementAttemptEvent>(HandleMoveAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, UseAttemptEvent>(OnUseAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, InteractionAttemptEvent>(OnInteractAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, EquipAttemptEvent>(OnEquipAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, UnequipAttemptEvent>(OnUnequipAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, DropAttemptEvent>(OnDropAttempt);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, PickupAttemptEvent>(OnPickupAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleMoveAttempt(EntityUid uid, SharedCuffableComponent component, MovementAttemptEvent args)
|
private void HandleMoveAttempt(EntityUid uid, SharedCuffableComponent component, MovementAttemptEvent args)
|
||||||
@@ -31,5 +42,50 @@ namespace Content.Shared.Cuffs
|
|||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region ActionBlocker
|
||||||
|
|
||||||
|
private void CheckAct(EntityUid uid, SharedCuffableComponent component, CancellableEntityEventArgs args)
|
||||||
|
{
|
||||||
|
if (!component.CanStillInteract)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUseAttempt(EntityUid uid, SharedCuffableComponent component, UseAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInteractAttempt(EntityUid uid, SharedCuffableComponent component, InteractionAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEquipAttempt(EntityUid uid, SharedCuffableComponent component, EquipAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUnequipAttempt(EntityUid uid, SharedCuffableComponent component, UnequipAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAttackAttempt(EntityUid uid, SharedCuffableComponent component, AttackAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDropAttempt(EntityUid uid, SharedCuffableComponent component, DropAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPickupAttempt(EntityUid uid, SharedCuffableComponent component, PickupAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace Content.Shared.EffectBlocker
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This interface gives components the ability to block certain effects
|
/// This interface gives components the ability to block certain effects
|
||||||
/// from affecting the owning entity. For actions see <see cref="IActionBlocker"/>
|
/// from affecting the owning entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IEffectBlocker
|
public interface IEffectBlocker
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
@@ -11,7 +9,7 @@ using Robust.Shared.ViewVariables;
|
|||||||
namespace Content.Shared.Ghost
|
namespace Content.Shared.Ghost
|
||||||
{
|
{
|
||||||
[NetworkedComponent()]
|
[NetworkedComponent()]
|
||||||
public class SharedGhostComponent : Component, IActionBlocker
|
public class SharedGhostComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "Ghost";
|
public override string Name => "Ghost";
|
||||||
|
|
||||||
@@ -66,14 +64,6 @@ namespace Content.Shared.Ghost
|
|||||||
CanReturnToBody = state.CanReturnToBody;
|
CanReturnToBody = state.CanReturnToBody;
|
||||||
CanGhostInteract = state.CanGhostInteract;
|
CanGhostInteract = state.CanGhostInteract;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanInteract() => CanGhostInteract;
|
|
||||||
public bool CanUse() => CanGhostInteract;
|
|
||||||
public bool CanThrow() => CanGhostInteract;
|
|
||||||
public bool CanDrop() => CanGhostInteract;
|
|
||||||
public bool CanPickup() => CanGhostInteract;
|
|
||||||
public bool CanEmote() => false;
|
|
||||||
public bool CanAttack() => CanGhostInteract;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Content.Shared.DragDrop;
|
||||||
|
using Content.Shared.Emoting;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
|
using Content.Shared.Item;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
@@ -7,6 +11,51 @@ namespace Content.Shared.Ghost
|
|||||||
{
|
{
|
||||||
public abstract class SharedGhostSystem : EntitySystem
|
public abstract class SharedGhostSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<SharedGhostComponent, UseAttemptEvent>(OnUseAttempt);
|
||||||
|
SubscribeLocalEvent<SharedGhostComponent, InteractionAttemptEvent>(OnInteractAttempt);
|
||||||
|
SubscribeLocalEvent<SharedGhostComponent, EmoteAttemptEvent>(OnEmoteAttempt);
|
||||||
|
SubscribeLocalEvent<SharedGhostComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||||
|
SubscribeLocalEvent<SharedGhostComponent, DropAttemptEvent>(OnDropAttempt);
|
||||||
|
SubscribeLocalEvent<SharedGhostComponent, PickupAttemptEvent>(OnPickupAttempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUseAttempt(EntityUid uid, SharedGhostComponent component, UseAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (!component.CanGhostInteract)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInteractAttempt(EntityUid uid, SharedGhostComponent component, InteractionAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (!component.CanGhostInteract)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEmoteAttempt(EntityUid uid, SharedGhostComponent component, EmoteAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAttackAttempt(EntityUid uid, SharedGhostComponent component, AttackAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDropAttempt(EntityUid uid, SharedGhostComponent component, DropAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (!component.CanGhostInteract)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPickupAttempt(EntityUid uid, SharedGhostComponent component, PickupAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (!component.CanGhostInteract)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn)
|
public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn)
|
||||||
{
|
{
|
||||||
if (component.CanReturnToBody == canReturn)
|
if (component.CanReturnToBody == canReturn)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.MobState.State;
|
using Content.Shared.MobState.State;
|
||||||
@@ -24,7 +23,7 @@ namespace Content.Shared.MobState.Components
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(IMobStateComponent))]
|
[ComponentReference(typeof(IMobStateComponent))]
|
||||||
[NetworkedComponent()]
|
[NetworkedComponent()]
|
||||||
public class MobStateComponent : Component, IMobStateComponent, IActionBlocker
|
public class MobStateComponent : Component, IMobStateComponent
|
||||||
{
|
{
|
||||||
public override string Name => "MobState";
|
public override string Name => "MobState";
|
||||||
|
|
||||||
@@ -318,56 +317,6 @@ namespace Content.Shared.MobState.Components
|
|||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IActionBlocker.CanInteract()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanInteract() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanUse()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanUse() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanThrow()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanThrow() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanSpeak()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanSpeak() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanDrop()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanDrop() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanPickup()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanPickup() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanEmote()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanEmote() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanAttack()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanAttack() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanEquip()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanEquip() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanUnequip()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanUnequip() ?? true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
|
using Content.Shared.Inventory.Events;
|
||||||
|
using Content.Shared.Item;
|
||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
using Content.Shared.MobState.State;
|
using Content.Shared.MobState.State;
|
||||||
using Content.Shared.Movement;
|
using Content.Shared.Movement;
|
||||||
using Content.Shared.Pulling.Events;
|
using Content.Shared.Pulling.Events;
|
||||||
|
using Content.Shared.Speech;
|
||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
|
using Content.Shared.Throwing;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
namespace Content.Shared.MobState.EntitySystems
|
namespace Content.Shared.MobState.EntitySystems
|
||||||
@@ -16,6 +21,15 @@ namespace Content.Shared.MobState.EntitySystems
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(OnChangeDirectionAttempt);
|
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(OnChangeDirectionAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, UseAttemptEvent>(OnUseAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, InteractionAttemptEvent>(OnInteractAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, ThrowAttemptEvent>(OnThrowAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, SpeakAttemptEvent>(OnSpeakAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, EquipAttemptEvent>(OnEquipAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, UnequipAttemptEvent>(OnUnequipAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, DropAttemptEvent>(OnDropAttempt);
|
||||||
|
SubscribeLocalEvent<MobStateComponent, PickupAttemptEvent>(OnPickupAttempt);
|
||||||
SubscribeLocalEvent<MobStateComponent, StartPullAttemptEvent>(OnStartPullAttempt);
|
SubscribeLocalEvent<MobStateComponent, StartPullAttemptEvent>(OnStartPullAttempt);
|
||||||
SubscribeLocalEvent<MobStateComponent, DamageChangedEvent>(UpdateState);
|
SubscribeLocalEvent<MobStateComponent, DamageChangedEvent>(UpdateState);
|
||||||
SubscribeLocalEvent<MobStateComponent, MovementAttemptEvent>(OnMoveAttempt);
|
SubscribeLocalEvent<MobStateComponent, MovementAttemptEvent>(OnMoveAttempt);
|
||||||
@@ -23,7 +37,9 @@ namespace Content.Shared.MobState.EntitySystems
|
|||||||
// Note that there's no check for Down attempts because if a mob's in crit or dead, they can be downed...
|
// Note that there's no check for Down attempts because if a mob's in crit or dead, they can be downed...
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnChangeDirectionAttempt(EntityUid uid, MobStateComponent component, ChangeDirectionAttemptEvent args)
|
#region ActionBlocker
|
||||||
|
|
||||||
|
private void CheckAct(EntityUid uid, MobStateComponent component, CancellableEntityEventArgs args)
|
||||||
{
|
{
|
||||||
switch (component.CurrentState)
|
switch (component.CurrentState)
|
||||||
{
|
{
|
||||||
@@ -34,6 +50,58 @@ namespace Content.Shared.MobState.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnChangeDirectionAttempt(EntityUid uid, MobStateComponent component, ChangeDirectionAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUseAttempt(EntityUid uid, MobStateComponent component, UseAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInteractAttempt(EntityUid uid, MobStateComponent component, InteractionAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnThrowAttempt(EntityUid uid, MobStateComponent component, ThrowAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEquipAttempt(EntityUid uid, MobStateComponent component, EquipAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnUnequipAttempt(EntityUid uid, MobStateComponent component, UnequipAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAttackAttempt(EntityUid uid, MobStateComponent component, AttackAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDropAttempt(EntityUid uid, MobStateComponent component, DropAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPickupAttempt(EntityUid uid, MobStateComponent component, PickupAttemptEvent args)
|
||||||
|
{
|
||||||
|
CheckAct(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void OnStartPullAttempt(EntityUid uid, MobStateComponent component, StartPullAttemptEvent args)
|
private void OnStartPullAttempt(EntityUid uid, MobStateComponent component, StartPullAttemptEvent args)
|
||||||
{
|
{
|
||||||
if(component.IsIncapacitated())
|
if(component.IsIncapacitated())
|
||||||
|
|||||||
@@ -33,55 +33,5 @@ namespace Content.Shared.MobState.State
|
|||||||
public virtual void ExitState(IEntity entity) { }
|
public virtual void ExitState(IEntity entity) { }
|
||||||
|
|
||||||
public virtual void UpdateState(IEntity entity, int threshold) { }
|
public virtual void UpdateState(IEntity entity, int threshold) { }
|
||||||
|
|
||||||
public virtual bool CanInteract()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanUse()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanThrow()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanSpeak()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanDrop()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanPickup()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanEmote()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanAttack()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanEquip()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanUnequip()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Content.Shared.MobState.State
|
|||||||
/// (i.e. Normal, Critical, Dead) and what effects to apply upon entering or
|
/// (i.e. Normal, Critical, Dead) and what effects to apply upon entering or
|
||||||
/// exiting the state.
|
/// exiting the state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMobState : IActionBlocker
|
public interface IMobState
|
||||||
{
|
{
|
||||||
bool IsAlive();
|
bool IsAlive();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Hands;
|
|
||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
@@ -35,55 +34,5 @@ namespace Content.Shared.MobState.State
|
|||||||
|
|
||||||
EntitySystem.Get<StandingStateSystem>().Stand(entity.Uid);
|
EntitySystem.Get<StandingStateSystem>().Stand(entity.Uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanInteract()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanThrow()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSpeak()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanDrop()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanPickup()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEmote()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanAttack()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEquip()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUnequip()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,65 +43,5 @@ namespace Content.Shared.MobState.State
|
|||||||
physics.CanCollide = true;
|
physics.CanCollide = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanInteract()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanThrow()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSpeak()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanDrop()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanPickup()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEmote()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanAttack()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEquip()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUnequip()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanShiver()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanSweat()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,55 +21,5 @@ namespace Content.Shared.MobState.State
|
|||||||
appearance.SetData(DamageStateVisuals.State, DamageState.Alive);
|
appearance.SetData(DamageStateVisuals.State, DamageState.Alive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanInteract()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanThrow()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSpeak()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanDrop()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanPickup()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEmote()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanAttack()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEquip()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUnequip()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ namespace Content.Shared.Speech
|
|||||||
/// Component required for entities to be able to speak.
|
/// Component required for entities to be able to speak.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class SharedSpeechComponent : Component, IActionBlocker
|
public class SharedSpeechComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "Speech";
|
public override string Name => "Speech";
|
||||||
|
|
||||||
@@ -25,7 +24,5 @@ namespace Content.Shared.Speech
|
|||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IActionBlocker.CanSpeak() => Enabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,13 @@ namespace Content.Shared.Speech
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<SpeakAttemptEvent>(OnSpeakAttempt);
|
SubscribeLocalEvent<SharedSpeechComponent, SpeakAttemptEvent>(OnSpeakAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSpeakAttempt(SpeakAttemptEvent ev)
|
private void OnSpeakAttempt(EntityUid uid, SharedSpeechComponent component, SpeakAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (!ev.Entity.HasComponent<SharedSpeechComponent>())
|
if (!component.Enabled)
|
||||||
{
|
args.Cancel();
|
||||||
ev.Cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user