ClearBrush() 공개 메소드

public ClearBrush ( ) : void
리턴 void
예제 #1
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            if (mi.Button == MouseButton.Left && (mi.Event == MouseInputEvent.Up || mi.Event == MouseInputEvent.Down))
            {
                var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);
                switch (state)
                {
                case State.SelectFirst:
                    if (mi.Event != MouseInputEvent.Down)
                    {
                        break;
                    }
                    start = cell;
                    selectionLayer.SetCopyRegion(start, end);
                    state = State.SelectSecond;
                    break;

                case State.SelectSecond:
                    if (mi.Event != MouseInputEvent.Up)
                    {
                        break;
                    }
                    end = cell;
                    selectionLayer.SetCopyRegion(start, end);
                    state = State.Paste;
                    break;

                case State.Paste:
                {
                    var gridType = worldRenderer.World.Map.Grid.Type;
                    var source   = CellRegion.BoundingRegion(gridType, new[] { start, end });
                    Copy(source, cell - end);
                    editorWidget.ClearBrush();
                    break;
                }
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            if (mi.Button == MouseButton.Left && AllowResourceAt(cell))
            {
                var type  = (byte)ResourceType.ResourceType;
                var index = (byte)ResourceType.MaxDensity;
                world.Map.Resources[cell] = new ResourceTile(type, index);
            }

            return(true);
        }
예제 #3
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                editorWidget.ClearBrush();
                return(true);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
            {
                // Check the actor is inside the map
                if (!footprint.All(c => world.Map.MapTiles.Value.Contains(cell + locationOffset + c)))
                {
                    return(true);
                }

                var newActorReference = new ActorReference(Actor.Name);
                newActorReference.Add(new OwnerInit(owner.Name));

                cell += locationOffset;
                newActorReference.Add(new LocationInit(cell));

                var ios = Actor.Traits.GetOrDefault <IOccupySpaceInfo>();
                if (ios != null && ios.SharesCell)
                {
                    var subcell = editorLayer.FreeSubCellAt(cell);
                    if (subcell != SubCell.Invalid)
                    {
                        newActorReference.Add(new SubCellInit(subcell));
                    }
                }

                var initDict = newActorReference.InitDict;

                if (Actor.Traits.Contains <IFacingInfo>())
                {
                    initDict.Add(new FacingInit(facing));
                }

                if (Actor.Traits.Contains <TurretedInfo>())
                {
                    initDict.Add(new TurretFacingInit(facing));
                }

                editorLayer.Add(newActorReference);
            }

            return(true);
        }
예제 #4
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            if (mi.Button == MouseButton.Left)
            {
                if (mi.Event == MouseInputEvent.Down)
                {
                    painting = true;
                }
                else if (mi.Event == MouseInputEvent.Up)
                {
                    painting = false;
                }
            }

            if (!painting)
            {
                return(true);
            }

            if (mi.Event != MouseInputEvent.Down && mi.Event != MouseInputEvent.Move)
            {
                return(true);
            }

            var cell     = worldRenderer.Viewport.ViewToWorld(mi.Location);
            var isMoving = mi.Event == MouseInputEvent.Move;

            if (mi.Modifiers.HasModifier(Modifiers.Shift))
            {
                FloodFillWithBrush(cell, isMoving);
                painting = false;
            }
            else
            {
                PaintCell(cell, isMoving);
            }

            return(true);
        }
예제 #5
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            if (editorCursor.CurrentToken != cursorToken)
            {
                return(false);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            if (mi.Button == MouseButton.Left && mi.Event != MouseInputEvent.Up && AllowResourceAt(cell))
            {
                var type  = (byte)ResourceType.ResourceType;
                var index = (byte)ResourceType.MaxDensity;
                action.Add(new CellResource(cell, world.Map.Resources[cell], new ResourceTile(type, index)));
                resourceAdded = true;
            }
            else if (resourceAdded && mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
            {
                editorActionManager.Add(action);
                action        = new AddResourcesEditorAction(world.Map, ResourceType);
                resourceAdded = false;
            }

            return(true);
        }
예제 #6
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            if (editorCursor.CurrentToken != cursorToken)
            {
                return(false);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            if (mi.Button == MouseButton.Left && mi.Event != MouseInputEvent.Up && resourceLayer.CanAddResource(ResourceType, cell))
            {
                action.Add(new CellResource(cell, resourceLayer.GetResource(cell), ResourceType));
                resourceAdded = true;
            }
            else if (resourceAdded && mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
            {
                editorActionManager.Add(action);
                action        = new AddResourcesEditorAction(world.Map, ResourceType, resourceLayer);
                resourceAdded = false;
            }

            return(true);
        }
예제 #7
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            if (editorCursor.CurrentToken != cursorToken)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
            {
                // Check the actor is inside the map
                var actor = editorCursor.Actor;
                if (!actor.Footprint.All(c => world.Map.Tiles.Contains(c.Key)))
                {
                    return(true);
                }

                var action = new AddActorAction(editorLayer, actor.Export());
                editorActionManager.Add(action);
            }

            return(true);
        }
예제 #8
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location - worldRenderer.ScreenPxOffset(centerOffset));

            if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
            {
                // Check the actor is inside the map
                if (!footprint.All(c => world.Map.Tiles.Contains(cell + c)))
                {
                    return(true);
                }

                // Enforce first entry of ValidOwnerNames as owner if the actor has RequiresSpecificOwners
                var action = new AddActorAction(editorLayer, Actor, cell, owner, facing);
                editorActionManager.Add(action);
            }

            return(true);
        }
예제 #9
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            if (mi.Button == MouseButton.Left)
            {
                if (mi.Event == MouseInputEvent.Down)
                {
                    painting = true;
                }
                else if (mi.Event == MouseInputEvent.Up)
                {
                    painting = false;
                }
            }

            if (!painting)
            {
                return(true);
            }

            var map       = world.Map;
            var mapTiles  = map.MapTiles.Value;
            var mapHeight = map.MapHeight.Value;
            var cell      = worldRenderer.Viewport.ViewToWorld(mi.Location);

            if (mi.Event != MouseInputEvent.Down && mi.Event != MouseInputEvent.Move)
            {
                return(true);
            }

            var rules      = map.Rules;
            var tileset    = rules.TileSets[map.Tileset];
            var template   = tileset.Templates[Template];
            var baseHeight = mapHeight.Contains(cell) ? mapHeight[cell] : (byte)0;

            if (mi.Event == MouseInputEvent.Move && PlacementOverlapsSameTemplate(template, cell))
            {
                return(true);
            }

            var i = 0;

            for (var y = 0; y < template.Size.Y; y++)
            {
                for (var x = 0; x < template.Size.X; x++, i++)
                {
                    if (template.Contains(i) && template[i] != null)
                    {
                        var index = template.PickAny ? (byte)Game.CosmeticRandom.Next(0, template.TilesCount) : (byte)i;
                        var c     = cell + new CVec(x, y);
                        if (!mapTiles.Contains(c))
                        {
                            continue;
                        }

                        mapTiles[c]  = new TerrainTile(Template, index);
                        mapHeight[c] = (byte)(baseHeight + template[index].Height).Clamp(0, map.Grid.MaximumTerrainHeight);
                    }
                }
            }

            return(true);
        }
예제 #10
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                if (mi.Event == MouseInputEvent.Up)
                {
                    editorWidget.ClearBrush();
                    return(true);
                }

                return(false);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location - worldRenderer.ScreenPxOffset(centerOffset));

            if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
            {
                // Check the actor is inside the map
                if (!footprint.All(c => world.Map.Tiles.Contains(cell + c)))
                {
                    return(true);
                }

                // Enforce first entry of ValidOwnerNames as owner if the actor has RequiresSpecificOwners
                var ownerName         = owner.Name;
                var specificOwnerInfo = Actor.TraitInfoOrDefault <RequiresSpecificOwnersInfo>();
                if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName))
                {
                    ownerName = specificOwnerInfo.ValidOwnerNames.First();
                }

                var newActorReference = new ActorReference(Actor.Name);
                newActorReference.Add(new OwnerInit(ownerName));

                newActorReference.Add(new LocationInit(cell));

                var ios = Actor.TraitInfoOrDefault <IOccupySpaceInfo>();
                if (ios != null && ios.SharesCell)
                {
                    var subcell = editorLayer.FreeSubCellAt(cell);
                    if (subcell != SubCell.Invalid)
                    {
                        newActorReference.Add(new SubCellInit(subcell));
                    }
                }

                var initDict = newActorReference.InitDict;

                if (Actor.HasTraitInfo <IFacingInfo>())
                {
                    initDict.Add(new FacingInit(facing));
                }

                if (Actor.HasTraitInfo <TurretedInfo>())
                {
                    initDict.Add(new TurretFacingInit(facing));
                }

                editorLayer.Add(newActorReference);
            }

            return(true);
        }