public async Task TestDamageTypeDamageAndHeal()
        {
            var server = StartServerDummyTicker(new ServerContentIntegrationOption
            {
                ExtraPrototypes = Prototypes
            });

            await server.WaitIdleAsync();

            var sEntityManager = server.ResolveDependency <IEntityManager>();
            var sMapManager    = server.ResolveDependency <IMapManager>();

            IEntity sDamageableEntity = null;
            IDamageableComponent sDamageableComponent = null;

            await server.WaitPost(() =>
            {
                var mapId       = sMapManager.NextMapId();
                var coordinates = new MapCoordinates(0, 0, mapId);
                sMapManager.CreateMap(mapId);

                sDamageableEntity    = sEntityManager.SpawnEntity(DamageableEntityId, coordinates);
                sDamageableComponent = sDamageableEntity.GetComponent <IDamageableComponent>();
            });

            await server.WaitRunTicks(5);

            await server.WaitAssertion(() =>
            {
                Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(0));

                var damageToDeal = 7;

                foreach (var type in Enum.GetValues <DamageType>())
                {
                    Assert.That(sDamageableComponent.SupportsDamageType(type));

                    // Damage
                    Assert.That(sDamageableComponent.ChangeDamage(type, damageToDeal, true), Is.True);
                    Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(damageToDeal));
                    Assert.That(sDamageableComponent.TryGetDamage(type, out var damage), Is.True);
                    Assert.That(damage, Is.EqualTo(damageToDeal));

                    // Heal
                    Assert.That(sDamageableComponent.ChangeDamage(type, -damageToDeal, true), Is.True);
                    Assert.That(sDamageableComponent.TotalDamage, Is.Zero);
                    Assert.That(sDamageableComponent.TryGetDamage(type, out damage), Is.True);
                    Assert.That(damage, 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);
            });
        }
        public async Task TotalDamageTest()
        {
            var server = StartServerDummyTicker(new ServerContentIntegrationOption
            {
                ExtraPrototypes = Prototypes
            });

            await server.WaitIdleAsync();

            var sEntityManager = server.ResolveDependency <IEntityManager>();
            var sMapManager    = server.ResolveDependency <IMapManager>();

            IEntity sDamageableEntity;
            IDamageableComponent sDamageableComponent = null;

            await server.WaitPost(() =>
            {
                var mapId       = sMapManager.NextMapId();
                var coordinates = new MapCoordinates(0, 0, mapId);
                sMapManager.CreateMap(mapId);

                sDamageableEntity    = sEntityManager.SpawnEntity(DamageableEntityId, coordinates);
                sDamageableComponent = sDamageableEntity.GetComponent <IDamageableComponent>();
            });

            await server.WaitAssertion(() =>
            {
                var damageType = DamageClass.Brute;
                var damage     = 10;

                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, damage, true));
                Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(10));

                var totalTypeDamage = 0;

                foreach (var type in damageType.ToTypes())
                {
                    Assert.True(sDamageableComponent.TryGetDamage(type, out var typeDamage));
                    Assert.That(typeDamage, Is.LessThanOrEqualTo(damage));

                    totalTypeDamage += typeDamage;
                }

                Assert.That(totalTypeDamage, Is.EqualTo(damage));
            });
        }
        public async Task Test()
        {
            var server = StartServerDummyTicker(new ServerContentIntegrationOption
            {
                ExtraPrototypes  = Prototypes,
                ContentBeforeIoC = () =>
                {
                    IoCManager.Resolve <IComponentFactory>().Register <TestThresholdListenerComponent>();
                }
            });

            await server.WaitIdleAsync();

            var sEntityManager = server.ResolveDependency <IEntityManager>();
            var sMapManager    = server.ResolveDependency <IMapManager>();

            IEntity sDestructibleEntity = null;
            IDamageableComponent           sDamageableComponent        = null;
            TestThresholdListenerComponent sThresholdListenerComponent = null;

            await server.WaitPost(() =>
            {
                var mapId       = new MapId(1);
                var coordinates = new MapCoordinates(0, 0, mapId);
                sMapManager.CreateMap(mapId);

                sDestructibleEntity         = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates);
                sDamageableComponent        = sDestructibleEntity.GetComponent <IDamageableComponent>();
                sThresholdListenerComponent = sDestructibleEntity.GetComponent <TestThresholdListenerComponent>();
            });

            await server.WaitAssertion(() =>
            {
                var coordinates = sDestructibleEntity.Transform.Coordinates;

                Assert.DoesNotThrow(() =>
                {
                    Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 50, true));
                });

                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                var threshold = sThresholdListenerComponent.ThresholdsReached[0].Threshold;

                Assert.That(threshold.Triggered, Is.True);
                Assert.That(threshold.Behaviors.Count, Is.EqualTo(3));

                var spawnEntitiesBehavior = (SpawnEntitiesBehavior)threshold.Behaviors.Single(b => b is SpawnEntitiesBehavior);

                Assert.That(spawnEntitiesBehavior.Spawn.Count, Is.EqualTo(1));
                Assert.That(spawnEntitiesBehavior.Spawn.Keys.Single(), Is.EqualTo(SpawnedEntityId));
                Assert.That(spawnEntitiesBehavior.Spawn.Values.Single(), Is.EqualTo(new MinMax {
                    Min = 1, Max = 1
                }));

                var entitiesInRange = sEntityManager.GetEntitiesInRange(coordinates, 2);
                var found           = false;

                foreach (var entity in entitiesInRange)
                {
                    if (entity.Prototype == null)
                    {
                        continue;
                    }

                    if (entity.Prototype.Name != SpawnedEntityId)
                    {
                        continue;
                    }

                    found = true;
                    break;
                }

                Assert.That(found, Is.True);
            });
        }
Beispiel #5
0
        public async Task AndTest()
        {
            var server = StartServerDummyTicker(new ServerContentIntegrationOption
            {
                ExtraPrototypes  = Prototypes,
                ContentBeforeIoC = () =>
                {
                    IoCManager.Resolve <IComponentFactory>().Register <TestThresholdListenerComponent>();
                }
            });

            await server.WaitIdleAsync();

            var sEntityManager = server.ResolveDependency <IEntityManager>();
            var sMapManager    = server.ResolveDependency <IMapManager>();

            IEntity sDestructibleEntity;
            IDamageableComponent           sDamageableComponent        = null;
            TestThresholdListenerComponent sThresholdListenerComponent = null;

            await server.WaitPost(() =>
            {
                var mapId       = new MapId(1);
                var coordinates = new MapCoordinates(0, 0, mapId);
                sMapManager.CreateMap(mapId);

                sDestructibleEntity         = sEntityManager.SpawnEntity(DestructibleDamageClassEntityId, coordinates);
                sDamageableComponent        = sDestructibleEntity.GetComponent <IDamageableComponent>();
                sThresholdListenerComponent = sDestructibleEntity.GetComponent <TestThresholdListenerComponent>();
            });

            await server.WaitRunTicks(5);

            await server.WaitAssertion(() =>
            {
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);
            });

            await server.WaitAssertion(() =>
            {
                // Raise brute damage to 5
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 5, true));

                // No thresholds reached yet, the earliest one is at 10 damage
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise brute damage to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 5, true));

                // No threshold reached, burn needs to be 10 as well
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise burn damage to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Burn, 10, true));

                // One threshold reached, brute 10 + burn 10
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold brute 10 + burn 10
                var msg       = sThresholdListenerComponent.ThresholdsReached[0];
                var threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);
                Assert.IsInstanceOf <AndTrigger>(threshold.Trigger);

                var trigger = (AndTrigger)threshold.Trigger;

                Assert.IsInstanceOf <DamageClassTrigger>(trigger.Triggers[0]);
                Assert.IsInstanceOf <DamageClassTrigger>(trigger.Triggers[1]);

                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Raise brute damage to 20
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 10, true));

                // No new thresholds reached
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise burn damage to 20
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Burn, 10, true));

                // No new thresholds reached
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Lower brute damage to 0
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, -20, true));

                // No new thresholds reached, healing should not trigger it
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise brute damage back up to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 10, true));

                // 10 brute + 10 burn threshold reached, brute was healed and brought back to its threshold amount and slash stayed the same
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Heal both classes of damage to 0
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, -10, true));
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Burn, -20, true));

                // No new thresholds reached, healing should not trigger it
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise brute damage to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 10, true));

                // No new thresholds reached
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise burn damage to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Burn, 10, true));

                // Both classes of damage were healed and then raised again, the threshold should have been reached as triggers once is default false
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold brute 10 + burn 10
                msg       = sThresholdListenerComponent.ThresholdsReached[0];
                threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);
                Assert.IsInstanceOf <AndTrigger>(threshold.Trigger);

                trigger = (AndTrigger)threshold.Trigger;

                Assert.IsInstanceOf <DamageClassTrigger>(trigger.Triggers[0]);
                Assert.IsInstanceOf <DamageClassTrigger>(trigger.Triggers[1]);

                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Change triggers once to true
                threshold.TriggersOnce = true;

                // Heal brute and burn back to 0
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, -10, true));
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Burn, -10, true));

                // No new thresholds reached from healing
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise brute damage to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Brute, 10, true));

                // No new thresholds reached
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Raise burn damage to 10
                Assert.True(sDamageableComponent.ChangeDamage(DamageClass.Burn, 10, true));

                // No new thresholds reached as triggers once is set to true and it already triggered before
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);
            });
        }
Beispiel #6
0
        public async Task BuckledDyingDropItemsTest()
        {
            var server = StartServer();

            IEntity              human           = null;
            IEntity              chair           = null;
            BuckleComponent      buckle          = null;
            StrapComponent       strap           = null;
            HandsComponent       hands           = null;
            IDamageableComponent humanDamageable = null;

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

                var mapId = new MapId(1);
                mapManager.CreateNewMapEntity(mapId);

                var entityManager = IoCManager.Resolve <IEntityManager>();
                var gridId        = new GridId(1);
                var grid          = mapManager.CreateGrid(mapId, gridId);
                var coordinates   = new GridCoordinates((0, 0), gridId);
                var tileManager   = IoCManager.Resolve <ITileDefinitionManager>();
                var tileId        = tileManager["underplating"].TileId;
                var tile          = new Tile(tileId);

                grid.SetTile(coordinates, tile);

                human = entityManager.SpawnEntity("HumanMob_Content", coordinates);
                chair = entityManager.SpawnEntity("ChairWood", coordinates);

                // Component sanity check
                Assert.True(human.TryGetComponent(out buckle));
                Assert.True(chair.TryGetComponent(out strap));
                Assert.True(human.TryGetComponent(out hands));
                Assert.True(human.TryGetComponent(out humanDamageable));

                // Buckle
                Assert.True(buckle.TryBuckle(human, chair));
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);

                // Put an item into every hand
                for (var i = 0; i < hands.Count; i++)
                {
                    var akms = entityManager.SpawnEntity("RifleAk", coordinates);

                    // Equip items
                    Assert.True(akms.TryGetComponent(out ItemComponent item));
                    Assert.True(hands.PutInHand(item));
                }
            });

            server.RunTicks(10);

            server.Assert(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // With items in all hands
                foreach (var slot in hands.Hands)
                {
                    Assert.NotNull(hands.GetItem(slot));
                }

                // Banish our guy into the shadow realm
                humanDamageable.ChangeDamage(DamageClass.Brute, 1000000, true);
            });

            server.RunTicks(10);

            server.Assert(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // Now with no item in any hand
                foreach (var slot in hands.Hands)
                {
                    Assert.Null(hands.GetItem(slot));
                }
            });

            await server.WaitIdleAsync();
        }
        public async Task Test()
        {
            var server = StartServerDummyTicker(new ServerContentIntegrationOption
            {
                ExtraPrototypes  = Prototypes,
                ContentBeforeIoC = () =>
                {
                    IoCManager.Resolve <IComponentFactory>().RegisterClass <TestThresholdListenerComponent>();
                }
            });

            await server.WaitIdleAsync();

            var sEntityManager = server.ResolveDependency <IEntityManager>();
            var sMapManager    = server.ResolveDependency <IMapManager>();

            IEntity sDestructibleEntity;
            IDamageableComponent           sDamageableComponent        = null;
            DestructibleComponent          sDestructibleComponent      = null;
            TestThresholdListenerComponent sThresholdListenerComponent = null;

            await server.WaitPost(() =>
            {
                var mapId       = new MapId(1);
                var coordinates = new MapCoordinates(0, 0, mapId);
                sMapManager.CreateMap(mapId);

                sDestructibleEntity         = sEntityManager.SpawnEntity(DestructibleEntityId, coordinates);
                sDamageableComponent        = sDestructibleEntity.GetComponent <IDamageableComponent>();
                sDestructibleComponent      = sDestructibleEntity.GetComponent <DestructibleComponent>();
                sThresholdListenerComponent = sDestructibleEntity.GetComponent <TestThresholdListenerComponent>();
            });

            await server.WaitRunTicks(5);

            await server.WaitAssertion(() =>
            {
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);
            });

            await server.WaitAssertion(() =>
            {
                Assert.True(sDamageableComponent.ChangeDamage(DamageType.Blunt, 10, true));

                // No thresholds reached yet, the earliest one is at 20 damage
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                Assert.True(sDamageableComponent.ChangeDamage(DamageType.Blunt, 10, true));

                // Only one threshold reached, 20
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold 20
                var msg       = sThresholdListenerComponent.ThresholdsReached[0];
                var threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);

                sThresholdListenerComponent.ThresholdsReached.Clear();

                Assert.True(sDamageableComponent.ChangeDamage(DamageType.Blunt, 30, true));

                // One threshold reached, 50, since 20 already triggered before and it has not been healed below that amount
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold 50
                msg       = sThresholdListenerComponent.ThresholdsReached[0];
                threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Has.Count.EqualTo(3));

                var soundThreshold = (PlaySoundBehavior)threshold.Behaviors[0];
                var spawnThreshold = (SpawnEntitiesBehavior)threshold.Behaviors[1];
                var actsThreshold  = (DoActsBehavior)threshold.Behaviors[2];

                Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
                Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg"));
                Assert.That(spawnThreshold.Spawn, Is.Not.Null);
                Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
                Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
                Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
                Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);

                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Damage for 50 again, up to 100 now
                Assert.True(sDamageableComponent.ChangeDamage(DamageType.Blunt, 50, true));

                // No thresholds reached as they weren't healed below the trigger amount
                Assert.IsEmpty(sThresholdListenerComponent.ThresholdsReached);

                // Heal down to 0
                sDamageableComponent.Heal();

                // Damage for 100, up to 100
                Assert.True(sDamageableComponent.ChangeDamage(DamageType.Blunt, 100, true));

                // Two thresholds reached as damage increased past the previous, 20 and 50
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(2));

                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Heal the entity for 40 damage, down to 60
                sDamageableComponent.ChangeDamage(DamageType.Blunt, -40, true);

                // Thresholds don't work backwards
                Assert.That(sThresholdListenerComponent.ThresholdsReached, Is.Empty);

                // Damage for 10, up to 70
                sDamageableComponent.ChangeDamage(DamageType.Blunt, 10, true);

                // Not enough healing to de-trigger a threshold
                Assert.That(sThresholdListenerComponent.ThresholdsReached, Is.Empty);

                // Heal by 30, down to 40
                sDamageableComponent.ChangeDamage(DamageType.Blunt, -30, true);

                // Thresholds don't work backwards
                Assert.That(sThresholdListenerComponent.ThresholdsReached, Is.Empty);

                // Damage up to 50 again
                sDamageableComponent.ChangeDamage(DamageType.Blunt, 10, true);

                // The 50 threshold should have triggered again, after being healed
                Assert.That(sThresholdListenerComponent.ThresholdsReached.Count, Is.EqualTo(1));

                msg       = sThresholdListenerComponent.ThresholdsReached[0];
                threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Has.Count.EqualTo(3));

                soundThreshold = (PlaySoundBehavior)threshold.Behaviors[0];
                spawnThreshold = (SpawnEntitiesBehavior)threshold.Behaviors[1];
                actsThreshold  = (DoActsBehavior)threshold.Behaviors[2];

                // Check that it matches the YAML prototype
                Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
                Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg"));
                Assert.That(spawnThreshold.Spawn, Is.Not.Null);
                Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
                Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
                Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
                Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);

                // Reset thresholds reached
                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Heal all damage
                sDamageableComponent.Heal();

                // Damage up to 50
                sDamageableComponent.ChangeDamage(DamageType.Blunt, 50, true);

                // Check that the total damage matches
                Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(50));

                // Both thresholds should have triggered
                Assert.That(sThresholdListenerComponent.ThresholdsReached, Has.Exactly(2).Items);

                // Verify the first one, should be the lowest one (20)
                msg         = sThresholdListenerComponent.ThresholdsReached[0];
                var trigger = (DamageTrigger)msg.Threshold.Trigger;
                Assert.NotNull(trigger);
                Assert.That(trigger.Damage, Is.EqualTo(20));

                threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);

                // Verify the second one, should be the highest one (50)
                msg     = sThresholdListenerComponent.ThresholdsReached[1];
                trigger = (DamageTrigger)msg.Threshold.Trigger;
                Assert.NotNull(trigger);
                Assert.That(trigger.Damage, Is.EqualTo(50));

                threshold = msg.Threshold;

                Assert.That(threshold.Behaviors, Has.Count.EqualTo(3));

                soundThreshold = (PlaySoundBehavior)threshold.Behaviors[0];
                spawnThreshold = (SpawnEntitiesBehavior)threshold.Behaviors[1];
                actsThreshold  = (DoActsBehavior)threshold.Behaviors[2];

                // Check that it matches the YAML prototype
                Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
                Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg"));
                Assert.That(spawnThreshold.Spawn, Is.Not.Null);
                Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
                Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
                Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
                Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);

                // Reset thresholds reached
                sThresholdListenerComponent.ThresholdsReached.Clear();

                // Heal the entity completely
                sDamageableComponent.Heal();

                // Check that the entity has 0 damage
                Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(0));

                // Set both thresholds to only trigger once
                foreach (var destructibleThreshold in sDestructibleComponent.Thresholds)
                {
                    Assert.NotNull(destructibleThreshold.Trigger);
                    destructibleThreshold.TriggersOnce = true;
                }

                // Damage the entity up to 50 damage again
                sDamageableComponent.ChangeDamage(DamageType.Blunt, 50, true);

                // Check that the total damage matches
                Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(50));

                // No thresholds should have triggered as they were already triggered before, and they are set to only trigger once
                Assert.That(sThresholdListenerComponent.ThresholdsReached, Is.Empty);

                // Set both thresholds to trigger multiple times
                foreach (var destructibleThreshold in sDestructibleComponent.Thresholds)
                {
                    Assert.NotNull(destructibleThreshold.Trigger);
                    destructibleThreshold.TriggersOnce = false;
                }

                // Check that the total damage matches
                Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(50));

                // They shouldn't have been triggered by changing TriggersOnce
                Assert.That(sThresholdListenerComponent.ThresholdsReached, Is.Empty);
            });
        }