Prevent Holoparasites from attacking their host (#6019)

This commit is contained in:
ShadowCommander
2022-01-04 01:22:28 -08:00
committed by GitHub
parent 5249ea057a
commit b335ef5e7f
5 changed files with 21 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -48,6 +49,8 @@ namespace Content.Server.Guardian
SubscribeLocalEvent<GuardianHostComponent, MoveEvent>(OnHostMove);
SubscribeLocalEvent<GuardianHostComponent, MobStateChangedEvent>(OnHostStateChange);
SubscribeLocalEvent<GuardianHostComponent, ComponentShutdown>(OnHostShutdown);
SubscribeLocalEvent<GuardianComponent, AttackAttemptEvent>(OnGuardianAttackAttempt);
}
private void OnGuardianUnplayer(EntityUid uid, GuardianComponent component, PlayerDetachedEvent args)
@@ -79,6 +82,15 @@ namespace Content.Server.Guardian
EntityManager.QueueDeleteEntity(component.HostedGuardian.Value);
}
private void OnGuardianAttackAttempt(EntityUid uid, GuardianComponent component, AttackAttemptEvent args)
{
if (args.Cancelled || args.Target != component.Host)
return;
_popupSystem.PopupCursor(Loc.GetString("guardian-attack-host"), Filter.Entities(uid));
args.Cancel();
}
public void ToggleGuardian(GuardianHostComponent hostComponent)
{
if (hostComponent.HostedGuardian == null ||