コード例 #1
0
        /// <inheritdoc />
        public void DeleteMap(MapId mapID)
        {
            if (!_maps.TryGetValue(mapID, out var map))
            {
                throw new InvalidOperationException($"Attempted to delete nonexistant map '{mapID}'");
            }

            // grids are cached because Delete modifies collection
            foreach (var grid in map.GetAllGrids().ToList())
            {
                DeleteGrid(grid.Index);
            }

            MapDestroyed?.Invoke(this, new MapEventArgs(_maps[mapID]));
            _maps.Remove(mapID);

            if (_netManager.IsClient)
            {
                return;
            }

            var msg = _netManager.CreateNetMessage <MsgMap>();

            msg.MessageType = MapMessage.DeleteMap;
            msg.MapIndex    = mapID;

            _netManager.ServerSendToAll(msg);
        }
コード例 #2
0
        /// <inheritdoc />
        public void DeleteMap(MapId mapID)
        {
            if (!_maps.ContainsKey(mapID))
            {
                Logger.Warning("[MAP] Attempted to delete nonexistent map.");
                return;
            }

            MapDestroyed?.Invoke(this, new MapEventArgs(_maps[mapID]));
            _maps.Remove(mapID);

            if(_netManager.IsClient)
                return;

            var msg = _netManager.CreateNetMessage<MsgMap>();

            msg.MessageType = MapMessage.DeleteMap;
            msg.MapIndex = mapID;

            _netManager.ServerSendToAll(msg);
        }