public async Task RejuvenateDeadTest()
        {
            var options = new ServerIntegrationOptions {
                ExtraPrototypes = PROTOTYPES
            };
            var server = StartServerDummyTicker(options);

            await server.WaitAssertion(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                mapManager.CreateNewMapEntity(MapId.Nullspace);

                var entityManager = IoCManager.Resolve <IEntityManager>();

                var human = entityManager.SpawnEntity("DamageableDummy", MapCoordinates.Nullspace);

                // Sanity check
                Assert.True(human.TryGetComponent(out IDamageableComponent damageable));
                Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Alive));

                // Kill the entity
                damageable.ChangeDamage(DamageClass.Brute, 10000000, true);

                // Check that it is dead
                Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Dead));

                // Rejuvenate them
                RejuvenateVerb.PerformRejuvenate(human);

                // Check that it is alive and with no damage
                Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Alive));
                Assert.That(damageable.TotalDamage, Is.Zero);
            });
        }
        public void RejuvenateDeadTest()
        {
            var server = StartServerDummyTicker();

            IEntity human = null;
            IDamageableComponent damageable = null;

            server.Assert(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                mapManager.CreateNewMapEntity(MapId.Nullspace);

                var entityManager = IoCManager.Resolve <IEntityManager>();

                human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);

                // Sanity check
                Assert.True(human.TryGetComponent(out damageable));
                Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Alive));

                // Kill the entity
                damageable.ChangeDamage(DamageClass.Brute, 10000000, true);

                // Check that it is dead
                Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Dead));

                // Rejuvenate them
                RejuvenateVerb.PerformRejuvenate(human);

                // Check that it is alive and with no damage
                Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Alive));
                Assert.That(damageable.TotalDamage, Is.Zero);
            });
        }
Beispiel #3
0
        public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
        {
            if (args.Length < 1 && player != null) //Try to heal the users mob if applicable
            {
                shell.SendText(player, Loc.GetString("Healing the user's mob since no arguments were provided."));
                if (player.AttachedEntity == null)
                {
                    shell.SendText(player, Loc.GetString("There's no entity attached to the user."));
                    return;
                }
                RejuvenateVerb.PerformRejuvenate(player.AttachedEntity);
            }

            var entityManager = IoCManager.Resolve <IEntityManager>();

            foreach (var arg in args)
            {
                if (!EntityUid.TryParse(arg, out var uid) || !entityManager.TryGetEntity(uid, out var entity))
                {
                    shell.SendText(player, Loc.GetString("Could not find entity {0}", arg));
                    continue;
                }
                RejuvenateVerb.PerformRejuvenate(entity);
            }
        }
        public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            var player = shell.Player as IPlayerSession;

            if (args.Length < 1 && player != null) //Try to heal the users mob if applicable
            {
                shell.WriteLine(Loc.GetString("rejuvenate-command-self-heal-message"));
                if (player.AttachedEntity == null)
                {
                    shell.WriteLine(Loc.GetString("rejuvenate-command-no-entity-attached-message"));
                    return;
                }
                RejuvenateVerb.PerformRejuvenate(player.AttachedEntity);
            }

            var entityManager = IoCManager.Resolve <IEntityManager>();

            foreach (var arg in args)
            {
                if (!EntityUid.TryParse(arg, out var uid) || !entityManager.TryGetEntity(uid, out var entity))
                {
                    shell.WriteLine(Loc.GetString("shell-could-not-find-entity", ("entity", arg)));
                    continue;
                }
                RejuvenateVerb.PerformRejuvenate(entity);
            }
        }
        public async Task RejuvenateDeadTest()
        {
            var options = new ServerIntegrationOptions {
                ExtraPrototypes = Prototypes
            };
            var server = StartServerDummyTicker(options);

            await server.WaitAssertion(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                mapManager.CreateNewMapEntity(MapId.Nullspace);

                var entityManager    = IoCManager.Resolve <IEntityManager>();
                var prototypeManager = IoCManager.Resolve <IPrototypeManager>();

                var human = entityManager.SpawnEntity("DamageableDummy", MapCoordinates.Nullspace);

                // Sanity check
                Assert.True(human.TryGetComponent(out IDamageableComponent damageable));
                Assert.True(human.TryGetComponent(out IMobStateComponent mobState));
                Assert.That(mobState.IsAlive, Is.True);
                Assert.That(mobState.IsCritical, Is.False);
                Assert.That(mobState.IsDead, Is.False);
                Assert.That(mobState.IsIncapacitated, Is.False);

                // Kill the entity
                damageable.TryChangeDamage(prototypeManager.Index <DamageGroupPrototype>("Toxin"), 10000000, true);

                // Check that it is dead
                Assert.That(mobState.IsAlive, Is.False);
                Assert.That(mobState.IsCritical, Is.False);
                Assert.That(mobState.IsDead, Is.True);
                Assert.That(mobState.IsIncapacitated, Is.True);

                // Rejuvenate them
                RejuvenateVerb.PerformRejuvenate(human);

                // Check that it is alive and with no damage
                Assert.That(mobState.IsAlive, Is.True);
                Assert.That(mobState.IsCritical, Is.False);
                Assert.That(mobState.IsDead, Is.False);
                Assert.That(mobState.IsIncapacitated, Is.False);

                Assert.That(damageable.TotalDamage, Is.Zero);
            });
        }