Exemplo n.º 1
0
        public async Task BuckledDyingDropItemsTest()
        {
            var options = new ServerContentIntegrationOption {
                ExtraPrototypes = Prototypes
            };
            var server = StartServer(options);

            EntityUid           human  = default;
            BuckleComponent     buckle = null;
            HandsComponent      hands  = null;
            SharedBodyComponent body   = null;

            await server.WaitIdleAsync();

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

                var grid        = GetMainGrid(mapManager);
                var coordinates = new EntityCoordinates(grid.GridEntityId, 0, 0);

                human     = entityManager.SpawnEntity(BuckleDummyId, coordinates);
                var chair = entityManager.SpawnEntity(StrapDummyId, coordinates);

                // Component sanity check
                Assert.True(entityManager.TryGetComponent(human, out buckle));
                Assert.True(entityManager.HasComponent <StrapComponent>(chair));
                Assert.True(entityManager.TryGetComponent(human, out hands));
                Assert.True(entityManager.TryGetComponent(human, out body));

                // 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(ItemDummyId, coordinates);

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

            await server.WaitRunTicks(10);

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

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

                var legs = body.GetPartsOfType(BodyPartType.Leg);

                // Break our guy's kneecaps
                foreach (var leg in legs)
                {
                    body.RemovePart(leg);
                }
            });

            await server.WaitRunTicks(10);

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

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

                buckle.TryUnbuckle(human, true);
            });
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public async Task BuckledDyingDropItemsTest()
        {
            var server = StartServer();

            IEntity         human;
            IEntity         chair;
            BuckleComponent buckle = null;
            HandsComponent  hands  = null;
            IBody           body   = null;

            await server.WaitAssertion(() =>
            {
                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   = grid.GridEntityId.ToCoordinates();
                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.HasComponent <StrapComponent>());
                Assert.True(human.TryGetComponent(out hands));
                Assert.True(human.TryGetComponent(out body));

                // 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));
                }
            });

            await server.WaitRunTicks(10);

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

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

                var legs = body.GetPartsOfType(BodyPartType.Leg);

                // Break our guy's kneecaps
                foreach (var leg in legs)
                {
                    body.RemovePart(leg);
                }
            });

            await server.WaitRunTicks(10);

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

                // Now with no item in any hand
                foreach (var slot in hands.Hands)
                {
                    Assert.Null(hands.GetItem(slot));
                }
            });
        }
Exemplo n.º 4
0
        public async Task BuckledDyingDropItemsTest()
        {
            var options = new ServerIntegrationOptions {
                ExtraPrototypes = PROTOTYPES
            };
            var server = StartServer(options);

            IEntity         human  = null;
            BuckleComponent buckle = null;
            HandsComponent  hands  = null;
            IBody           body   = null;

            await server.WaitIdleAsync();

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

                var gridId      = new GridId(1);
                var grid        = mapManager.GetGrid(gridId);
                var coordinates = grid.GridEntityId.ToCoordinates();

                human         = entityManager.SpawnEntity("BuckleDummy", coordinates);
                IEntity chair = entityManager.SpawnEntity("StrapDummy", coordinates);

                // Component sanity check
                Assert.True(human.TryGetComponent(out buckle));
                Assert.True(chair.HasComponent <StrapComponent>());
                Assert.True(human.TryGetComponent(out hands));
                Assert.True(human.TryGetComponent(out body));

                // 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));
                }
            });

            await server.WaitRunTicks(10);

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

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

                var legs = body.GetPartsOfType(BodyPartType.Leg);

                // Break our guy's kneecaps
                foreach (var leg in legs)
                {
                    body.RemovePart(leg);
                }
            });

            await server.WaitRunTicks(10);

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

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

                buckle.TryUnbuckle(human, true);
            });
        }