public IMapLayer AddLayer(string groupName, string layerName, string layerDefinitionId)
        {
            Check.ArgumentNotEmpty(layerName, nameof(layerName));
            Check.ArgumentNotEmpty(layerDefinitionId, nameof(layerDefinitionId));
            Check.ThatPreconditionIsMet(ResourceIdentifier.Validate(layerDefinitionId), $"ResourceIdentifier.Validate({nameof(layerDefinitionId)})");
            Check.ThatPreconditionIsMet(ResourceIdentifier.GetResourceTypeAsString(layerDefinitionId) == ResourceTypes.LayerDefinition.ToString(), $"ResourceIdentifier.GetResourceTypeAsString({nameof(layerDefinitionId)}) == ResourceTypes.LayerDefinition.ToString()");
            if (!string.IsNullOrEmpty(groupName))
            {
                Check.ThatPreconditionIsMet(this.GetGroupByName(groupName) != null, $"There should be an existing group for <{nameof(groupName)}>");
            }
            var layer = new MapLayerType()
            {
                Parent         = this,
                ExpandInLegend = true,
                LegendLabel    = layerName,
                Name           = layerName,
                ResourceId     = layerDefinitionId,
                ShowInLegend   = true,
                Visible        = true,
                Selectable     = true
            };

            layer.Group = string.IsNullOrEmpty(groupName) ? string.Empty : groupName;

            this.MapLayer.Insert(0, layer);
            OnPropertyChanged(nameof(MapLayer));

            this.AutoSetExtentsFromLayer(layer.ResourceId);

            return(layer);
        }
        public IMapLayer InsertLayer(int index, string groupName, string layerName, string layerDefinitionId)
        {
            Check.ThatArgumentIsBetweenRange(index, 0, this.MapLayer.Count, true, nameof(index) + " (" + index + ") between [" + 0 + "," + this.MapLayer.Count + "]");
            Check.ArgumentNotEmpty(layerName, nameof(layerName));
            Check.ArgumentNotEmpty(layerDefinitionId, nameof(layerDefinitionId));
            Check.ThatPreconditionIsMet(ResourceIdentifier.Validate(layerDefinitionId), $"ResourceIdentifier.Validate({nameof(layerDefinitionId)})");
            Check.ThatPreconditionIsMet(ResourceIdentifier.GetResourceTypeAsString(layerDefinitionId) == ResourceTypes.LayerDefinition.ToString(), $"ResourceIdentifier.GetResourceTypeAsString({nameof(layerDefinitionId)}) == ResourceTypes.LayerDefinition.ToString()");
            if (!string.IsNullOrEmpty(groupName))
            {
                Check.ArgumentNotNull(this.GetGroupByName(groupName), $"Group for <{nameof(groupName)}>");
            }
            var layer = new MapLayerType()
            {
                Parent         = this,
                ExpandInLegend = true,
                LegendLabel    = layerName,
                Name           = layerName,
                ResourceId     = layerDefinitionId,
                ShowInLegend   = true,
                Visible        = true,
                Selectable     = true
            };

            layer.Group = string.IsNullOrEmpty(groupName) ? string.Empty : groupName;
            this.MapLayer.Insert(index, layer);
            return(layer);
        }
Beispiel #3
0
        /// <summary>
        /// Defines a map layer to be added to the layers manager
        /// </summary>
        /// <param name="type">the type of the layer</param>
        /// <param name="url">the url of the layer if it is an online annotations layer</param>
        public MapLayerDef(MapLayerType type, string url)
        {
            LayerType = type;
            LayerURL = url;

            InitializePredefinedLayers();
        }
Beispiel #4
0
 public MapLayer(MapRoot Parent, MapLayerType Type, string TextureName)
 {
     LayerType = Type;
     this.Parent = Parent;
     Tiles = new uint[(int)Parent.Dimensions.Width, (int)Parent.Dimensions.Height];
     this.TextureName = TextureName;
     LayerTexture = Moxy.ContentManager.Load<Texture2D>(TextureName);
     LayerBounds = Parent.CreateBoundings(LayerTexture);
 }
        public IMapLayer AddLayer(IMapLayer layerToInsertAbove, string groupName, string layerName, string layerDefinitionId)
        {
            Check.ArgumentNotEmpty(layerName, nameof(layerName));
            Check.ArgumentNotEmpty(layerDefinitionId, nameof(layerDefinitionId));
            Check.ThatPreconditionIsMet(ResourceIdentifier.Validate(layerDefinitionId), $"ResourceIdentifier.Validate({nameof(layerDefinitionId)})");
            Check.ThatPreconditionIsMet(ResourceIdentifier.GetResourceTypeAsString(layerDefinitionId) == ResourceTypes.LayerDefinition.ToString(), $"ResourceIdentifier.GetResourceTypeAsString({nameof(layerDefinitionId)}) == ResourceTypes.LayerDefinition.ToString()");
            if (!string.IsNullOrEmpty(groupName))
            {
                Check.ArgumentNotNull(this.GetGroupByName(groupName), $"Group for <{nameof(groupName)}>");
            }
            var layer = new MapLayerType()
            {
                Parent         = this,
                ExpandInLegend = true,
                LegendLabel    = layerName,
                Name           = layerName,
                ResourceId     = layerDefinitionId,
                ShowInLegend   = true,
                Visible        = true,
                Selectable     = true
            };

            layer.Group = string.IsNullOrEmpty(groupName) ? string.Empty : groupName;

            if (layerToInsertAbove != null)
            {
                var clayerToInsertAbove = layerToInsertAbove as MapLayerType;
                if (clayerToInsertAbove != null)
                {
                    var idx = this.MapLayer.IndexOf(clayerToInsertAbove);
                    if (idx >= 0)
                    {
                        this.MapLayer.Insert(idx, layer);
                    }
                    else
                    {
                        this.MapLayer.Add(layer);
                    }
                }
                else
                {
                    this.MapLayer.Add(layer);
                }
            }
            else
            {
                this.MapLayer.Add(layer);
            }
            OnPropertyChanged(nameof(MapLayer));

            this.AutoSetExtentsFromLayer(layer.ResourceId);

            return(layer);
        }
Beispiel #6
0
 internal MapLayerBuilder(int width, int height, MapLayerType layerType)
 {
     this.Width  = width;
     this.Height = height;
     LayerType   = layerType;
     CellValues  = new int[width * height];
     for (int i = 0; i < CellValues.Length; i++)
     {
         CellValues[i] = MapLayerModel.UNSET_CELL;
     }
 }
Beispiel #7
0
        public MapLayerBuilder AddLayer(MapLayerType layerType)
        {
            if (Width == 0 || Height == 0)
            {
                throw new InvalidOperationException("Width and Height must have non zero positive values");
            }

            var layerBuilder = new MapLayerBuilder(Width, Height, layerType);

            Layers.Add(layerBuilder);
            return(layerBuilder);
        }
Beispiel #8
0
        /// <summary>
        /// The layer type. Supported types are "tile" and "shape".
        /// </summary>
        /// <param name="value">The value that configures the type.</param>
        public MapLayerBuilder Type(MapLayerType value)
        {
            container.Type = value;

            return this;
        }
Beispiel #9
0
 /// <summary>
 /// Defines a Map layer to be added to the layers manager
 /// </summary>
 /// <param name="type"></param>
 public MapLayerDef(MapLayerType type)
 {
     LayerType = type;
     InitializePredefinedLayers();
 }
Beispiel #10
0
        public override void Update(GameTime gameTime)
        {
            camera.Update(Moxy.Graphics);
            map.Update(gameTime);

            var mouseState = Mouse.GetState ();
            var state = Keyboard.GetState ();

            if (WasKeyPressed (state, Keys.F1))
                currentTool = EditorTool.PlaceTiles;

            HandleCameraControls (state, gameTime);

            if (currentTool == EditorTool.PlaceTiles)
            {
                int tileID = currentTileID;
                if (WasKeyPressed(state, Keys.Right))
                    tileID++;// = (int)MathHelper.Min(tileID + 1, map.Boundings.Length - 1);
                else if (WasKeyPressed(state, Keys.Left))
                    tileID--;// = Helpers.LowerClamp(tileID - 1, 0);

                if (tileID < 0)
                    tileID = map.Boundings.Length + tileID;

                currentTileID = tileID%map.Boundings.Length;

                if (mouseState.LeftButton == ButtonState.Pressed)
                    SetTileAtPoint (new Vector2 (mouseState.X, mouseState.Y), currentTileID);
                if (WasKeyPressed (state, Keys.NumPad1))
                    currentLayer = MapLayerType.Base;
                if (WasKeyPressed (state, Keys.NumPad2))
                    currentLayer = MapLayerType.Decal;
                if (WasKeyPressed (state, Keys.NumPad3))
                    currentLayer = MapLayerType.Collision;

                if (WasKeyPressed (state, Keys.F5))
                    ExportMapData ();
            }

            // String debugging
            Vector2 mouseVec = new Vector2(mouseState.X, mouseState.Y);
            WorldAtCursor = camera.ScreenToWorld (mouseVec);
            TileAtCursor = new Vector2 ((int)WorldAtCursor.X / 64, (int)WorldAtCursor.Y / 64);

            oldMouse = mouseState;
            old = state;
        }
 bool isLavaOrWater(int x, int y, MapLayerType layerType)
 {
     var terrainType = (TerrainType)map.GetData(layerType, x, y);
     return terrainType == TerrainType.Lava || terrainType == TerrainType.Water;
 }
 //void addTriangle(List<Triangle> triangleList, List<Vector3> normalList, List<TerrainType> textureList, MapLayerType layer,
 //    Triangle2i triangle) {
 //        addTriangle(triangleList, normalList, textureList, layer,
 //            triangle.P0.X, triangle.P0.Y,
 //            triangle.P1.X, triangle.P1.Y,
 //            triangle.P2.X, triangle.P2.Y);
 //}
 void addTriangle(List<Triangle> triangleList, List<Vector3> normalList, List<TerrainType> textureList, MapLayerType layer,
     int p0x, int p0y, int p1x, int p1y, int p2x, int p2y)
 {
     triangleList.Add(new Triangle {
         P0 = GetMapVertex(p0x, p0y),
         P1 = GetMapVertex(p1x, p1y),
         P2 = GetMapVertex(p2x, p2y)
     });
     normalList.Add(normals[p0y, p0x]);
     normalList.Add(normals[p1y, p1x]);
     normalList.Add(normals[p2y, p2x]);
     //textureList.Add(TerrainType.Swamp);
     textureList.Add((TerrainType)map.GetData(layer, p0x, p0y));
 }
Beispiel #13
0
        /// <summary>
        /// The layer type. Supported types are "tile" and "shape".
        /// </summary>
        /// <param name="value">The value that configures the type.</param>
        public MapLayerBuilder Type(MapLayerType value)
        {
            container.Type = value;

            return(this);
        }
Beispiel #14
0
 /// <summary>
 /// Request data for all mainland (Linden managed) simulators
 /// </summary>
 public void RequestMainlandSims(MapLayerType layer)
 {
     RequestMapBlocks(layer, 0, 0, 65535, 65535, false);
 }
Beispiel #15
0
        public void RequestMapBlocks(MapLayerType layer, ushort minX, ushort minY, ushort maxX, ushort maxY, 
            bool returnNonExistent)
        {
            MapBlockRequestPacket request = new MapBlockRequestPacket();

            request.AgentData.AgentID = Client.Network.AgentID;
            request.AgentData.SessionID = Client.Network.SessionID;
            request.AgentData.Flags = (uint)layer;
            request.AgentData.Flags |= (uint)(returnNonExistent ? 0x10000 : 0);
            request.AgentData.EstateID = 0; // Filled in at the simulator
            request.AgentData.Godlike = false; // Filled in at the simulator

            request.PositionData.MinX = minX;
            request.PositionData.MinY = minY;
            request.PositionData.MaxX = maxX;
            request.PositionData.MaxY = maxY;

            Client.Network.SendPacket(request);
        }
Beispiel #16
0
 public MapLayerModel GetLayer(MapLayerType layerType)
 {
     return(Layers.First(layer => layer.LayerType == layerType));
 }
Beispiel #17
0
 public MapLayer(MapRoot Parent, MapLayerType Type)
 {
     LayerType = Type;
     this.Parent = Parent;
     Tiles = new uint[(int)Parent.Dimensions.Width, (int)Parent.Dimensions.Height];
 }
Beispiel #18
0
        public int GetLayerIndex(MapLayerType layerType)
        {
            var layer = Layers.First(item => item.LayerType == layerType);

            return(Layers.IndexOf(layer));
        }
Beispiel #19
0
 public byte GetData(MapLayerType layerType, int x, int y)
 {
     return layers[layerType].Data[y * Width + x];
 }
Beispiel #20
0
        void ReadLayer(BinaryReader binaryReader, MapLayerType type)
        {
            binaryReader.BaseStream.Seek(6, SeekOrigin.Current);
            var layer = new MapLayer();
            int seek = -4;
            while (layer.Width == 0) {
                layer.Width = binaryReader.ReadUInt16();
                seek += 2;
            }
            while (layer.Height == 0) {
                layer.Height = binaryReader.ReadUInt16();
                seek += 2;
            }
            binaryReader.BaseStream.Seek(6 - seek, SeekOrigin.Current);

            layer.Data = binaryReader.ReadBytes(layer.Width * layer.Height);
            layers[type] = layer;
        }
Beispiel #21
0
        public override void Update(GameTime gameTime)
        {
            Camera.Update(Moxy.Graphics);
            Map.Update(gameTime);

            var mouseState = Mouse.GetState ();
            var state = Keyboard.GetState ();

            if (IsFocused)
            {
                if (WasKeyPressed (state, Keys.F1))
                    currentTool = EditorTool.PlaceTiles;

                HandleCameraControls (state, gameTime);

                if (currentTool == EditorTool.PlaceTiles)
                {
                    if (enableTileHelper)
                        UpdateTileHelper (state);

                    if (mouseState.LeftButton == ButtonState.Pressed)
                        SetTileAtPoint (new Vector2 (mouseState.X, mouseState.Y), currentTileID);
                    if (WasKeyPressed (state, Keys.NumPad1))
                        CurrentLayer = MapLayerType.Base;
                    if (WasKeyPressed (state, Keys.NumPad2))
                        CurrentLayer = MapLayerType.Decal;
                    if (WasKeyPressed (state, Keys.NumPad3))
                        CurrentLayer = MapLayerType.Collision;

                    if (WasKeyPressed (state, Keys.F5))
                        ExportMapData();
                }

                if (Moxy.CurrentKeyboard.IsKeyDown (Keys.Tab))
                {
                    IsFocused = false;
                    Moxy.StateManager.Push ("TilePicker");
                }
                else if (Moxy.CurrentKeyboard.IsKeyDown(Keys.LeftControl) && Moxy.LastKeyboard.IsKeyUp(Keys.LeftControl))
                {
                    IsFocused = false;
                    Moxy.StateManager.Push("MapSerailizor");
                }

                // String debugging
                Vector2 mouseVec = new Vector2 (mouseState.X, mouseState.Y);
                WorldAtCursor = Camera.ScreenToWorld (mouseVec);
                TileAtCursor = new Vector2 ((int) WorldAtCursor.X / 64, (int) WorldAtCursor.Y / 64);
            }

            oldMouse = mouseState;
            old = state;
        }
Beispiel #22
0
        public void RequestMapLayer(MapLayerType layer)
        {
            //if (Client.Network.CurrentCaps.Capabilities.ContainsKey("MapLayer"))
            //if (false)
            //{
                //string url = Client.Network.CurrentCaps.Capabilities["MapLayer"];

                // FIXME: CAPS is currently disabled until the message pumps are implemented
            //}
            //else
            //{
                MapLayerRequestPacket request = new MapLayerRequestPacket();

                request.AgentData.AgentID = Client.Network.AgentID;
                request.AgentData.SessionID = Client.Network.SessionID;
                request.AgentData.Godlike = false; // Filled in at the simulator
                request.AgentData.Flags = (uint)layer;
                request.AgentData.EstateID = 0; // Filled in at the simulator

                Client.Network.SendPacket(request);
            //}
        }