/// <summary> /// Called every time the guardian moves: makes sure it's not out of it's allowed distance /// </summary> private void OnGuardianMove(EntityUid uid, GuardianComponent component, ref MoveEvent args) { if (!component.GuardianLoose) { return; } CheckGuardianMove(component.Host, uid, guardianComponent: component); }
/// <summary> /// Handles guardian receiving damage and splitting it with the host according to his defence percent /// </summary> private void OnGuardianDamaged(EntityUid uid, GuardianComponent component, DamageChangedEvent args) { if (args.DamageDelta == null) { return; } _damageSystem.TryChangeDamage(component.Host, args.DamageDelta * component.DamageShare); _popupSystem.PopupEntity(Loc.GetString("guardian-entity-taking-damage"), component.Host, Filter.Entities(component.Host)); }
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(); }
private void OnGuardianPlayer(EntityUid uid, GuardianComponent component, PlayerAttachedEvent args) { var host = component.Host; if (!HasComp <GuardianHostComponent>(host)) { return; } _popupSystem.PopupEntity(Loc.GetString("guardian-available"), host, Filter.Entities(host)); }
private void OnGuardianUnplayer(EntityUid uid, GuardianComponent component, PlayerDetachedEvent args) { var host = component.Host; if (!TryComp <GuardianHostComponent>(host, out var hostComponent)) { return; } RetractGuardian(hostComponent, component); }
private void RetractGuardian(GuardianHostComponent hostComponent, GuardianComponent guardianComponent) { if (!guardianComponent.GuardianLoose) { DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardianComponent.Owner)); return; } hostComponent.GuardianContainer.Insert(guardianComponent.Owner); DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardianComponent.Owner)); _popupSystem.PopupEntity(Loc.GetString("guardian-entity-recall"), hostComponent.Owner, Filter.Pvs(hostComponent.Owner)); guardianComponent.GuardianLoose = false; }
private void ReleaseGuardian(GuardianHostComponent hostComponent, GuardianComponent guardianComponent) { if (guardianComponent.GuardianLoose) { DebugTools.Assert(!hostComponent.GuardianContainer.Contains(guardianComponent.Owner)); return; } if (!CanRelease(hostComponent, guardianComponent)) { _popupSystem.PopupEntity(Loc.GetString("guardian-no-soul"), hostComponent.Owner, Filter.Entities(hostComponent.Owner)); return; } DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardianComponent.Owner)); hostComponent.GuardianContainer.Remove(guardianComponent.Owner); DebugTools.Assert(!hostComponent.GuardianContainer.Contains(guardianComponent.Owner)); guardianComponent.GuardianLoose = true; }
private bool CanRelease(GuardianHostComponent host, GuardianComponent guardian) { return(HasComp <ActorComponent>(guardian.Owner)); }