protected void TestEnergyEvent(EnergyEventData data) { if (constraint.component.Test(data.energy)) { energyEvent.Invoke(data); } }
// Given the data in an event, find all local pairs with the same energy socket and return the pairs private List <SocketStockpilePair> ConnectionsInEvent(EnergyEventData eventData) { List <SocketStockpilePair> pairs = prioritizedPairs.ConvertAll(x => x.pair); pairs.RemoveAll(x => x.socket != eventData.socket); return(pairs); }
// When the signal suppressor transmits the signal, this method is called // Find all local pairs whose energy sockets match the one that sent the signal, // then change stock on each stockpile in each pair private void ChangeAllStock(EnergyEventData eventData) { List <SocketStockpilePair> pairs = ConnectionsInEvent(eventData); foreach (SocketStockpilePair pair in pairs) { pair.stockpile.ChangeStock(eventData.energy); } }
// Add the stock change to the list of stock changes private void ScheduleStockChange(EnergyEventData data) { if (data.energy < 0) { scheduledStockDecreases.Add(data.energy); } else { scheduledStockIncreases.Add(data.energy); } }
private void ChangeStockByAmountAbsorbed(EnergyEventData data) { _stock.ChangeStock(data.energy); }
// Find the priority wrapper whose energy socket matches the one in the event data and return its priority private int GetLocalPriority(EnergyEventData eventData) { PrioritizedSocketStockpilePair matchedPair = prioritizedPairs.Find(x => x.socket == eventData.socket); return(matchedPair.priority); }