Exemplo n.º 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 (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);
        }
Exemplo n.º 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 - 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);
        }