diff --git a/Classes/DrugWarehouse.cs b/Classes/DrugWarehouse.cs index a8aa0b1a..c2fd91c9 100644 --- a/Classes/DrugWarehouse.cs +++ b/Classes/DrugWarehouse.cs @@ -91,12 +91,10 @@ public void CreateBlip(BlipSprite blipSprite = BlipSprite.BusinessForSale, BlipC } /// - public void ChangeBlip(string? blipName, BlipSprite blipSprite = BlipSprite.BusinessForSale, BlipColor blipColor = BlipColor.White) + public void ChangeBlip(BlipSprite blipSprite = BlipSprite.BusinessForSale, BlipColor blipColor = BlipColor.White) { if (BlipCreated) { - if (blipName is not null) - Blip!.Name = blipName; Blip!.Sprite = blipSprite; Blip!.Color = blipColor; } diff --git a/Constants.cs b/Constants.cs index 04af345c..36c69020 100644 --- a/Constants.cs +++ b/Constants.cs @@ -219,11 +219,17 @@ public static class Constants public static readonly Vector3 MissionMarkerScale = new(8f, 8f, 1.5f); public static readonly Color MissionMarkerColor = Color.FromArgb(255, 240, 200, 80); + + public static readonly Vector3 WarehouseEntranceFranklin = new(-320.3f, -1389.8f, 36.5f); - public static readonly Vector3 WarehouseLocationFranklin = new(466.3f, -1384.1f, 37.1f); + public static readonly Vector3 WarehouseLocationFranklin = new(-307.3f, -1399.5f, 41.6f); - public static readonly Vector3 WarehouseEntranceFranklin = new(477.71f, -1397.76f, 31.04f); + public static readonly Vector3 WarehouseMissionStartFranklin = new(-323.7f, -1400.5f, 31.8f); - public static readonly Vector3 WarehouseMissionStartFranklin = new(488.73f, 1400.86f, 29.31f); + public static readonly Vector3 WarehouseEntranceMichael = new(794.2f, -102.8f, 82f); + + public static readonly Vector3 WarehouseLocationMichael = new(799.5f, -94.6f, 80.6f); + + public static readonly Vector3 WarehouseMissionStartMichael = new(794.8f, -79.2f, 80.6f); } } diff --git a/Contracts/IPlayerProperty.cs b/Contracts/IPlayerProperty.cs index 1124cd73..243a8af0 100644 --- a/Contracts/IPlayerProperty.cs +++ b/Contracts/IPlayerProperty.cs @@ -60,7 +60,6 @@ public interface IPlayerProperty /// /// /// - /// - void ChangeBlip(string? blipName, BlipSprite blipSprite = BlipSprite.BusinessForSale, BlipColor blipColor = BlipColor.White); + void ChangeBlip(BlipSprite blipSprite = BlipSprite.BusinessForSale, BlipColor blipColor = BlipColor.White); } } diff --git a/Features/RewardSystem.cs b/Features/RewardSystem.cs new file mode 100644 index 00000000..72370005 --- /dev/null +++ b/Features/RewardSystem.cs @@ -0,0 +1,80 @@ +using GTA.UI; +using Los.Santos.Dope.Wars.Extension; +using Los.Santos.Dope.Wars.Persistence; +using System; +using System.ComponentModel; + +namespace Los.Santos.Dope.Wars.Features +{ + /// + /// The class servers as the handler for rewarding the currently played character throughout the game progress + /// + public static class RewardSystem + { + private static GameState? _gameState; + private static PlayerStats? _playerStats; + + /// + /// The property indicates if the method was called + /// + public static bool Initialized { get; private set; } + + /// + /// Standard constructor for the class + /// + static RewardSystem() { } + + /// + /// The method, run for every tick + /// + /// + /// + public static void OnTick(object sender, EventArgs e) + { + if (!Initialized) + return; + + if (_playerStats != Utils.GetPlayerStatsFromModel(_gameState!)) + { + _playerStats!.PropertyChanged -= OnCurrentLevelPropertyChanged; + _playerStats = Utils.GetPlayerStatsFromModel(_gameState!); + _playerStats.PropertyChanged += OnCurrentLevelPropertyChanged; + } + } + + /// + /// The method must be called from outside with the needed parameters + /// + /// + public static void Init(GameState gameState) + { + _gameState = gameState; + _playerStats = Utils.GetPlayerStatsFromModel(gameState); + _playerStats.PropertyChanged += OnCurrentLevelPropertyChanged; + Initialized = true; + } + + /// + /// The method is where the magic happens + /// + /// + /// + private static void OnCurrentLevelPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (sender is PlayerStats playerStats) + { + // this is what happens for every level up + Notification.Show($"Congratulations you have reached level ~y~{playerStats.CurrentLevel}~w~. Your bag size has been increased to ~y~{playerStats.MaxBagSize}~w~."); + + // this is when the warehouse reward has been granted + if (playerStats.CurrentLevel.Equals(5)) + { + playerStats.SpecialReward.Warehouse |= Enums.WarehouseStates.Unlocked; + Notification.Show($"Congratulations you have unlocked the ~y~warehouse~w~. Buy it to store drugs and drug money safely."); + // if we have come this far, save + Utils.SaveGameState(_gameState!); + } + } + } + } +} \ No newline at end of file diff --git a/Main.cs b/Main.cs index f9ce3488..1f785829 100644 --- a/Main.cs +++ b/Main.cs @@ -1,5 +1,6 @@ using GTA; using Los.Santos.Dope.Wars.Extension; +using Los.Santos.Dope.Wars.Features; using Los.Santos.Dope.Wars.Missions; using Los.Santos.Dope.Wars.Persistence; using System; @@ -15,8 +16,9 @@ public class Main : Script private static bool _gameStateLoaded; private static bool _traffickingLoaded; private static bool _warehouseLoaded; - private static GameSettings GameSettings = null!; - private static GameState GameState = null!; + private static bool _rewardSystemLoaded; + private static GameSettings? GameSettings; + private static GameState? GameState; /// /// The property, this is the main directory for logging and saving the game config and the game state @@ -31,16 +33,16 @@ public Main() { Interval = 10; ScriptDirectory = BaseDirectory; + Init(); Tick += OnTick; Tick += Trafficking.OnTick; Tick += Warehouse.OnTick; + Tick += RewardSystem.OnTick; Aborted += OnAborted; Aborted += Trafficking.OnAborted; - Aborted += Warehouse.OnAborted; - - Init(); + Aborted += Warehouse.OnAborted; } #endregion @@ -55,16 +57,23 @@ private void OnTick(object sender, EventArgs e) if (!_traffickingLoaded) { - Trafficking.Init(GameSettings, GameState); - _traffickingLoaded = true; - Logger.Status($"Trafficking loaded: {_traffickingLoaded}"); + Trafficking.Init(GameSettings!, GameState!); + _traffickingLoaded = Trafficking.Initialized; + Logger.Status($"{nameof(Trafficking)} loaded: {_traffickingLoaded}"); } if (!_warehouseLoaded) { - Warehouse.Init(GameState); - _warehouseLoaded = true; - Logger.Status($"Warehouse loaded: {_traffickingLoaded}"); + Warehouse.Init(GameState!); + _warehouseLoaded = Warehouse.Initialized; + Logger.Status($"{nameof(Warehouse)} loaded: {_traffickingLoaded}"); + } + + if (!_rewardSystemLoaded) + { + RewardSystem.Init(GameState!); + _rewardSystemLoaded = RewardSystem.Initialized; + Logger.Status($"{nameof(RewardSystem)} loaded: {_traffickingLoaded}"); } } @@ -74,7 +83,7 @@ private static void Init() { if (!_settingsLoaded || !_gameStateLoaded) { - Logger.Status($"Mod: {Constants.AssemblyName} - Vesion: {Constants.AssemblyVersion}"); + Logger.Status($"Game: {Constants.AssemblyName} - Vesion: {Constants.AssemblyVersion}"); if (!_settingsLoaded) { @@ -93,7 +102,7 @@ private static void Init() { GameState = loadedGameState; loadedGameState.LastRestock = ScriptHookUtils.GetGameDate().AddHours(-25); - Logger.Status($"Last game state loaded. Version: {GameSettings.Version}"); + Logger.Status($"Last game state loaded. Version: {GameSettings!.Version}"); _gameStateLoaded = success; } } diff --git a/Missions/Trafficking.cs b/Missions/Trafficking.cs index d63300f2..6a8291e9 100644 --- a/Missions/Trafficking.cs +++ b/Missions/Trafficking.cs @@ -14,14 +14,19 @@ namespace Los.Santos.Dope.Wars.Missions /// public class Trafficking { - private static List DrugDealers = null!; - private static GameSettings GameSettings = null!; - private static GameState GameState = null!; - private static Script Script = null!; - private static PlayerStats PlayerStats = null!; + private static List? _drugDealers; + private static GameSettings? _gameSettings; + private static GameState? _gameState; + private static PlayerStats? _playerStats; + private static Ped? _player; private static DrugDealer? CurrentDrugDealer { get; set; } + /// + /// The property indicates if the method was called + /// + public static bool Initialized { get; private set; } + /// /// The empty class constructor /// @@ -34,9 +39,11 @@ static Trafficking() { } /// public static void Init(GameSettings gameSettings, GameState gameState) { - GameSettings = gameSettings; - GameState = gameState; - DrugDealers = GetDrugDealers(); + _gameSettings = gameSettings; + _gameState = gameState; + _drugDealers = GetDrugDealers(); + _player = Game.Player.Character; + Initialized = true; } /// @@ -46,12 +53,12 @@ public static void Init(GameSettings gameSettings, GameState gameState) /// public static void OnAborted(object sender, EventArgs e) { - foreach (DrugDealer? dealer in DrugDealers) + foreach (DrugDealer? dealer in _drugDealers!) { dealer.DeleteBlip(); dealer.DeletePed(); } - DrugDealers.Clear(); + _drugDealers.Clear(); } /// @@ -61,46 +68,46 @@ public static void OnAborted(object sender, EventArgs e) /// public static void OnTick(object sender, EventArgs e) { - if (sender is Script script) - Script = script; - - while (GameState is null && GameState is null) + if (!Initialized) return; try { - Ped player = Game.Player.Character; - PlayerStats = Utils.GetPlayerStatsFromModel(GameState); + if (_player != Game.Player.Character) + _player = Game.Player.Character; + + if (_playerStats != Utils.GetPlayerStatsFromModel(_gameState!)) + _playerStats = Utils.GetPlayerStatsFromModel(_gameState!); // The dealer drug stash restock (quantity) - if (ScriptHookUtils.GetGameDate() > GameState.LastRestock.AddHours(GameSettings.DealerSettings.RestockIntervalHours)) + if (ScriptHookUtils.GetGameDate() > _gameState!.LastRestock.AddHours(_gameSettings!.DealerSettings.RestockIntervalHours)) { - GameState.LastRestock = ScriptHookUtils.GetGameDate(); + _gameState.LastRestock = ScriptHookUtils.GetGameDate(); - foreach (DrugDealer dealer in DrugDealers) + foreach (DrugDealer dealer in _drugDealers!) { dealer.DrugStash.Init(); - dealer.DrugStash.RestockQuantity(PlayerStats, GameSettings); - dealer.DrugStash.RefreshDrugMoney(PlayerStats, GameSettings); - dealer.DrugStash.RefreshCurrentPrice(PlayerStats, GameSettings); + dealer.DrugStash.RestockQuantity(_playerStats, _gameSettings); + dealer.DrugStash.RefreshDrugMoney(_playerStats, _gameSettings); + dealer.DrugStash.RefreshCurrentPrice(_playerStats, _gameSettings); } ScriptHookUtils.NotifyWithPicture("Anonymous", "Tip-off", "The drug dealers have been restocked.", 0); - Utils.SaveGameState(GameState); + Utils.SaveGameState(_gameState); } else // The dealer drug stash refresh (money & prices) - if (ScriptHookUtils.GetGameDate() > GameState.LastRefresh.AddHours(GameSettings.DealerSettings.RefreshIntervalHours)) + if (ScriptHookUtils.GetGameDate() > _gameState.LastRefresh.AddHours(_gameSettings.DealerSettings.RefreshIntervalHours)) { - GameState.LastRefresh = ScriptHookUtils.GetGameDate(); - foreach (DrugDealer dealer in DrugDealers) + _gameState.LastRefresh = ScriptHookUtils.GetGameDate(); + foreach (DrugDealer dealer in _drugDealers!) { - dealer.DrugStash.RefreshDrugMoney(PlayerStats, GameSettings); - dealer.DrugStash.RefreshCurrentPrice(PlayerStats, GameSettings); + dealer.DrugStash.RefreshDrugMoney(_playerStats, _gameSettings); + dealer.DrugStash.RefreshCurrentPrice(_playerStats, _gameSettings); } - Utils.SaveGameState(GameState); + Utils.SaveGameState(_gameState); } - foreach (DrugDealer dealer in DrugDealers) + foreach (DrugDealer dealer in _drugDealers!) { // creating the blips if not already created if (!dealer.BlipCreated) @@ -108,12 +115,12 @@ public static void OnTick(object sender, EventArgs e) dealer.CreateBlip(); } // if the player is in range of the dealer - if (player.IsInRange(dealer.Position, 100f)) + if (_player.IsInRange(dealer.Position, 100f)) { // if the ped was not created if (!dealer.PedCreated) { - (float health, float armor) = Utils.GetDealerHealthArmor(GameSettings.DealerSettings, PlayerStats.CurrentLevel); + (float health, float armor) = Utils.GetDealerHealthArmor(_gameSettings.DealerSettings, _playerStats.CurrentLevel); int money = dealer.DrugStash.Money; dealer.CreatePed(health, armor, money); } @@ -126,10 +133,10 @@ public static void OnTick(object sender, EventArgs e) } // now we are real close to the dealer - if (player.IsInRange(dealer.Position, 3f) && CurrentDrugDealer is null && Game.Player.WantedLevel == 0) + if (_player.IsInRange(dealer.Position, 3f) && CurrentDrugDealer is null && Game.Player.WantedLevel == 0) { CurrentDrugDealer = dealer; - DealMenu.Init(PlayerStats.DrugStash, (DrugStash)dealer.DrugStash, GameState); + DealMenu.Init(_playerStats.DrugStash, (DrugStash)dealer.DrugStash, _gameState); if (CheckIfDealerCanTrade(dealer)) DealMenu.ShowDealMenu = true; @@ -138,7 +145,7 @@ public static void OnTick(object sender, EventArgs e) DealMenu.ShowDealMenu = false; } - else if ((!player.IsInRange(dealer.Position, 3f) && CurrentDrugDealer == dealer) || Game.Player.WantedLevel != 0) + else if ((!_player.IsInRange(dealer.Position, 3f) && CurrentDrugDealer == dealer) || Game.Player.WantedLevel != 0) { CurrentDrugDealer = null!; DealMenu.ShowDealMenu = false; diff --git a/Missions/Warehouse.cs b/Missions/Warehouse.cs index 0a23edcd..a2fbbbb8 100644 --- a/Missions/Warehouse.cs +++ b/Missions/Warehouse.cs @@ -1,7 +1,6 @@ using GTA; using GTA.UI; using Los.Santos.Dope.Wars.Classes; -using Los.Santos.Dope.Wars.Contracts; using Los.Santos.Dope.Wars.Extension; using Los.Santos.Dope.Wars.Persistence; using System; @@ -13,10 +12,14 @@ namespace Los.Santos.Dope.Wars.Missions /// public static class Warehouse { - private static Script Script = null!; - private static GameState GameState = null!; - private static PlayerStats PlayerStats = null!; - private static DrugWarehouse DrugWarehouse = null!; + private static GameState? _gameState; + private static PlayerStats? _playerStats; + private static DrugWarehouse? _drugWarehouse; + + /// + /// The property indicates if the method was called + /// + public static bool Initialized { get; private set; } /// /// The property @@ -35,40 +38,35 @@ static Warehouse() { } /// public static void OnTick(object sender, EventArgs e) { - if (sender is Script script) - Script = script; + if (!Initialized) + return; - while (GameState is null && PlayerStats is null && DrugWarehouse is null) - Script.Wait(50); + if (_playerStats != Utils.GetPlayerStatsFromModel(_gameState!)) + _playerStats = Utils.GetPlayerStatsFromModel(_gameState!); try { Ped? player = Game.Player.Character; - if (PlayerStats!.CurrentLevel >= 5 && !PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Unlocked)) - PlayerStats.SpecialReward.Warehouse |= Enums.WarehouseStates.Unlocked; - //all necessary flags are there - if (PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Unlocked) || PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought) || PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Upgraded)) + if (_playerStats!.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Unlocked) || _playerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought) || _playerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Upgraded)) { BlipColor blipColor = Utils.GetCharacterBlipColor(Utils.GetCharacterFromModel()); - if (!DrugWarehouse!.BlipCreated) + if (!_drugWarehouse!.BlipCreated) { - DrugWarehouse = new DrugWarehouse(Constants.WarehouseLocationFranklin, Constants.WarehouseEntranceFranklin, Constants.WarehouseMissionStartFranklin); - DrugWarehouse.CreateBlip(); + _drugWarehouse = new DrugWarehouse(Constants.WarehouseLocationFranklin, Constants.WarehouseEntranceFranklin, Constants.WarehouseMissionStartFranklin); + _drugWarehouse.CreateBlip(BlipSprite.WarehouseForSale); - if (!PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought)) - DrugWarehouse.ChangeBlip("Property: Drug Warehouse", BlipSprite.WarehouseForSale, blipColor); - else - DrugWarehouse.ChangeBlip("Drug Warehouse", BlipSprite.Warehouse, blipColor); + if (_playerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought)) + _drugWarehouse.ChangeBlip(BlipSprite.Warehouse, blipColor); } } //Warehouse exists - if (DrugWarehouse!.BlipCreated && World.GetDistance(player.Position, Constants.WarehouseEntranceFranklin) <= 3f) + if (_drugWarehouse!.BlipCreated && World.GetDistance(player.Position, Constants.WarehouseEntranceFranklin) <= 3f) { //Warehouse is not yours - if (!PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought)) + if (!_playerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought)) { Screen.ShowHelpTextThisFrame($"~b~Press ~INPUT_CONTEXT~ ~w~to buy the warehouse for ~r~${Constants.DrugWarehousePrice}"); if (Game.IsControlJustPressed(Control.Context)) @@ -79,7 +77,7 @@ public static void OnTick(object sender, EventArgs e) } //Warehouse is yours - if (PlayerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought)) + if (_playerStats.SpecialReward.Warehouse.HasFlag(Enums.WarehouseStates.Bought)) { Screen.ShowHelpTextThisFrame($"~b~Press ~INPUT_CONTEXT~ ~w~to transfer drugs or drug money to your warehouse."); if (Game.IsControlJustPressed(Control.Context)) @@ -101,13 +99,14 @@ public static void OnTick(object sender, EventArgs e) /// public static void Init(GameState gameState) { - GameState = gameState; - PlayerStats = Utils.GetPlayerStatsFromModel(gameState); - DrugWarehouse = new() - { - DrugStash = PlayerStats.Warehouse.DrugStash - }; - } + _gameState = gameState; + _playerStats = Utils.GetPlayerStatsFromModel(gameState); + _drugWarehouse = new() + { + DrugStash = _playerStats.Warehouse.DrugStash + }; + Initialized = true; + } /// /// @@ -116,8 +115,8 @@ public static void Init(GameState gameState) /// public static void OnAborted(object sender, EventArgs e) { - if (DrugWarehouse.BlipCreated) - DrugWarehouse.DeleteBlip(); + if (_drugWarehouse!.BlipCreated) + _drugWarehouse.DeleteBlip(); } /// @@ -125,7 +124,7 @@ public static void OnAborted(object sender, EventArgs e) /// private static void BuyDrugWareHouse() { - if ((Game.Player.Money + PlayerStats.DrugStash.Money) < Constants.DrugWarehousePrice) + if ((Game.Player.Money + _playerStats!.DrugStash.Money) < Constants.DrugWarehousePrice) { Screen.ShowSubtitle($"You don't have enough money to buy the warehouse."); return; @@ -135,29 +134,29 @@ private static void BuyDrugWareHouse() BlipColor blipColor = Utils.GetCharacterBlipColor(Utils.GetCharacterFromModel()); int moneyToPay = Constants.DrugWarehousePrice; - if (PlayerStats.DrugStash.Money > 0) + if (_playerStats.DrugStash.Money > 0) { int moneyToRemoveFromStash = 0; - if (PlayerStats.DrugStash.Money >= Constants.DrugWarehousePrice) + if (_playerStats.DrugStash.Money >= Constants.DrugWarehousePrice) { moneyToRemoveFromStash += Constants.DrugWarehousePrice; - PlayerStats.DrugStash.Money -= moneyToRemoveFromStash; + _playerStats.DrugStash.Money -= moneyToRemoveFromStash; } else { - moneyToPay -= PlayerStats.DrugStash.Money; + moneyToPay -= _playerStats.DrugStash.Money; moneyToRemoveFromStash = Constants.DrugWarehousePrice - moneyToPay; - PlayerStats.DrugStash.Money -= moneyToRemoveFromStash; + _playerStats.DrugStash.Money -= moneyToRemoveFromStash; } Notification.Show($"~r~${moneyToRemoveFromStash} removed from stash and used as payment."); } player.Money -= moneyToPay; - PlayerStats.SpecialReward.Warehouse |= Enums.WarehouseStates.Bought; - Screen.ShowSubtitle("You bought a warehouse, use it to keep your drugs and drug money safe."); - Screen.ShowSubtitle("But beware! Other ~r~shady ~w~individuals might be interested in it."); + _playerStats.SpecialReward.Warehouse |= Enums.WarehouseStates.Bought; + Notification.Show("You bought a ~g~warehouse~w~, use it to keep your drugs and drug money safe."); + Notification.Show("But beware! Other ~r~shady ~w~individuals might be interested in it."); Audio.PlaySoundFrontend("PURCHASE", "HUD_LIQUOR_STORE_SOUNDSET"); - DrugWarehouse.ChangeBlip("Drug Warehouse", BlipSprite.Warehouse, blipColor); - Utils.SaveGameState(GameState); + _drugWarehouse!.ChangeBlip(BlipSprite.Warehouse, blipColor); + Utils.SaveGameState(_gameState!); } } } diff --git a/Persistence/PlayerStats.cs b/Persistence/PlayerStats.cs index 1e205052..522f89b6 100644 --- a/Persistence/PlayerStats.cs +++ b/Persistence/PlayerStats.cs @@ -1,5 +1,7 @@ using Los.Santos.Dope.Wars.Classes; using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; using System.Xml.Serialization; namespace Los.Santos.Dope.Wars.Persistence @@ -8,8 +10,13 @@ namespace Los.Santos.Dope.Wars.Persistence /// The class is the root element for each character /// [XmlRoot(ElementName = nameof(PlayerStats), IsNullable = false)] - public class PlayerStats + public class PlayerStats : INotifyPropertyChanged { + private int currentLevel; + + /// + public event PropertyChangedEventHandler? PropertyChanged; + #region ctor /// /// Empty constructor with default values @@ -38,10 +45,10 @@ public PlayerStats() [XmlIgnore] public const int MaxLevel = 50; - /// - /// The property, money spend for buying drugs - /// - [XmlAttribute(AttributeName = nameof(SpentMoney))] + /// + /// The property, money spend for buying drugs + /// + [XmlAttribute(AttributeName = nameof(SpentMoney))] public int SpentMoney { get; set; } /// @@ -54,7 +61,18 @@ public PlayerStats() /// The property, increases depending on experience gain /// [XmlAttribute(AttributeName = nameof(CurrentLevel))] - public int CurrentLevel { get; set; } + public int CurrentLevel + { + get { return currentLevel; } + set + { + if (value > currentLevel) + { + currentLevel = value; + OnPropertyChanged(nameof(CurrentLevel)); + } + } + } /// /// The property @@ -133,5 +151,12 @@ private int GetCurrentBagSize() bagSize += drug.Quantity; return bagSize; } + + /// + /// The method for the event trigger + /// + /// + private protected void OnPropertyChanged([CallerMemberName] string? name = null) => + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } }