static bool Prefix(PlantingBoxUnit ___cisternUnit) { if (!enabled || !settings.InstantFertilize) { return(true); } ItemObject curUseItem = Module <Player> .Self.bag.itemBar.GetCurUseItem(); if (curUseItem != null) { ItemNutrientCmpt nutri = curUseItem.GetComponent <ItemNutrientCmpt>(); if (nutri != null) { UIStateMgr.Instance.ChangeStateByType(UIStateMgr.StateType.Empty, false, null); UIUtils.ShowNumberSelectMinMax(curUseItem.ItemDataId, 1, Mathf.Min(curUseItem.Number, (int)(((float)___cisternUnit.MaxNutrient - ___cisternUnit.CurrentNutrient) / (float)nutri.Point)), 1, string.Empty, delegate(int o) { Module <Player> .Self.bag.itemBar.RemoveCurItem(o); ___cisternUnit.TryAddNutrient((float)(nutri.Point * o), true); UIStateMgr.Instance.PopState(false); }, delegate() { UIStateMgr.Instance.PopState(false); }, false, 0, string.Empty); } } return(false); }
static bool Prefix(PlantingBoxUnit ___boxUnit, UnityEngine.Transform ___addNutriParticleParent) { if (!enabled || !settings.InstantFertilize) { return(true); } ItemObject curUseItem = Module <Player> .Self.bag.itemBar.GetCurUseItem(); if (curUseItem != null) { ItemNutrientCmpt nutri = curUseItem.GetComponent <ItemNutrientCmpt>(); if (nutri != null && ___boxUnit.CanAddNutrient(nutri.Point)) { Module <Player> .Self.bag.itemBar.RemoveCurItem(1); ___boxUnit.TryAddNutrient((float)nutri.Point, true); GameObject addNutriParticle = GameUtils.AddChildToTransform(___addNutriParticleParent, "FX_ApplyFertilizer", false, AssetType.Effect); ParticleSystem componentInChildren = addNutriParticle.GetComponentInChildren <ParticleSystem>(); componentInChildren.Play(); Singleton <TaskRunner> .Instance.RunDelayTask(componentInChildren.main.duration, false, delegate { UnityEngine.Object.Destroy(addNutriParticle); }); } } return(false); }