Minor Knock spell refactor + fix its obstruction check (#41447)
* refactor: remove isFirstTimepredicted for knock XAE * refactor: cleanups * refactor: do not count laser obstructions toward stuff that blocks Knock spell, project spell from artifact and not node * refactor: no method-events for knock-spells --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Shared.Charges.Systems;
|
|||||||
using Content.Shared.Coordinates.Helpers;
|
using Content.Shared.Coordinates.Helpers;
|
||||||
using Content.Shared.Doors.Components;
|
using Content.Shared.Doors.Components;
|
||||||
using Content.Shared.Doors.Systems;
|
using Content.Shared.Doors.Systems;
|
||||||
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
@@ -66,6 +67,7 @@ public abstract class SharedMagicSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||||
[Dependency] private readonly TurfSystem _turf = default!;
|
[Dependency] private readonly TurfSystem _turf = default!;
|
||||||
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
||||||
|
[Dependency] private readonly ExamineSystemShared _examine= default!;
|
||||||
|
|
||||||
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
|
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
|
||||||
|
|
||||||
@@ -399,22 +401,30 @@ public abstract class SharedMagicSystem : EntitySystem
|
|||||||
#endregion
|
#endregion
|
||||||
#region Knock Spells
|
#region Knock Spells
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens all doors and locks within range
|
/// Opens all doors and locks within range.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args"></param>
|
|
||||||
private void OnKnockSpell(KnockSpellEvent args)
|
private void OnKnockSpell(KnockSpellEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled || !PassesSpellPrerequisites(args.Action, args.Performer))
|
if (args.Handled || !PassesSpellPrerequisites(args.Action, args.Performer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
Knock(args.Performer, args.Range);
|
||||||
|
}
|
||||||
|
|
||||||
var transform = Transform(args.Performer);
|
/// <summary>
|
||||||
|
/// Opens all doors and locks within range.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="performer">Performer of spell. </param>
|
||||||
|
/// <param name="range">Radius around <see cref="performer"/> in which all doors and locks should be opened.</param>
|
||||||
|
public void Knock(EntityUid performer, float range)
|
||||||
|
{
|
||||||
|
var transform = Transform(performer);
|
||||||
|
|
||||||
// Look for doors and lockers, and don't open/unlock them if they're already opened/unlocked.
|
// Look for doors and lockers, and don't open/unlock them if they're already opened/unlocked.
|
||||||
foreach (var target in _lookup.GetEntitiesInRange(_transform.GetMapCoordinates(args.Performer, transform), args.Range, flags: LookupFlags.Dynamic | LookupFlags.Static))
|
foreach (var target in _lookup.GetEntitiesInRange(_transform.GetMapCoordinates(performer, transform), range, flags: LookupFlags.Dynamic | LookupFlags.Static))
|
||||||
{
|
{
|
||||||
if (!_interaction.InRangeUnobstructed(args.Performer, target, range: 0, collisionMask: CollisionGroup.Opaque))
|
if (!_examine.InRangeUnOccluded(performer, target, range: 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (TryComp<DoorBoltComponent>(target, out var doorBoltComp) && doorBoltComp.BoltsDown)
|
if (TryComp<DoorBoltComponent>(target, out var doorBoltComp) && doorBoltComp.BoltsDown)
|
||||||
@@ -424,7 +434,7 @@ public abstract class SharedMagicSystem : EntitySystem
|
|||||||
_door.StartOpening(target);
|
_door.StartOpening(target);
|
||||||
|
|
||||||
if (TryComp<LockComponent>(target, out var lockComp) && lockComp.Locked)
|
if (TryComp<LockComponent>(target, out var lockComp) && lockComp.Locked)
|
||||||
_lock.Unlock(target, args.Performer, lockComp);
|
_lock.Unlock(target, performer, lockComp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End Knock Spells
|
// End Knock Spells
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Content.Shared.Magic.Events;
|
using Content.Shared.Magic;
|
||||||
using Content.Shared.Xenoarchaeology.Artifact.XAE.Components;
|
using Content.Shared.Xenoarchaeology.Artifact.XAE.Components;
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
namespace Content.Shared.Xenoarchaeology.Artifact.XAE;
|
namespace Content.Shared.Xenoarchaeology.Artifact.XAE;
|
||||||
|
|
||||||
@@ -9,19 +8,10 @@ namespace Content.Shared.Xenoarchaeology.Artifact.XAE;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class XAEKnockSystem : BaseXAESystem<XAEKnockComponent>
|
public sealed class XAEKnockSystem : BaseXAESystem<XAEKnockComponent>
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly SharedMagicSystem _magic = default!;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OnActivated(Entity<XAEKnockComponent> ent, ref XenoArtifactNodeActivatedEvent args)
|
protected override void OnActivated(Entity<XAEKnockComponent> ent, ref XenoArtifactNodeActivatedEvent args)
|
||||||
{
|
{
|
||||||
if (!_timing.IsFirstTimePredicted)
|
_magic.Knock(args.Artifact, ent.Comp.KnockRange);
|
||||||
return;
|
|
||||||
|
|
||||||
var ev = new KnockSpellEvent
|
|
||||||
{
|
|
||||||
Performer = ent.Owner,
|
|
||||||
Range = ent.Comp.KnockRange
|
|
||||||
};
|
|
||||||
RaiseLocalEvent(ev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user