private bool RequireLoadCurrency(GridStamp Grid) { //MyObjectBuilder_Definitions(MyParticlesManager) if (!Config.RequireCurrency) { return(true); } else { long LoadCost = 0; switch (Config.HangarLoadCostType) { case CostType.BlockCount: //If grid is station LoadCost = Convert.ToInt64(Grid.NumberofBlocks * Config.LoadStaticGridCurrency); break; case CostType.Fixed: LoadCost = Convert.ToInt64(Config.LoadStaticGridCurrency); break; case CostType.PerGrid: LoadCost += Convert.ToInt64(Grid.StaticGrids * Config.LoadStaticGridCurrency); LoadCost += Convert.ToInt64(Grid.LargeGrids * Config.LoadLargeGridCurrency); LoadCost += Convert.ToInt64(Grid.SmallGrids * Config.LoadSmallGridCurrency); break; } TryGetPlayerBalance(out long Balance); if (Balance >= LoadCost) { //Check command status! string command = Grid.GridName; var confirmationCooldownMap = Hangar.ConfirmationsMap; if (confirmationCooldownMap.TryGetValue(IdentityID, out CurrentCooldown confirmationCooldown)) { if (!confirmationCooldown.CheckCommandStatus(command)) { //Confirmed command! Update player balance! confirmationCooldownMap.Remove(IdentityID); Chat?.Respond("Confirmed! Loading grid!"); ChangeBalance(-1 * LoadCost); return(true); } else { Chat?.Respond("Loading this grid will cost " + LoadCost + " SC. Run this command again within 30 secs to continue!"); confirmationCooldown.StartCooldown(command); return(false); } } else { Chat?.Respond("Loading this grid will cost " + LoadCost + " SC. Run this command again within 30 secs to continue!"); confirmationCooldown = new CurrentCooldown(); confirmationCooldown.StartCooldown(command); confirmationCooldownMap.Add(IdentityID, confirmationCooldown); return(false); } } else { long Remaing = LoadCost - Balance; Chat?.Respond("You need an additional " + Remaing + " SC to perform this action!"); return(false); } } }
private bool RequireSaveCurrency(GridResult result) { //MyObjectBuilder_Definitions(MyParticlesManager) if (!Config.RequireCurrency) { return(true); } else { long SaveCost = 0; switch (Config.HangarSaveCostType) { case CostType.BlockCount: foreach (MyCubeGrid grid in result.Grids) { if (grid.GridSizeEnum == MyCubeSize.Large) { if (grid.IsStatic) { //If grid is station SaveCost += Convert.ToInt64(grid.BlocksCount * Config.CustomStaticGridCurrency); } else { //If grid is large grid SaveCost += Convert.ToInt64(grid.BlocksCount * Config.CustomLargeGridCurrency); } } else { //if its a small grid SaveCost += Convert.ToInt64(grid.BlocksCount * Config.CustomSmallGridCurrency); } } //Multiply by break; case CostType.Fixed: SaveCost = Convert.ToInt64(Config.CustomStaticGridCurrency); break; case CostType.PerGrid: foreach (MyCubeGrid grid in result.Grids) { if (grid.GridSizeEnum == MyCubeSize.Large) { if (grid.IsStatic) { //If grid is station SaveCost += Convert.ToInt64(Config.CustomStaticGridCurrency); } else { //If grid is large grid SaveCost += Convert.ToInt64(Config.CustomLargeGridCurrency); } } else { //if its a small grid SaveCost += Convert.ToInt64(Config.CustomSmallGridCurrency); } } break; } TryGetPlayerBalance(out long Balance); if (Balance >= SaveCost) { //Check command status! string command = result.BiggestGrid.DisplayName; var confirmationCooldownMap = Hangar.ConfirmationsMap; if (confirmationCooldownMap.TryGetValue(IdentityID, out CurrentCooldown confirmationCooldown)) { if (!confirmationCooldown.CheckCommandStatus(command)) { //Confirmed command! Update player balance! confirmationCooldownMap.Remove(IdentityID); Chat?.Respond("Confirmed! Saving grid!"); ChangeBalance(-1 * SaveCost); return(true); } else { Chat?.Respond("Saving this grid in your hangar will cost " + SaveCost + " SC. Run this command again within 30 secs to continue!"); confirmationCooldown.StartCooldown(command); return(false); } } else { Chat?.Respond("Saving this grid in your hangar will cost " + SaveCost + " SC. Run this command again within 30 secs to continue!"); confirmationCooldown = new CurrentCooldown(); confirmationCooldown.StartCooldown(command); confirmationCooldownMap.Add(IdentityID, confirmationCooldown); return(false); } } else { long Remaing = SaveCost - Balance; Chat?.Respond("You need an additional " + Remaing + " SC to perform this action!"); return(false); } } }