static bool IsWantContinueEat(PeEntity entity, out List <AttrPer> AttrPers) { AttrPers = new List <AttrPer>(); if (entity == null) { return(false); } AttrPer attrper = WantByType(entity, AttribType.Hp, AttribType.HpMax, true); if (attrper != null) { AttrPers.Add(attrper); } attrper = WantByType(entity, AttribType.Comfort, AttribType.ComfortMax, true); if (attrper != null) { AttrPers.Add(attrper); } attrper = WantByType(entity, AttribType.Hunger, AttribType.HungerMax, true); if (attrper != null) { AttrPers.Add(attrper); } return(AttrPers.Count > 0); }
public static AttrPer WantByType(PeEntity entity, AttribType _type, AttribType _typeMax, float _eatMin, float _eatMax, bool _bContinue = false) { AttrPer attrper = null; float curPercent = 1.0f; int TypeID = (int)_type; //float eatLimt = _bContinue ? _eatMax : _eatMin; float p = entity.GetAttribute(_type); float pMax = entity.GetAttribute(_typeMax); curPercent = p / pMax; if (curPercent < _eatMax) { attrper = new AttrPer(TypeID, curPercent); } return(attrper); }
public static bool CanEatByAttr(PeEntity entity, AttribType type, AttribType typeMax, bool bContinue) { if (entity.UseItem == null) { return(false); } AttrPer Db = WantByType(entity, type, typeMax, bContinue); if (Db == null) { return(false); } int[] eatids = GetEatIDs(Db.mTypeId, Db.mCurPercent); ItemAsset.ItemObject item = GetCanEatItemFromPackage(entity, eatids); if (item != null) { return(true); } return(false); }
public static AttrPer WantByType(PeEntity entity, AttribType _type, AttribType _typeMax, bool _bContinue = false) { AttrPer attrper = null; float curPercent = 1.0f; int TypeID = (int)_type; Items items = NpcEatDb.GetIitems(TypeID); if (items == null) { return(null); } //float eatLimt = _bContinue ? items.mEatMax : items.mEatMin; float Hp = entity.GetAttribute(_type); float HpMax = entity.GetAttribute(_typeMax); curPercent = Hp / HpMax; if (curPercent < items.mEatMax) { attrper = new AttrPer(TypeID, curPercent); } return(attrper); }