コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        private void OnGuardianUnplayer(EntityUid uid, GuardianComponent component, PlayerDetachedEvent args)
        {
            var host = component.Host;

            if (!TryComp <GuardianHostComponent>(host, out var hostComponent))
            {
                return;
            }

            RetractGuardian(hostComponent, component);
        }
コード例 #6
0
        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;
        }
コード例 #7
0
        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;
        }
コード例 #8
0
 private bool CanRelease(GuardianHostComponent host, GuardianComponent guardian)
 {
     return(HasComp <ActorComponent>(guardian.Owner));
 }