public static bool UndoSetBlocks(EntityPlayer sender) { var userId = 0; if (sender != null) { userId = sender.entityId; } if (!_undoCache.ContainsKey(userId)) { return(false); } if (_undoCache[userId].Count <= 0) { return(false); } var pCache = _undoCache[userId][_undoCache[userId].Count - 1]; if (pCache != null) { var prefab = new Prefab(); prefab.Load(Utils.GetGameDir(UndoDir), pCache.Filename); BCImport.InsertPrefab(GameManager.Instance.World, prefab, 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); return(true); }
public static 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); }