public override bool ShouldExecute() { if (entity.World.Rand.NextDouble() < 0.005) { return(false); } if (cooldownUntilMs > entity.World.ElapsedMilliseconds) { return(false); } if (cooldownUntilTotalHours > entity.World.Calendar.TotalHours) { return(false); } if (whenInEmotionState != null && !entity.HasEmotionState(whenInEmotionState)) { return(false); } if (whenNotInEmotionState != null && entity.HasEmotionState(whenNotInEmotionState)) { return(false); } EntityBehaviorMultiply bh = entity.GetBehavior <EntityBehaviorMultiply>(); if (bh != null && !bh.ShouldEat) { return(false); } IPointOfInterest nearestPoi = porregistry.GetNearestPoi(entity.ServerPos.XYZ, 32, (poi) => { if (poi.Type != "food") { return(false); } if ((target = poi as IAnimalFoodSource)?.IsSuitableFor(entity) == true) { FailedAttempt attempt; failedSeekTargets.TryGetValue(target, out attempt); doOnce = true; if (attempt == null || (attempt.Count < 4 || attempt.LastTryMs < world.ElapsedMilliseconds - 60000)) { return(true); } } return(false); }); return(nearestPoi != null); }
public override bool ShouldExecute() { if (entity.World.Rand.NextDouble() < 0.005) { return(false); } if (cooldownUntilMs > entity.World.ElapsedMilliseconds) { return(false); } if (cooldownUntilTotalHours > entity.World.Calendar.TotalHours) { return(false); } if (whenInEmotionState != null && !entity.HasEmotionState(whenInEmotionState)) { return(false); } if (whenNotInEmotionState != null && entity.HasEmotionState(whenNotInEmotionState)) { return(false); } EntityBehaviorMultiply bh = entity.GetBehavior <EntityBehaviorMultiply>(); if (bh != null && !bh.ShouldEat) { return(false); } if (shouldSeek) { entity.World.RegisterCallback(SeekFoodSources, 5000); } return(nearestPoi != null); }