本文整理汇总了C#中Pawn.AnimalAwareOfEx方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.AnimalAwareOfEx方法的具体用法?C# Pawn.AnimalAwareOfEx怎么用?C# Pawn.AnimalAwareOfEx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.AnimalAwareOfEx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BestWaterSpawnedFor
public static Thing BestWaterSpawnedFor(Pawn getter, float wantedLitres, Predicate<Thing> validator = null,
IntVec3? near = null, bool allowPleasureDrug = true)
{
if (!near.HasValue)
{
near = getter.Position;
}
Predicate<Thing> baseValidator;
if (validator == null)
{
baseValidator = (Thing t) =>
{
return (!t.IsForbidden(getter) && t.IsSociallyProper(getter) &&
getter.AnimalAwareOfEx(t) &&
(!ShouldReserveWaterSource(t, wantedLitres) || getter.CanReserve(t, 1)));
};
}
else
{
baseValidator = (Thing t) =>
{
return (!t.IsForbidden(getter) && t.IsSociallyProper(getter) &&
getter.AnimalAwareOfEx(t) &&
(!ShouldReserveWaterSource(t, wantedLitres) || getter.CanReserve(t, 1)) &&
validator(t));
};
}
// Can drink from anything that is a non-empty water container.
Predicate<Thing> toolValidator = (Thing t) =>
{
if (!baseValidator(t)) { return false; }
var wc = t.TryGetComp<CompWaterContainer>();
return (wc != null && wc.StoredLitres > 0);
};
// Can drink from anything that is a non-empty water container, but only if
// it doesn't require tool use.
Predicate<Thing> noToolValidator = (Thing t) =>
{
if (!baseValidator(t)) { return false; }
var wc = t.TryGetComp<CompWaterContainer>();
return (wc != null && wc.StoredLitres > 0 && !wc.props.needsToolUser);
};
// Prefer a water source that has at least as much as we want.
// Otherwise prefer the one with the most.
Func<Thing, int> priorityGetter = (Thing t) =>
{
var wc = t.TryGetComp<CompWaterContainer>();
if (wc == null) { return -1; }
if (wc.StoredLitres >= wantedLitres) { return int.MaxValue; }
return (int) Math.Round(wc.StoredLitres, 0, MidpointRounding.AwayFromZero);
};
// TODO: may be able to narrow down the ThingRequestGroup.
var allThings = ThingRequest.ForGroup(ThingRequestGroup.Everything);
var traverse = TraverseParms.For(getter, Danger.Deadly, TraverseMode.ByPawn);
Predicate<Thing> searchValidator = toolValidator;
if (!getter.RaceProps.ToolUser)
{
searchValidator = noToolValidator;
}
Thing result = GenClosest.RegionwiseBFSWorker(
near.Value, allThings, PathEndMode.ClosestTouch, traverse, searchValidator,
priorityGetter, 9, 30, 9999f);
return result;
}