public async Task TestA()
        {
            var(c, s) = await Start();

            await c.WaitIdleAsync();

            var cEntities = c.ResolveDependency <IEntityManager>();

            EntityUid dummy = default;

            s.Post(() =>
            {
                var pos       = new MapCoordinates(Vector2.Zero, new MapId(1));
                var ent       = IoCManager.Resolve <IEntityManager>();
                var container = ent.SpawnEntity("ContainerOcclusionA", pos);
                dummy         = ent.SpawnEntity("ContainerOcclusionDummy", pos);

                ent.GetComponent <EntityStorageComponent>(container).Insert(dummy);
            });

            await RunTicksSync(c, s, 5);

            c.Assert(() =>
            {
                var sprite = cEntities.GetComponent <SpriteComponent>(dummy);
                var light  = cEntities.GetComponent <PointLightComponent>(dummy);
                Assert.True(sprite.ContainerOccluded);
                Assert.True(light.ContainerOccluded);
            });

            await Task.WhenAll(c.WaitIdleAsync(), s.WaitIdleAsync());
        }
Exemplo n.º 2
0
        public GridPainter(ClientIntegrationInstance client, ServerIntegrationInstance server)
        {
            _entityPainter = new EntityPainter(client, server);

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

            _sEntityManager = server.ResolveDependency <IEntityManager>();

            _entities = GetEntities();
        }
Exemplo n.º 3
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);
        }
        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);
        }
Exemplo n.º 5
0
 public TilePainter(ClientIntegrationInstance client, ServerIntegrationInstance server)
 {
     _sTileDefinitionManager = server.ResolveDependency <ITileDefinitionManager>();
     _cResourceCache         = client.ResolveDependency <IResourceCache>();
 }