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.Doors.Components;
|
||||
using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -66,6 +67,7 @@ public abstract class SharedMagicSystem : EntitySystem
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly TurfSystem _turf = default!;
|
||||
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
||||
[Dependency] private readonly ExamineSystemShared _examine= default!;
|
||||
|
||||
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
|
||||
|
||||
@@ -399,22 +401,30 @@ public abstract class SharedMagicSystem : EntitySystem
|
||||
#endregion
|
||||
#region Knock Spells
|
||||
/// <summary>
|
||||
/// Opens all doors and locks within range
|
||||
/// Opens all doors and locks within range.
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
private void OnKnockSpell(KnockSpellEvent args)
|
||||
{
|
||||
if (args.Handled || !PassesSpellPrerequisites(args.Action, args.Performer))
|
||||
return;
|
||||
|
||||
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.
|
||||
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;
|
||||
|
||||
if (TryComp<DoorBoltComponent>(target, out var doorBoltComp) && doorBoltComp.BoltsDown)
|
||||
@@ -424,7 +434,7 @@ public abstract class SharedMagicSystem : EntitySystem
|
||||
_door.StartOpening(target);
|
||||
|
||||
if (TryComp<LockComponent>(target, out var lockComp) && lockComp.Locked)
|
||||
_lock.Unlock(target, args.Performer, lockComp);
|
||||
_lock.Unlock(target, performer, lockComp);
|
||||
}
|
||||
}
|
||||
// End Knock Spells
|
||||
|
||||
Reference in New Issue
Block a user