public override void Init(ITorchBase torch) { //Settings S = new Settings(); base.Init(torch); //Grab Settings string path = Path.Combine(StoragePath, "QuantumHangar.cfg"); _config = Persistent <Settings> .Load(path); if (Config.FolderDirectory == null || Config.FolderDirectory == "") { Config.FolderDirectory = Path.Combine(StoragePath, "QuantumHangar"); Directory.CreateDirectory(Config.FolderDirectory); } MainPlayerDirectory = Path.Combine(Config.FolderDirectory, "PlayerHangars"); Directory.CreateDirectory(MainPlayerDirectory); TorchSession = Torch.Managers.GetManager <TorchSessionManager>(); if (TorchSession != null) { TorchSession.SessionStateChanged += SessionChanged; } if (Config.GridMarketEnabled) { Controller = new HangarMarketController(); } else { Log.Info("Starting plugin WITHOUT the Hangar Market!"); } PatchManager manager = DependencyProviderExtensions.GetManager <PatchManager>(Torch.Managers); Patcher patcher = new Patcher(); patcher.Apply(manager.AcquireContext(), this); //Load files MigrateHangar(); }
private bool CheckGridForSale(GridStamp Stamp, int ID) { if (!Stamp.GridForSale) { //if grid is not for sale, remove any confirmations PlayerConfirmations.Remove(SteamID); return(true); } else { if (!PlayerConfirmations.TryGetValue(SteamID, out int Selection)) { //Prompt user if (Config.RestockAmount != 0) { Chat.Respond($"This grid is for sale! Run this command again to pay {Config.RestockAmount}sc to remove it from the market and load it in!"); } else { Chat.Respond("This grid is for sale! Run this command again to confirm removal of sell offer and load it in!"); } PlayerConfirmations.Add(SteamID, ID); return(false); } else { if (Selection != ID) { //If this grid is for sale and doesnt match our first selection need to remove it from the list and call this function again. PlayerConfirmations.Remove(SteamID); return(CheckGridForSale(Stamp, ID)); } //Remove market offer HangarMarketController.RemoveMarketListing(SteamID, Stamp.GridName); PlayerConfirmations.Remove(SteamID); return(true); } } }
public bool SellSelectedGrid(GridStamp Stamp, long Price, string Description) { Stamp.GridForSale = true; MarketListing NewListing = new MarketListing(Stamp); NewListing.SetUserInputs(Description, Price); NewListing.Seller = Identity.DisplayName; //We will set this into the file. (in the block we will dynamically get palyer name and faction) NewListing.SetPlayerData(SteamID, Identity.IdentityId); HangarMarketController.SaveNewMarketFile(NewListing); //Save player file SavePlayerFile(); HangarMarketController.NewGridOfferListed(NewListing); return(true); }