Exemplo n.º 1
0
        public void Paste()
        {
            if (this.Initialized)
            {
                MemoryStream stream = null;
                IDataObject  obj    = Clipboard.GetDataObject();
                const string format = "aeon_entities";

                if (obj.GetDataPresent(format))
                {
                    stream = obj.GetData(format) as MemoryStream;
                }

                EntitySelectionTool.Instance.SelectedEntities.Clear();
                BinaryInput bin = new BinaryInput(stream);

                int c = bin.ReadInt32();
                for (int i = 0; i < c; i++)
                {
                    int temp_index = bin.ReadInt32();
                    int x          = (int)bin.ReadSingle() >> 4;
                    int y          = (int)bin.ReadSingle() >> 4;

                    AddEntityAction act = new AddEntityAction(EditorEngine.Instance.World.EntityContainer.All()[temp_index], new Vector2(x, y));
                    EditorEngine.Instance.GetActionManager().Execute(act);

                    MapEntity result = act.worldEntity;
                    EntitySelectionTool.Instance.SelectedEntities.Add(result);
                }
            }
        }
Exemplo n.º 2
0
        private void onMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                EntityTemplate model = FrmEntitySelector.Instance.selectedEntity;

                if (model != null)
                {
                    AddEntityAction action = new AddEntityAction(
                        model, new Vector2(xt, yt));

                    EditorEngine.Instance.GetActionManager().Execute(action);
                }
            }
        }
Exemplo n.º 3
0
        public IAction Read()
        {
            IAction     result = null;
            BinaryInput stream = _stream as BinaryInput;
            int         i      = stream.ReadInt32();

            if (i == 1)
            {
                result = new SetTileAction();
            }
            if (i == 2)
            {
                result = new MultiAction();
            }
            if (i == 3)
            {
                result = new FillAction();
            }
            if (i == 4)
            {
                result = new RectangleAction();
            }
            if (i == 5)
            {
                result = new AddEntityAction();
            }
            if (i == 6)
            {
                result = new RemoveEntityAction();
            }

            IEncodable encodable = result as IEncodable;

            if (encodable != null)
            {
                encodable.Decode(stream);
            }
            return(result);
        }