I have ReactiveCollection of PlayerBuildings. Is it possible to subscribe to this collection only when ProductionPerHour or ProducedResourceId value will change ?
I mean something like this ?
public void Sub()
{
var collection = new ReactiveCollection<PlayerBuilding>();
collection
.where(x => x.ProducedResourceId == 1)
.sum(y => y)
.subscribe(_ => something);
}
public class PlayerBuilding
{
public ReactiveProperty<SimpleRessourceEnum?> ProducedResourceId;
public ReactiveProperty<int?> ProductionPerHour;
public ReactiveProperty<int?> ProductionLimit;
}
Update
The purpose of this is to map production sum to textValue. So I need a subscription signal only if ProductionPerHour will change where ProducedResourceId = myResource or ProducedResourceId of any building will be set to myResource.Pseudo code example
public class ResourceItemScript : MonoBehaviour {
private Text _valueText;
private void Awake()
{
_valueText = transform.FindDeepChild("Text").GetComponent<Text>();
}
private void Start()
{
_productionService.GetProductionSumObservable(myResource)
.SubscribeToText(_valueText);
}
}