public override void OnEvent(ItemMerging evnt) { if (evnt.Entity == GetComponentInParent <BoltEntity>()) // This is the kart that launched the event { if (evnt.Shield && OnItemMergingShield != null) { OnItemMergingShield.Invoke(); } else if (!evnt.Shield && OnItemMergingSpeedBoost != null) { OnItemMergingSpeedBoost.Invoke(); } } }
// PRIVATE /* KEEP IT JUST IN CASE * private void ConsumeItem() * { * if (_inventory.CurrentItem != null) * { * _inventory.SetCount(_inventory.CurrentItemCount - 1); * GrantBoosts(MergeMode.Shield); * } * else if (_lottery.LotteryStarted) * { * _lottery.StopAllCoroutines(); * _lottery.ResetLottery(); * GrantBoosts(MergeMode.SpeedBoost); * } * } */ private void GrantBoosts(MergeMode mode) { ItemMerging itemMergingEvent = ItemMerging.Create(); itemMergingEvent.Entity = entity; switch (mode) { case MergeMode.Shield: itemMergingEvent.Shield = true; break; case MergeMode.SpeedBoost: itemMergingEvent.Shield = false; _boost.CustomBoostFromBoostSettings(_boostSettings); break; } itemMergingEvent.Send(); }