public bool LoadGrid(int ID, out IEnumerable <MyObjectBuilder_CubeGrid> Grids, out GridStamp Stamp) { Grids = null; Stamp = null; if (ID - 1 >= SelectedPlayerFile.Grids.Count || ID < 1) { Chat?.Respond("Invalid Index! Grid doent exsist in that slot!"); return(false); } Stamp = SelectedPlayerFile.GetGrid(ID); string GridPath = Path.Combine(PlayersFolderPath, Stamp.GridName + ".sbc"); Log.Warn("Attempting to load grid @" + GridPath); if (!GridSerializer.LoadGrid(GridPath, out Grids)) { return(false); } PluginDependencies.BackupGrid(Grids.ToList(), IdentityID); GridSerializer.TransferGridOwnership(Grids, IdentityID); return(true); }
public bool TryGetGrids(string PlayersFolderPath, out IEnumerable <MyObjectBuilder_CubeGrid> Grids) { Grids = null; string GridPath = Path.Combine(PlayersFolderPath, GridName + ".sbc"); if (!GridSerializer.LoadGrid(GridPath, out Grids)) { return(false); } return(true); }
public static void SetGridPreview(long EntityID, ulong Owner, string GridName) { if (!ValidGrid(Owner, GridName, out MarketListing Offer, out string GridPath)) { return; } if (Offer.NumberofBlocks > 100000) { Log.Warn("MarketPreview Blocked. Grid is greater than 100000 blocks"); return; } //Need async Log.Warn("Loading Grid"); if (!GridSerializer.LoadGrid(GridPath, out IEnumerable <MyObjectBuilder_CubeGrid> GridBuilders)) { RemoveMarketListing(Owner, GridName); return; } //Now attempt to load grid if (MyEntities.TryGetEntityById(EntityID, out MyEntity entity)) { MyProjectorBase proj = entity as MyProjectorBase; if (proj != null) { proj.SendRemoveProjection(); var Grids = GridBuilders.ToList(); Log.Warn("Setting projection!"); SendNewProjection.Invoke(proj, new object[] { Grids }); } } }