@ -28,7 +28,7 @@ public abstract class ShopView : MonoBehaviour
[SerializeField]protectedLayoutGrouplayoutGroup;// The layout group that represents this view visually
[SerializeField]privateModelComponentownModel;// Reference to the model this view technically belongs to
[SerializeField]privateInventoryComponenttradePartner;// Reference to the model this view technically belongs to
[SerializeField]protectedInventoryComponenttradePartner;// Reference to the model this view technically belongs to
protectedShopModelmodel;// Model in MVC pattern
protectedShopModelother;// Other model in MVC pattern (our own inventory)
@ -50,11 +50,15 @@ public abstract class ShopView : MonoBehaviour
//model.Subscribe(this);
}
privatevoidStart()
{
RegisterMoneyObserver();// Make sure if this thing's got a money component somewhere we register it as an observer for the inventory we're looking at
}
privatevoidOnEnable()
{
// sanity check
if(model==null)model=ownModel.Model;
RegisterMoneyObserver();// Make sure if this thing's got a money component somewhere we register it as an observer for the inventory we're looking at
model.SetTradePartner(tradePartner.Inventory);
PopulateItemIconView();//Display items
}
@ -66,12 +70,8 @@ public abstract class ShopView : MonoBehaviour
UnregisterMoneyObserver();
}
// If view is generic, and shopview was just an implementation, this would be more flexible in theory. But for now it's enough to just manually assign "ourselves" as trade partner if we know the model works on just one inventory