public override void Begin(Precondition.Context context) { if ((UnityEngine.Object)context.consumerState.consumer == (UnityEngine.Object)null) { Debug.LogError("EATCHORE null context.consumer"); } else { RationMonitor.Instance sMI = context.consumerState.consumer.GetSMI <RationMonitor.Instance>(); if (sMI == null) { Debug.LogError("EATCHORE null RationMonitor.Instance"); } else { Edible edible = sMI.GetEdible(); if ((UnityEngine.Object)edible.gameObject == (UnityEngine.Object)null) { Debug.LogError("EATCHORE null edible.gameObject"); } else if (base.smi == null) { Debug.LogError("EATCHORE null smi"); } else if (base.smi.sm == null) { Debug.LogError("EATCHORE null smi.sm"); } else if (base.smi.sm.ediblesource == null) { Debug.LogError("EATCHORE null smi.sm.ediblesource"); } else { base.smi.sm.ediblesource.Set(edible.gameObject, base.smi); KCrashReporter.Assert(edible.FoodInfo.CaloriesPerUnit > 0f, edible.GetProperName() + " has invalid calories per unit. Will result in NaNs"); AmountInstance amountInstance = Db.Get().Amounts.Calories.Lookup(gameObject); float num = (amountInstance.GetMax() - amountInstance.value) / edible.FoodInfo.CaloriesPerUnit; KCrashReporter.Assert(num > 0f, "EatChore is requesting an invalid amount of food"); base.smi.sm.requestedfoodunits.Set(num, base.smi); base.smi.sm.eater.Set(context.consumerState.gameObject, base.smi); base.Begin(context); } } } }
public override void Populate(MinionIdentity _identity) { base.Populate(_identity); rationMonitor = _identity.GetSMI <RationMonitor.Instance>(); Refresh(); }