Beispiel #1
0
        private void UndoInsert(EntityPlayer sender)
        {
            var userId = 0;

            if (sender != null)
            {
                userId = sender.entityId;
            }
            if (!_undoCache.ContainsKey(userId))
            {
                return;
            }

            if (_undoCache[userId].Count <= 0)
            {
                return;
            }

            var pCache = _undoCache[userId][_undoCache[userId].Count - 1];

            if (pCache != null)
            {
                var p = new Prefab();
                p.Load(Utils.GetGameDir(UndoDir), pCache.Filename);
                BCImport.InsertPrefab(p, pCache.Pos.x, pCache.Pos.y, pCache.Pos.z, pCache.Pos);

                //workaround for multi dim blocks, insert undo prefab twice
                //todo: clear all blocks (turn to air) before inserting the prefab instead
                BCImport.InsertPrefab(p, pCache.Pos.x, pCache.Pos.y, pCache.Pos.z, pCache.Pos);

                var cacheFile = Utils.GetGameDir($"{UndoDir}{pCache.Filename}");
                if (Utils.FileExists($"{cacheFile}.tts"))
                {
                    Utils.FileDelete($"{cacheFile}.tts");
                }
                if (Utils.FileExists($"{cacheFile}.xml"))
                {
                    Utils.FileDelete($"{cacheFile}.xml");
                }
            }
            _undoCache[userId].RemoveAt(_undoCache[userId].Count - 1);
        }
Beispiel #2
0
        private void UndoInsert(EntityPlayer sender)
        {
            var userId = 0;

            if (sender != null)
            {
                userId = sender.entityId;
            }
            if (!_undoCache.ContainsKey(userId))
            {
                return;
            }

            if (_undoCache[userId].Count <= 0)
            {
                return;
            }

            var pCache = _undoCache[userId][_undoCache[userId].Count - 1];

            if (pCache != null)
            {
                var p = new Prefab();
                p.Load(Utils.GetGameDir(UndoDir), pCache.Filename);
                BCImport.InsertPrefab(p, pCache.Pos.x, pCache.Pos.y, pCache.Pos.z, pCache.Pos);

                var cacheFile = Utils.GetGameDir($"{UndoDir}{pCache.Filename}");
                if (Utils.FileExists($"{cacheFile}.tts"))
                {
                    Utils.FileDelete($"{cacheFile}.tts");
                }
                if (Utils.FileExists($"{cacheFile}.xml"))
                {
                    Utils.FileDelete($"{cacheFile}.xml");
                }
            }
            _undoCache[userId].RemoveAt(_undoCache[userId].Count - 1);
        }