2024-07-28 16:54:32 +00:00
|
|
|
using Content.Shared._White.Chaplain;
|
2024-03-22 17:23:33 +09:00
|
|
|
using Content.Shared._White.Cult.Components;
|
|
|
|
|
using Content.Shared.Actions;
|
2024-03-24 18:43:51 +09:00
|
|
|
using Content.Shared.Examine;
|
2024-03-22 17:23:33 +09:00
|
|
|
using Content.Shared.Hands;
|
2024-07-28 16:54:32 +00:00
|
|
|
using Content.Shared.Projectiles;
|
2024-03-22 17:23:33 +09:00
|
|
|
using Content.Shared.StatusEffect;
|
|
|
|
|
using Content.Shared.Stunnable;
|
|
|
|
|
using Content.Shared.Throwing;
|
|
|
|
|
using Robust.Shared.Audio.Systems;
|
|
|
|
|
using Robust.Shared.Network;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared._White.Cult.Systems;
|
|
|
|
|
|
|
|
|
|
public sealed class BloodSpearSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
|
|
|
|
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
|
|
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
2024-07-28 16:54:32 +00:00
|
|
|
[Dependency] private readonly HolyWeaponSystem _holy = default!;
|
2024-03-22 17:23:33 +09:00
|
|
|
[Dependency] private readonly INetManager _net = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<BloodSpearComponent, ComponentRemove>(OnRemove);
|
|
|
|
|
SubscribeLocalEvent<BloodSpearComponent, GotEquippedHandEvent>(OnEquip);
|
2024-07-28 16:54:32 +00:00
|
|
|
SubscribeLocalEvent<BloodSpearComponent, ThrowDoHitEvent>(OnThrowDoHit,
|
|
|
|
|
before: new[] {typeof(SharedProjectileSystem)});
|
2024-03-24 18:43:51 +09:00
|
|
|
SubscribeLocalEvent<BloodSpearComponent, ExaminedEvent>(OnExamine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnExamine(Entity<BloodSpearComponent> ent, ref ExaminedEvent args)
|
|
|
|
|
{
|
|
|
|
|
args.PushMarkup(Loc.GetString("blood-spear-component-extra-desc"));
|
2024-03-22 17:23:33 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnThrowDoHit(Entity<BloodSpearComponent> ent, ref ThrowDoHitEvent args)
|
|
|
|
|
{
|
2024-07-28 16:54:32 +00:00
|
|
|
if (HasComp<CultistComponent>(args.Target) || HasComp<ConstructComponent>(args.Target))
|
|
|
|
|
{
|
|
|
|
|
args.Handled = true;
|
2024-03-22 17:23:33 +09:00
|
|
|
return;
|
2024-07-28 16:54:32 +00:00
|
|
|
}
|
2024-03-22 17:23:33 +09:00
|
|
|
|
2024-07-28 16:54:32 +00:00
|
|
|
if (!TryComp(args.Target, out StatusEffectsComponent? status))
|
2024-03-22 17:23:33 +09:00
|
|
|
return;
|
|
|
|
|
|
2024-07-28 16:54:32 +00:00
|
|
|
if (!_holy.IsHoldingHolyWeapon(args.Target))
|
|
|
|
|
{
|
2024-08-03 15:23:46 +00:00
|
|
|
if(!_stunSystem.TryParalyze(args.Target, TimeSpan.FromSeconds(5), true, status))
|
2024-07-28 16:54:32 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-22 17:23:33 +09:00
|
|
|
if (_net.IsClient)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_audio.PlayPvs(ent.Comp.ShatterSound, Transform(ent).Coordinates);
|
|
|
|
|
QueueDel(ent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEquip(Entity<BloodSpearComponent> ent, ref GotEquippedHandEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!TryComp(args.User, out CultistComponent? cultist))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Entity<CultistComponent> user = (args.User, cultist);
|
|
|
|
|
|
|
|
|
|
if (cultist.BloodSpear == ent && ent.Comp.User == user)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (ent.Comp.User != null)
|
|
|
|
|
DetachSpearFromUser(ent.Comp.User.Value);
|
|
|
|
|
DetachSpearFromUser(user);
|
|
|
|
|
AttachSpearToUser(user, ent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DetachSpearFromUser(Entity<CultistComponent> user)
|
|
|
|
|
{
|
|
|
|
|
_actionsSystem.RemoveAction(user, user.Comp.BloodSpearActionEntity);
|
|
|
|
|
user.Comp.BloodSpearActionEntity = null;
|
|
|
|
|
if (user.Comp.BloodSpear != null)
|
|
|
|
|
user.Comp.BloodSpear.Value.Comp.User = null;
|
|
|
|
|
user.Comp.BloodSpear = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AttachSpearToUser(Entity<CultistComponent> user, Entity<BloodSpearComponent> spear)
|
|
|
|
|
{
|
|
|
|
|
_actionsSystem.AddAction(user, ref user.Comp.BloodSpearActionEntity, spear.Comp.Action);
|
|
|
|
|
user.Comp.BloodSpear = spear;
|
|
|
|
|
spear.Comp.User = user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRemove(Entity<BloodSpearComponent> ent, ref ComponentRemove args)
|
|
|
|
|
{
|
|
|
|
|
if (ent.Comp.User != null)
|
|
|
|
|
DetachSpearFromUser(ent.Comp.User.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|