public async Task TestPointLinearImpulse()
        {
            await _server.WaitIdleAsync();

            var entManager    = _server.ResolveDependency <IEntityManager>();
            var fixtureSystem = _server.ResolveDependency <IEntitySystemManager>()
                                .GetEntitySystem <FixtureSystem>();

            await _server.WaitAssertion(() =>
            {
                var boxEnt = entManager.SpawnEntity(null, new MapCoordinates(Vector2.Zero, new MapId(1)));
                var box    = IoCManager.Resolve <IEntityManager>().AddComponent <PhysicsComponent>(boxEnt);
                var poly   = new PolygonShape();
                poly.SetAsBox(0.5f, 0.5f);
                var fixture       = fixtureSystem.CreateFixture(box, poly);
                fixture.Mass      = 1f;
                box.FixedRotation = false;
                box.BodyType      = BodyType.Dynamic;
                Assert.That(box.InvI, Is.GreaterThan(0f));

                // Check regular impulse works
                box.ApplyLinearImpulse(new Vector2(0f, 1f));
                Assert.That(box.LinearVelocity.Length, Is.GreaterThan(0f));

                // Reset the box
                box.LinearVelocity = Vector2.Zero;
                Assert.That(box.LinearVelocity.Length, Is.EqualTo(0f));
                Assert.That(box.AngularVelocity, Is.EqualTo(0f));

                // Check the angular impulse is applied from the point
                box.ApplyLinearImpulse(new Vector2(0f, 1f), new Vector2(0.5f, 0f));
                Assert.That(box.LinearVelocity.Length, Is.GreaterThan(0f));
                Assert.That(box.AngularVelocity, Is.Not.EqualTo(0f));
            });
        }
示例#2
0
        public GridPainter(ClientIntegrationInstance client, ServerIntegrationInstance server)
        {
            _entityPainter = new EntityPainter(client, server);
            _decalPainter  = new DecalPainter(client, server);

            _cEntityManager = client.ResolveDependency <IEntityManager>();
            _cMapManager    = client.ResolveDependency <IMapManager>();

            _sEntityManager = server.ResolveDependency <IEntityManager>();
            _sMapManager    = server.ResolveDependency <IMapManager>();

            _entities = GetEntities();
            _decals   = GetDecals();
        }
示例#3
0
        public async Task Setup()
        {
            var options = new ServerIntegrationOptions {
                ExtraPrototypes = Prototypes
            };

            _server = StartServerDummyTicker(options);

            await _server.WaitIdleAsync();

            _mapManager    = _server.ResolveDependency <IMapManager>();
            _entityManager = _server.ResolveDependency <IEntityManager>();
            _gameTiming    = _server.ResolveDependency <IGameTiming>();
        }
示例#4
0
        public async Task Setup()
        {
            var options = new ServerIntegrationOptions {
                ExtraPrototypes = Prototypes
            };

            _server = StartServer(options);

            await _server.WaitIdleAsync();

            _mapManager           = _server.ResolveDependency <IMapManager>();
            _entityManager        = _server.ResolveDependency <IEntityManager>();
            _gameTiming           = _server.ResolveDependency <IGameTiming>();
            _extensionCableSystem = _entityManager.EntitySysManager.GetEntitySystem <ExtensionCableSystem>();
        }
        public async Task Setup()
        {
            _server = StartServer();
            await _server.WaitIdleAsync();

            var mapManager = _server.ResolveDependency <IMapManager>();

            mapManager.CreateMap();
        }
示例#6
0
        public async Task <bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale)
        {
            Vector2?  worldPos         = null;
            EntityUid entity           = default;
            var       clientEntManager = _client.ResolveDependency <IEntityManager>();
            var       serverEntManager = _server.ResolveDependency <IEntityManager>();
            var       eyeManager       = _client.ResolveDependency <IEyeManager>();
            var       mapManager       = _server.ResolveDependency <IMapManager>();
            var       gameTicker       = _server.ResolveDependency <IEntitySystemManager>().GetEntitySystem <GameTicker>();

            await _server.WaitPost(() =>
            {
                var gridEnt = mapManager.GetAllGrids().First().GridEntityId;
                worldPos    = serverEntManager.GetComponent <TransformComponent>(gridEnt).WorldPosition;

                var ent = serverEntManager.SpawnEntity(prototype, new EntityCoordinates(gridEnt, 0f, 0f));
                serverEntManager.GetComponent <TransformComponent>(ent).LocalRotation = angle;
                serverEntManager.GetComponent <SpriteComponent>(ent).Scale            = (scale, scale);
                entity = ent;
            });

            // Let client sync up.
            await RunTicksSync(_client, _server, 5);

            var hit = false;

            await _client.WaitPost(() =>
            {
                // these tests currently all assume player eye is 0
                eyeManager.CurrentEye.Rotation = 0;

                var clickable = clientEntManager.GetComponent <ClickableComponent>(entity);

                hit = clickable.CheckClick((clickPosX, clickPosY) + worldPos !.Value, out _, out _);
            });

            await _server.WaitPost(() =>
            {
                serverEntManager.DeleteEntity(entity);
            });

            return(hit);
        }
            /// <summary>
            ///     Wire up the server to connect to when <see cref="IClientNetManager.ClientConnect"/> gets called.
            /// </summary>
            public void SetConnectTarget(ServerIntegrationInstance server)
            {
                var clientNetManager = ResolveDependency <IntegrationNetManager>();
                var serverNetManager = server.ResolveDependency <IntegrationNetManager>();

                if (!serverNetManager.IsRunning)
                {
                    throw new InvalidOperationException("Server net manager is not running!");
                }

                clientNetManager.NextConnectChannel = serverNetManager.MessageChannelWriter;
            }
        public async Task <bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale)
        {
            EntityUid entity           = default;
            var       clientEntManager = _client.ResolveDependency <IEntityManager>();
            var       serverEntManager = _server.ResolveDependency <IEntityManager>();
            var       eyeManager       = _client.ResolveDependency <IEyeManager>();
            var       mapManager       = _server.ResolveDependency <IMapManager>();

            await _server.WaitPost(() =>
            {
                var ent = serverEntManager.SpawnEntity(prototype, GetMainEntityCoordinates(mapManager));
                serverEntManager.GetComponent <TransformComponent>(ent).WorldRotation = angle;
                serverEntManager.GetComponent <SpriteComponent>(ent).Scale            = (scale, scale);
                entity = ent;
            });

            // Let client sync up.
            await RunTicksSync(_client, _server, 5);

            var hit = false;

            await _client.WaitPost(() =>
            {
                // these tests currently all assume player eye is 0
                eyeManager.CurrentEye.Rotation = 0;

                var pos       = clientEntManager.GetComponent <TransformComponent>(entity).WorldPosition;
                var clickable = clientEntManager.GetComponent <ClickableComponent>(entity);

                hit = clickable.CheckClick((clickPosX, clickPosY) + pos, out _, out _);
            });

            await _server.WaitPost(() =>
            {
                serverEntManager.DeleteEntity(entity);
            });

            return(hit);
        }
示例#9
0
 public TilePainter(ClientIntegrationInstance client, ServerIntegrationInstance server)
 {
     _sTileDefinitionManager = server.ResolveDependency <ITileDefinitionManager>();
     _cResourceCache         = client.ResolveDependency <IResourceCache>();
 }