public void Setup()
        {
            var factory = IoCManager.Resolve <IComponentFactory>();

            factory.Register <ClientTransformComponent>();
            factory.RegisterReference <ClientTransformComponent, ITransformComponent>();

            EntityManager = (EntityManager)IoCManager.Resolve <IClientEntityManager>();
            MapManager    = IoCManager.Resolve <IMapManager>();

            var manager = IoCManager.Resolve <IPrototypeManager>();

            manager.LoadFromStream(new StringReader(PROTOTYPES));
            manager.Resync();

            // build the net dream
            var newMap = MapManager.CreateMap(new MapId(1));

            newMap.CreateGrid(new GridId(4));

            newMap = MapManager.CreateMap(new MapId(2));
            newMap.CreateGrid(new GridId(5));

            //NOTE: The grids have not moved, so we can assert worldpos == localpos for the tests
        }
        public void Setup()
        {
            var compMan = IoCManager.Resolve <IComponentManager>();

            compMan.Initialize();

            EntityManager = IoCManager.Resolve <IServerEntityManagerInternal>();
            MapManager    = IoCManager.Resolve <IMapManager>();
            MapManager.Initialize();
            MapManager.Startup();

            MapManager.CreateMap();

            var manager = IoCManager.Resolve <IPrototypeManager>();

            manager.LoadFromStream(new StringReader(PROTOTYPES));
            manager.Resync();

            // build the net dream
            MapA  = MapManager.CreateMap();
            GridA = MapManager.CreateGrid(MapA);

            MapB  = MapManager.CreateMap();
            GridB = MapManager.CreateGrid(MapB);

            //NOTE: The grids have not moved, so we can assert worldpos == localpos for the test
        }
        public void Setup()
        {
            EntityManager = IoCManager.Resolve <IServerEntityManager>();
            MapManager    = IoCManager.Resolve <IMapManager>();

            var manager = IoCManager.Resolve <IPrototypeManager>();

            manager.LoadFromStream(new StringReader(PROTOTYPES));
            manager.Resync();

            // build the net dream
            MapA  = MapManager.CreateMap();
            GridA = MapA.CreateGrid();

            MapB  = MapManager.CreateMap();
            GridB = MapB.CreateGrid();

            //NOTE: The grids have not moved, so we can assert worldpos == localpos for the test
        }
        public void Setup()
        {
            EntityManager = (EntityManager)IoCManager.Resolve <IClientEntityManager>();
            MapManager    = IoCManager.Resolve <IMapManager>();

            var manager = IoCManager.Resolve <IPrototypeManager>();

            manager.LoadFromStream(new StringReader(PROTOTYPES));
            manager.Resync();

            // build the net dream
            var newMap = MapManager.CreateMap(new MapId(1));

            newMap.CreateGrid(new GridId(4));

            newMap = MapManager.CreateMap(new MapId(2));
            newMap.CreateGrid(new GridId(5));

            //NOTE: The grids have not moved, so we can assert worldpos == localpos for the tests
        }
        /// <inheritdoc />
        public void LoadMap(MapId mapId, string path)
        {
            // FIXME: The handling of grid IDs in here is absolutely 100% turbofucked ATM.
            // This function absolutely will not work.
            // It's CURRENTLY still working using the old map ID -> grid ID which absolutely DOES NOT WORK ANYMORE.
            // BP loading works because grid IDs are manually hard set.
            var rootPath = _resMan.ConfigDirectory;
            var comb     = Path.Combine(rootPath, "./", path);
            var fullPath = Path.GetFullPath(comb);

            TextReader reader;

            // try user
            if (!File.Exists(fullPath))
            {
                Logger.InfoS("map", $"No user blueprint found: {fullPath}");

                // fallback to content
                if (_resMan.TryContentFileRead(path, out var contentReader))
                {
                    reader = new StreamReader(contentReader);
                }
                else
                {
                    Logger.ErrorS("map", $"No blueprint found: {path}");
                    return;
                }
            }
            else
            {
                reader = new StreamReader(fullPath);
            }

            using (reader)
            {
                Logger.InfoS("map", $"Loading Map: {path}");

                var stream = new YamlStream();
                stream.Load(reader);

                foreach (var document in stream.Documents)
                {
                    var root = (YamlMappingNode)document.RootNode;
                    var map  = _mapManager.CreateMap(mapId);
                    LoadMapNode(map, root);
                }
            }
        }
    private void Setup()
    {
        if (CargoMap != null && _mapManager.MapExists(CargoMap.Value))
        {
            return;
        }

        // It gets mapinit which is okay... buuutt we still want it paused to avoid power draining.
        CargoMap = _mapManager.CreateMap();
        _mapManager.SetMapPaused(CargoMap !.Value, true);

        foreach (var comp in EntityQuery <StationCargoOrderDatabaseComponent>(true))
        {
            AddShuttle(comp);
        }
    }
Beispiel #7
0
        /// <inheritdoc />
        public void LoadMap(MapId mapId, string path)
        {
            // FIXME: The handling of grid IDs in here is absolutely 100% turbofucked ATM.
            // This function absolutely will not work.
            // It's CURRENTLY still working using the old map ID -> grid ID which absolutely DOES NOT WORK ANYMORE.
            // BP loading works because grid IDs are manually hard set.

            TextReader reader;
            var        resPath = new ResourcePath(path).ToRootedPath();

            // try user
            if (!_resMan.UserData.Exists(resPath))
            {
                Logger.InfoS("map", $"No user blueprint found: {resPath}");

                // fallback to content
                if (_resMan.TryContentFileRead(resPath, out var contentReader))
                {
                    reader = new StreamReader(contentReader);
                }
                else
                {
                    Logger.ErrorS("map", $"No blueprint found: {resPath}");
                    return;
                }
            }
            else
            {
                var file = _resMan.UserData.Open(resPath, FileMode.Open);
                reader = new StreamReader(file);
            }

            using (reader)
            {
                Logger.InfoS("map", $"Loading Map: {resPath}");

                var stream = new YamlStream();
                stream.Load(reader);

                foreach (var document in stream.Documents)
                {
                    var root = (YamlMappingNode)document.RootNode;
                    var map  = _mapManager.CreateMap(mapId);
                    LoadMapNode(map, root);
                }
            }
        }
        /// <summary>
        ///     Deserializes an IMapManager and ITileDefinitionManager from a properly formatted NetMessage.
        /// </summary>
        /// <param name="message">The message containing a serialized map and tileDefines.</param>
        private void HandleTileMap(MsgMap message)
        {
            Debug.Assert(_netManager.IsClient, "Why is the server calling this?");

            GridsReceived++;

            var mapIndex  = message.MapIndex;
            var gridIndex = message.GridIndex;

            _defManager.RegisterServerTileMapping(message);

            var chunkSize  = message.ChunkSize;
            var chunkCount = message.ChunkDefs.Length;

            if (!_mapManager.TryGetMap(mapIndex, out IMap map))
            {
                map = _mapManager.CreateMap(mapIndex);
            }
            if (!map.GridExists(gridIndex))
            {
                _mapManager.GetMap(mapIndex).CreateGrid(gridIndex, chunkSize);
            }
            IMapGrid grid = _mapManager.GetMap(mapIndex).GetGrid(gridIndex);

            for (var i = 0; i < chunkCount; ++i)
            {
                var chunkPos = new MapGrid.Indices(message.ChunkDefs[i].X, message.ChunkDefs[i].Y);
                var chunk    = grid.GetChunk(chunkPos);

                var counter = 0;
                for (ushort x = 0; x < chunk.ChunkSize; x++)
                {
                    for (ushort y = 0; y < chunk.ChunkSize; y++)
                    {
                        chunk.SetTile(x, y, (Tile)message.ChunkDefs[i].Tiles[counter]);
                        counter++;
                    }
                }
            }

            if (GridsReceived == GridsToReceive)
            {
                IoCManager.Resolve <IEntityManager>().MapsInitialized = true;
            }
        }
Beispiel #9
0
        /// <inheritdoc />
        public void LoadMap(MapId mapId, string path)
        {
            var rootPath = _resMan.ConfigDirectory;
            var comb     = Path.Combine(rootPath, "./", path);
            var fullPath = Path.GetFullPath(comb);

            TextReader reader;

            // try user
            if (!File.Exists(fullPath))
            {
                Logger.InfoS("map", $"No user blueprint found: {fullPath}");

                // fallback to content
                if (_resMan.TryContentFileRead(path, out var contentReader))
                {
                    reader = new StreamReader(contentReader);
                }
                else
                {
                    Logger.ErrorS("map", $"No blueprint found: {path}");
                    return;
                }
            }
            else
            {
                reader = new StreamReader(fullPath);
            }

            using (reader)
            {
                Logger.InfoS("map", $"Loading Map: {path}");

                var stream = new YamlStream();
                stream.Load(reader);

                foreach (var document in stream.Documents)
                {
                    var root = (YamlMappingNode)document.RootNode;
                    var map  = _mapManager.CreateMap(mapId);
                    LoadMapNode(map, root);
                }
            }
        }
        public void Initialize()
        {
            // Create ingress point map.
            Map = _mapManager.CreateMap();
            var grid = _mapManager.CreateGrid(Map);

            grid.SetTile(new Vector2i(-1, -1), new Tile(0));
            grid.SetTile(new Vector2i(0, -1), new Tile(1));
            grid.SetTile(new Vector2i(1, -1), new Tile(0));

            grid.SetTile(new Vector2i(-1, 0), new Tile(1));
            grid.SetTile(new Vector2i(0, 0), new Tile(0));
            grid.SetTile(new Vector2i(1, 0), new Tile(1));

            grid.SetTile(new Vector2i(-1, 1), new Tile(0));
            grid.SetTile(new Vector2i(0, 1), new Tile(1));
            grid.SetTile(new Vector2i(1, 1), new Tile(0));
            // _mapManager.CreateNewMapEntity(IngressMap);

            // Setup join experience.
            _playerManager.PlayerStatusChanged += PlayerStatusChanged;
        }