- Modified item buying logic: selected items are purchased immediately without having to click the "buy" button, and they stay in the list of purchased items until the round is started. (-> It's possible to see which items have been purchased and cancel purchases).
- Clients can be given a permission to manage the campaign (atm selecting which location to head towards and buying items). - Syncing cargomanager state with clients. - Misc fixes.
This commit is contained in:
@@ -1,20 +1,56 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class CargoManager
|
||||
{
|
||||
private List<ItemPrefab> purchasedItems;
|
||||
private readonly List<ItemPrefab> purchasedItems;
|
||||
|
||||
private readonly CampaignMode campaign;
|
||||
|
||||
public Action OnItemsChanged;
|
||||
|
||||
public List<ItemPrefab> PurchasedItems
|
||||
{
|
||||
get { return purchasedItems; }
|
||||
}
|
||||
|
||||
public CargoManager()
|
||||
public CargoManager(CampaignMode campaign)
|
||||
{
|
||||
purchasedItems = new List<ItemPrefab>();
|
||||
this.campaign = campaign;
|
||||
}
|
||||
|
||||
public void AddItem(ItemPrefab item)
|
||||
public void SetPurchasedItems(List<ItemPrefab> items)
|
||||
{
|
||||
purchasedItems.Clear();
|
||||
purchasedItems.AddRange(items);
|
||||
|
||||
OnItemsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void PurchaseItem(ItemPrefab item)
|
||||
{
|
||||
campaign.Money -= item.Price;
|
||||
purchasedItems.Add(item);
|
||||
|
||||
OnItemsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SellItem(ItemPrefab item)
|
||||
{
|
||||
campaign.Money += item.Price;
|
||||
purchasedItems.Remove(item);
|
||||
|
||||
OnItemsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public int GetTotalItemCost()
|
||||
{
|
||||
return purchasedItems.Sum(i => i.Price);
|
||||
}
|
||||
|
||||
public void CreateItems()
|
||||
|
||||
Reference in New Issue
Block a user