Let entities attack their outermost container (#13406)
Closes https://github.com/space-wizards/space-station-14/issues/13405 closes https://github.com/space-wizards/space-station-14/issues/13403
This commit is contained in:
parent
f0429edbb1
commit
943495922a
|
|
@ -146,7 +146,8 @@ namespace Content.Shared.ActionBlocker
|
|||
|
||||
public bool CanAttack(EntityUid uid, EntityUid? target = null)
|
||||
{
|
||||
if (_container.IsEntityInContainer(uid))
|
||||
_container.TryGetOuterContainer(uid, Transform(uid), out var outerContainer);
|
||||
if (target != null && target != outerContainer?.Owner && _container.IsEntityInContainer(uid))
|
||||
{
|
||||
var containerEv = new CanAttackFromContainerEvent(uid, target);
|
||||
RaiseLocalEvent(uid, containerEv);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public abstract class SharedMechSystem : EntitySystem
|
|||
|
||||
SubscribeLocalEvent<MechPilotComponent, GetMeleeWeaponEvent>(OnGetMeleeWeapon);
|
||||
SubscribeLocalEvent<MechPilotComponent, CanAttackFromContainerEvent>(OnCanAttackFromContainer);
|
||||
SubscribeLocalEvent<MechPilotComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||
}
|
||||
|
||||
#region State Handling
|
||||
|
|
@ -451,6 +452,12 @@ public abstract class SharedMechSystem : EntitySystem
|
|||
args.CanAttack = true;
|
||||
}
|
||||
|
||||
private void OnAttackAttempt(EntityUid uid, MechPilotComponent component, AttackAttemptEvent args)
|
||||
{
|
||||
if (args.Target == component.Mech)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void UpdateAppearance(EntityUid uid, SharedMechComponent ? component = null, AppearanceComponent? appearance = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, ref appearance, false))
|
||||
|
|
|
|||
Loading…
Reference in New Issue