Пример #1
0
        public static bool TransferGrid(ulong From, ulong To, string GridName)
        {
            try
            {
                Log.Error("Starting Grid Transfer!");

                var FromInfo = new PlayerInfo();
                FromInfo.LoadFile(Hangar.MainPlayerDirectory, From);

                if (!FromInfo.GetGrid(GridName, out GridStamp Stamp, out string error))
                {
                    Log.Error("Failed to get grid! " + error);
                    return(false);
                }


                string GridPath = Stamp.GetGridPath(FromInfo.PlayerFolderPath);
                string FileName = Path.GetFileName(GridPath);



                FromInfo.Grids.Remove(Stamp);
                FromInfo.SaveFile();



                var ToInfo = new PlayerInfo();
                ToInfo.LoadFile(Hangar.MainPlayerDirectory, To);
                ToInfo.FormatGridName(Stamp);


                //Call gridstamp transferred as it will force load near player, and transfer on load
                Stamp.Transfered();

                ToInfo.Grids.Add(Stamp);

                //Make sure to create directory
                Directory.CreateDirectory(ToInfo.PlayerFolderPath);
                File.Move(GridPath, Path.Combine(ToInfo.PlayerFolderPath, Stamp.GridName + ".sbc"));

                ToInfo.SaveFile();
                Log.Error("Moved Grid!");
            }
            catch (Exception Ex)
            {
                Log.Error(Ex);
                return(false);
            }


            return(true);
        }