-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Shadow shackles can now be removed
- Loading branch information
Showing
10 changed files
with
97 additions
and
77 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Content.Server/WhiteDream/BloodCult/Items/BaseAura/BaseAuraSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Content.Server.Chat.Systems; | ||
using Content.Shared.WhiteDream.BloodCult.Items.BaseAura; | ||
using Content.Shared.WhiteDream.BloodCult.Spells; | ||
|
||
namespace Content.Server.WhiteDream.BloodCult.Items.BaseAura; | ||
|
||
public abstract class BaseAuraSystem<T> : EntitySystem where T : BaseAuraComponent | ||
{ | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<T, SpeakOnAuraUseEvent>(OnAuraUse); | ||
} | ||
|
||
private void OnAuraUse(EntityUid uid, T component, SpeakOnAuraUseEvent args) | ||
{ | ||
// TODO: The charge of the aura spell should be spent here | ||
if (component.Speech != null) | ||
_chat.TrySendInGameICMessage(args.User, component.Speech, component.ChatType, false); | ||
} | ||
} |
66 changes: 7 additions & 59 deletions
66
Content.Server/WhiteDream/BloodCult/Items/ShadowShacklesAura/ShadowShacklesAuraSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,25 @@ | ||
using System.Linq; | ||
using Content.Server.Chat.Systems; | ||
using Content.Server.Cuffs; | ||
using Content.Server.DoAfter; | ||
using Content.Shared.Cuffs.Components; | ||
using Content.Shared.DoAfter; | ||
using Content.Shared.Interaction; | ||
using Content.Server.WhiteDream.BloodCult.Items.BaseAura; | ||
using Content.Shared.Speech.Muting; | ||
using Content.Shared.StatusEffect; | ||
using Content.Shared.Weapons.Melee.Events; | ||
using Content.Shared.WhiteDream.BloodCult.BloodCultist; | ||
using Content.Shared.WhiteDream.BloodCult.Spells; | ||
using Robust.Server.GameObjects; | ||
using Content.Shared.WhiteDream.BloodCult.Items.ShadowShacklesAura; | ||
using Robust.Shared.Containers; | ||
|
||
namespace Content.Server.WhiteDream.BloodCult.Items.ShadowShacklesAura; | ||
|
||
public sealed class ShadowShacklesAuraSystem : EntitySystem | ||
public sealed class ShadowShacklesAuraSystem : BaseAuraSystem<ShadowShacklesAuraComponent> | ||
{ | ||
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!; | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
[Dependency] private readonly TransformSystem _transform = default!; | ||
[Dependency] private readonly CuffableSystem _cuffable = default!; | ||
[Dependency] private readonly DoAfterSystem _doAfter = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ShadowShacklesAuraComponent, MeleeHitEvent>(OnMeleeHit); | ||
SubscribeLocalEvent<ShadowShacklesAuraComponent, ShadowShacklesDoAfterEvent>(OnDoAfter); | ||
SubscribeLocalEvent<ShadowShacklesAuraComponent, EntRemovedFromContainerMessage>(OnShackles); | ||
} | ||
|
||
private void OnMeleeHit(EntityUid uid, ShadowShacklesAuraComponent component, MeleeHitEvent args) | ||
private void OnShackles(EntityUid uid, ShadowShacklesAuraComponent component, EntRemovedFromContainerMessage args) | ||
{ | ||
if (!args.HitEntities.Any()) | ||
return; | ||
|
||
var target = args.HitEntities.First(); | ||
if (uid == target || HasComp<BloodCultistComponent>(target) || !HasComp<CuffableComponent>(target)) | ||
return; | ||
|
||
if (component.Speech != null) | ||
_chat.TrySendInGameICMessage(args.User, component.Speech, component.ChatType, false); | ||
|
||
var doAfterArgs = new DoAfterArgs( | ||
EntityManager, | ||
args.User, | ||
component.Delay, | ||
new ShadowShacklesDoAfterEvent(), | ||
uid, | ||
target, | ||
uid) | ||
{ | ||
DistanceThreshold = SharedInteractionSystem.InteractionRange, | ||
BreakOnDamage = true, | ||
BreakOnMove = true, | ||
}; | ||
|
||
_doAfter.TryStartDoAfter(doAfterArgs, out _); | ||
} | ||
|
||
private void OnDoAfter(EntityUid uid, ShadowShacklesAuraComponent component, ShadowShacklesDoAfterEvent args) | ||
{ | ||
if (!args.Target.HasValue) | ||
return; | ||
|
||
var shackles = Spawn(component.ShacklesProto, _transform.GetMapCoordinates(args.User)); | ||
if (!_cuffable.TryAddNewCuffs(args.Target.Value, args.User, shackles)) | ||
{ | ||
QueueDel(shackles); | ||
return; | ||
} | ||
|
||
_statusEffects.TryAddStatusEffect<MutedComponent>(args.Target.Value, "Muted", component.MuteDuration, true); | ||
QueueDel(uid); | ||
_statusEffects.TryAddStatusEffect<MutedComponent>(component.Target, "Muted", component.MuteDuration, true); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
Content.Server/WhiteDream/BloodCult/Items/StunAura/StunAuraComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dCult/Items/BaseAura/BaseAuraComponent.cs → ...dCult/Items/BaseAura/BaseAuraComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...nt.Shared/WhiteDream/BloodCult/Items/ShadowShacklesAura/SharedShadowShacklesAuraSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Linq; | ||
using Content.Shared.Cuffs; | ||
using Content.Shared.Cuffs.Components; | ||
using Content.Shared.Weapons.Melee.Events; | ||
using Content.Shared.WhiteDream.BloodCult.BloodCultist; | ||
using Content.Shared.WhiteDream.BloodCult.Spells; | ||
using Robust.Shared.Containers; | ||
|
||
namespace Content.Shared.WhiteDream.BloodCult.Items.ShadowShacklesAura; | ||
|
||
public sealed class SharedShadowShacklesAuraSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedTransformSystem _transform = default!; | ||
[Dependency] private readonly SharedCuffableSystem _cuffable = default!; | ||
[Dependency] private readonly SharedContainerSystem _container = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ShadowShacklesAuraComponent, MeleeHitEvent>(OnMeleeHit); | ||
SubscribeLocalEvent<ShadowShacklesAuraComponent, ComponentInit>(OnInit); | ||
} | ||
|
||
private void OnMeleeHit(EntityUid uid, ShadowShacklesAuraComponent component, MeleeHitEvent args) | ||
{ | ||
if (!args.HitEntities.Any()) | ||
return; | ||
|
||
component.Target = args.HitEntities.First(); | ||
if (uid == component.Target || HasComp<BloodCultistComponent>(component.Target) || !HasComp<CuffableComponent>(component.Target)) | ||
return; | ||
|
||
if (_cuffable.TryCuffing(args.User, component.Target, component.Shackles, distanceThreshold:component.DistanceThreshold)) | ||
RaiseLocalEvent(uid, new SpeakOnAuraUseEvent(args.User)); | ||
} | ||
|
||
private void OnInit(EntityUid uid, ShadowShacklesAuraComponent component, ComponentInit args) | ||
{ | ||
var container = _container.EnsureContainer<Container>(uid, "shackles"); | ||
component.Shackles = Spawn(component.ShacklesProto, _transform.GetMapCoordinates(uid)); | ||
_container.Insert(component.Shackles, container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters