public override void OnBegin(GameObject interactor, Interaction interaction) { feeder = interactor.GetComponent <Feeder>(); if (feeder == null) { failed = true; return; } consumable = feeder.GetConsumable(); if (consumable == null || !consumableTypes.Contains(consumable.consumableType)) { failed = true; return; } // If we're holding an object, and there is already a job in progress, fail if (progression != null && !resetProgress) { failed = true; return; } foreach (Interactable i in subscribers) { if (i is Progressive) { ((Progressive)i).OnBegin(interactor, interaction); } } foreach (Interactable i in subscribers) { if (i is Consumer) { ((Consumer)i).OnConsume(interactor, consumable, interaction); } } feeder.Feed(); }
public override void Interact(GameObject interactor, Interaction interaction) { if (acceptedInteractions.Contains(interaction)) { Feeder feeder = interactor.GetComponent <Feeder>(); if (feeder != null) { Consumable consumable = feeder.GetConsumable(); if (consumable != null && acceptedConsumableTypes.Contains(consumable.consumableType)) { foreach (Interactable i in subscribers) { i.OnInteract(interactor, interaction); } Consume(feeder, consumable, interaction); } } } }