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:
metalgearsloth
2021-10-21 13:03:14 +11:00
committed by GitHub
parent 339982d05b
commit 7beb363285
20 changed files with 196 additions and 437 deletions

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.ActionBlocker;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.MobState.State;
@@ -24,7 +23,7 @@ namespace Content.Shared.MobState.Components
[RegisterComponent]
[ComponentReference(typeof(IMobStateComponent))]
[NetworkedComponent()]
public class MobStateComponent : Component, IMobStateComponent, IActionBlocker
public class MobStateComponent : Component, IMobStateComponent
{
public override string Name => "MobState";
@@ -318,56 +317,6 @@ namespace Content.Shared.MobState.Components
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]

View File

@@ -1,10 +1,15 @@
using Content.Shared.Damage;
using Content.Shared.DragDrop;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.MobState.Components;
using Content.Shared.MobState.State;
using Content.Shared.Movement;
using Content.Shared.Pulling.Events;
using Content.Shared.Speech;
using Content.Shared.Standing;
using Content.Shared.Throwing;
using Robust.Shared.GameObjects;
namespace Content.Shared.MobState.EntitySystems
@@ -16,6 +21,15 @@ namespace Content.Shared.MobState.EntitySystems
base.Initialize();
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, DamageChangedEvent>(UpdateState);
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...
}
private void OnChangeDirectionAttempt(EntityUid uid, MobStateComponent component, ChangeDirectionAttemptEvent args)
#region ActionBlocker
private void CheckAct(EntityUid uid, MobStateComponent component, CancellableEntityEventArgs args)
{
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)
{
if(component.IsIncapacitated())

View File

@@ -33,55 +33,5 @@ namespace Content.Shared.MobState.State
public virtual void ExitState(IEntity entity) { }
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;
}
}
}

View File

@@ -8,7 +8,7 @@ namespace Content.Shared.MobState.State
/// (i.e. Normal, Critical, Dead) and what effects to apply upon entering or
/// exiting the state.
/// </summary>
public interface IMobState : IActionBlocker
public interface IMobState
{
bool IsAlive();

View File

@@ -1,5 +1,4 @@
using Content.Shared.Alert;
using Content.Shared.Hands;
using Content.Shared.Standing;
using Robust.Shared.GameObjects;
@@ -35,55 +34,5 @@ namespace Content.Shared.MobState.State
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;
}
}
}

View File

@@ -43,65 +43,5 @@ namespace Content.Shared.MobState.State
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;
}
}
}

View File

@@ -21,55 +21,5 @@ namespace Content.Shared.MobState.State
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;
}
}
}