本文整理汇总了C#中Pawn.CanReserve方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.CanReserve方法的具体用法?C# Pawn.CanReserve怎么用?C# Pawn.CanReserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.CanReserve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindClosestCorpseFor
public static Corpse FindClosestCorpseFor(Predicate<Thing> pred, Pawn getter)
{
Predicate<Thing> predicate1 = (Thing c) => !c.IsForbidden(Faction.OfColony) && getter.AwareOf(c) && getter.CanReserve(c);
Predicate<Thing> predicate = (Thing t) => pred(t) && predicate1(t);
ThingRequest thingReq = ThingRequest.ForGroup(ThingRequestGroup.Corpse);
return (Corpse)GenClosest.ClosestThingReachable(getter.Position, thingReq, PathEndMode.ClosestTouch, TraverseParms.For(getter), 9999f, predicate, null);
}
示例2: JobOnThing
public override Job JobOnThing(Pawn pawn, Thing thing)
{
ISlotGroupParent slotGroupParent = thing as ISlotGroupParent;
if (slotGroupParent == null)
{
return null;
}
if (!pawn.CanReserve(thing.Position, 1))
{
return null;
}
int num = 0;
List<Thing> list = Find.ThingGrid.ThingsListAt(thing.Position);
for (int i = 0; i < list.Count; i++)
{
Thing thing2 = list[i];
if (Building_AquacultureBasin.IsAcceptableFeedstock(thing2.def))
{
num += thing2.stackCount;
}
}
if (num > 25)
{
JobFailReason.Is("AlreadyFilledLower".Translate());
return null;
}
return WorkGiver_FillAquacultureHopper.HopperFillFoodJob(pawn, slotGroupParent);
}
示例3: HasJobOnThing
public override bool HasJobOnThing(Pawn pawn, Thing t)
{
Fire fire = t as Fire;
if (fire == null)
{
return false;
}
Area outpostArea = OG_Util.FindOutpostArea();
Pawn pawn2 = fire.parent as Pawn;
if (pawn2 != null)
{
if (pawn2 == pawn)
{
return false;
}
if ((pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction)
&& ((outpostArea == null) || (outpostArea.ActiveCells.Contains(t.Position) == false))
&& IntVec3Utility.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > 15)
{
return false;
}
}
else if ((outpostArea == null)
|| (outpostArea.ActiveCells.Contains(t.Position) == false))
{
return false;
}
return ((pawn.Position - fire.Position).LengthHorizontalSquared <= 225f || pawn.CanReserve(fire, 1)) && !WorkGiver_FightFiresOutpost.FireIsBeingHandled(fire, pawn);
}
示例4: GetBestSeedThingForSowing
private Thing GetBestSeedThingForSowing(Pawn pawn, IntVec3 cell, ThingDef_PlantWithSeeds customPlantDef)
{
Thing result = null;
Predicate<Thing> validator = (Thing tempThing) => !tempThing.IsForbidden(pawn.Faction) && pawn.AnimalAwareOf(tempThing) && pawn.CanReserve(tempThing, 1);
if (customPlantDef.SeedDef != null)
{
result = GenClosest.ClosestThingReachable(cell, ThingRequest.ForDef(customPlantDef.SeedDef), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, null, -1, false);
}
return result;
}
示例5: FindAvailablePlants
public void FindAvailablePlants(Pawn pawn)
{
// find all plants designated to be cut of harvest
availablePlants = Find.DesignationManager.allDesignations.FindAll(designation => designation.def == DesignationDefOf.CutPlant || designation.def == DesignationDefOf.HarvestPlant).Select(designation => designation.target.Thing);
// needed to avoid null references if availablePlants == 0
if (availablePlants.Count() > 0)
{
// could be reserved and not on fire among them
availablePlants = availablePlants.Where(plant => pawn.CanReserve(plant) && !plant.IsBurning());
}
}
示例6: FindAvailableRepairables
public void FindAvailableRepairables(Pawn pawn)
{
// find all available repairables
availableRepairables = ListerBuildingsRepairable.RepairableBuildings(pawn.Faction);
// needed to avoid null references if availableRepairables == 0
if (availableRepairables.Count() > 0)
{
// repairable is in home area, can e reserved, not being decontructed, not burning
availableRepairables = availableRepairables.Where(Repairable => pawn.Faction == Faction.OfColony && Find.HomeAreaGrid[Repairable.Position] && pawn.CanReserve(Repairable) && Repairable.def.useHitPoints && Repairable.HitPoints < Repairable.MaxHitPoints && Find.DesignationManager.DesignationOn(Repairable, DesignationDefOf.Deconstruct) == null && !Repairable.IsBurning());
}
}
示例7: GetBestSeedThingForSowing
private Thing GetBestSeedThingForSowing( Pawn pawn, IntVec3 cell, ThingDef_PlantWithSeeds customPlantDef )
{
Thing seedThing = null;
Predicate<Thing> predicate = (Thing tempThing ) => !tempThing.IsForbidden( pawn.Faction ) && pawn.AwareOf( tempThing ) && pawn.CanReserve( tempThing);
if ( customPlantDef.SeedDef != null )
{
seedThing = GenClosest.ClosestThingReachable(cell, ThingRequest.ForDef(customPlantDef.SeedDef), PathEndMode.ClosestTouch,
TraverseParms.For( pawn ), 9999f, predicate );
}
return seedThing;
}
示例8: FindBestGrave
private Building_Grave FindBestGrave(Pawn p, Corpse corpse)
{
Predicate<Thing> predicate = (Thing m) => !m.IsForbidden(p) && p.CanReserve(m, 1) && ((Building_Grave)m).Accepts(corpse);
if (corpse.innerPawn.ownership != null && corpse.innerPawn.ownership.AssignedGrave != null)
{
Building_Grave assignedGrave = corpse.innerPawn.ownership.AssignedGrave;
if (predicate(assignedGrave) && corpse.Position.CanReach(assignedGrave, PathEndMode.ClosestTouch, TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false)))
{
return assignedGrave;
}
}
Func<Thing, float> priorityGetter = (Thing t) => (float)((IStoreSettingsParent)t).GetStoreSettings().Priority;
Predicate<Thing> validator = predicate;
return (Building_Grave)GenClosest.ClosestThing_Global_Reachable(corpse.Position, Find.ListerThings.ThingsInGroup(ThingRequestGroup.Grave), PathEndMode.ClosestTouch, TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, priorityGetter);
}
示例9: HasJobOnThing
public override bool HasJobOnThing(Pawn carer, Thing t)
{
Pawn patient = t as Pawn;
if (patient == null || patient == carer)
{
return false;
}
if (patient.GetPosture() == PawnPosture.Standing)
{
return false;
}
if (patient.RaceProps.Humanlike)
{
if (patient.Faction != Faction.OfColony && patient.HostFaction != Faction.OfColony)
{
return false;
}
}
else
{
Building_Bed building_Bed = patient.CurrentBed();
if (building_Bed == null || building_Bed.Faction != patient.Faction)
{
return false;
}
}
var waterNeed = patient.needs.TryGetNeed<Need_Water>();
if (waterNeed == null || !waterNeed.NeedWaterSoon)
{
return false;
}
if (patient.HostFaction != null)
{
if (patient.HostFaction != patient.Faction)
{
return false;
}
if (patient.guest != null && !patient.guest.ShouldBeBroughtFood)
{
return false;
}
}
return carer.CanReserve(patient, 1);
}
示例10: MakeWaterPrisonerJob
private Job MakeWaterPrisonerJob(Pawn warden, Thing t)
{
Pawn prisoner = t as Pawn;
if (prisoner == null || !prisoner.IsPrisonerOfColony || !prisoner.guest.PrisonerIsSecure ||
prisoner.holder != null || (prisoner.Broken && prisoner.BrokenStateDef.isAggro) ||
!warden.CanReserveAndReach(prisoner, PathEndMode.OnCell, warden.NormalMaxDanger(), 1))
{
return null;
}
var waterNeed = prisoner.needs.TryGetNeed<Need_Water>();
if (waterNeed != null && prisoner.guest.ShouldBeBroughtFood && waterNeed.NeedWaterSoon)
{
if (prisoner.Downed || (prisoner.InBed() && prisoner.CurrentBed().Medical))
{
if (warden.CanReserve(prisoner, 1))
{
var waterPatientWorkGiver = WaterPatientWorkGiverDef.Worker as WorkGiver_WaterPatient;
if (waterPatientWorkGiver != null)
{
// Use the existing WorkGiver for doctors giving water to patients.
return waterPatientWorkGiver.JobOnThing(warden, prisoner);
}
}
}
else if (!WaterAvailableInRoomTo(prisoner))
{
Thing haulTo = BestWaterContainerInPrison(prisoner);
if (haulTo != null)
{
var haulWorkGiver = HaulWaterWorkGiverDef.Worker as WorkGiver_HaulWater;
if (haulWorkGiver != null)
{
// Use the existing WorkGiver for water hauling.
// Note that the normal check for social properness happens in
// HasJobOnThing(), so this warden bypasses the normal inability to
// haul to containers inside a prison.
return haulWorkGiver.JobOnThing(warden, haulTo);
}
}
}
}
return null;
}
示例11: HasJobOnThing
// This workgiver is specific to MiningCo. employees. It allows them to rescue fallen comrades even when MiningCo. is hostile to colony (thus the redefinition of EnemyIsNear function).
public override bool HasJobOnThing(Pawn pawn, Thing t)
{
if ((pawn.Faction != null)
&& (pawn.Faction != OG_Util.FactionOfMiningCo))
{
return false;
}
Pawn downedPawn = t as Pawn;
if (downedPawn == null || !downedPawn.Downed || downedPawn.Faction != pawn.Faction || downedPawn.InBed() || !pawn.CanReserve(downedPawn, 1) || EnemyIsNear(downedPawn, 40f))
{
return false;
}
Thing cryptosleepBay = FindFreeSupplyShipCryptosleepBay(pawn);
Thing cryptosleepCasket = FindFreeCryptosleepCasket(pawn);
return (((cryptosleepBay != null) && downedPawn.CanReserve(cryptosleepBay, 1))
|| ((cryptosleepCasket != null) && downedPawn.CanReserve(cryptosleepCasket, 1)));
}
示例12: StartingJobForOn
public override Job StartingJobForOn(Pawn pawn, Thing t)
{
if (t.Faction != pawn.Faction)
{
return null;
}
if (pawn.food.Food.Starving)
{
return null;
}
if (!pawn.CanReserve(t, ReservationType.Use))
{
return null;
}
if (!t.def.defName.Equals("ShootingRange"))
{
return null;
}
return new Job(JobDefOf.ManThing, new TargetPack(t));
}
示例13: DeconstructExistingEdificeJob
public Job DeconstructExistingEdificeJob(Pawn pawn, RimWorld.Blueprint blue)
{
if (!blue.def.entityDefToBuild.IsEdifice())
{
return null;
}
Thing thing = null;
var cellRect = blue.OccupiedRect();
for (var i = cellRect.minZ; i <= cellRect.maxZ; i++)
{
var j = cellRect.minX;
while (j <= cellRect.maxX)
{
var c = new IntVec3(j, 0, i);
thing = c.GetEdifice();
if (thing != null)
{
var thingDef = blue.def.entityDefToBuild as ThingDef;
if (thingDef != null && thingDef.building.canPlaceOverWall && thing.def == ThingDefOf.Wall)
{
return null;
}
break;
}
j++;
}
if (thing != null)
{
break;
}
}
if (thing == null || !pawn.CanReserve(thing))
{
return null;
}
return new Job(JobDefOf.Deconstruct, thing)
{
ignoreDesignations = true
};
}
开发者ID:RWA-Team,项目名称:RimworldAscension,代码行数:40,代码来源:WorkGiver_ConstructDeliverResourcesToBlueprints.cs
示例14: GetFloatMenuOptions
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn)
{
List<FloatMenuOption> list = new List<FloatMenuOption>();
{
if (!myPawn.CanReserve(this, 1))
{
FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null);
return new List<FloatMenuOption>
{
item
};
}
if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some))
{
FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null);
return new List<FloatMenuOption>
{
item2
};
}
Action action3 = delegate
{
Job job = new Job(DefDatabase<JobDef>.GetNamed("ClutterGoAndPickUpItem", true), this, this.Position);
myPawn.drafter.TakeOrderedJob(job);
OwnerPawn = myPawn;
};
list.Add(new FloatMenuOption("Pick Up" + this.def.LabelCap, action3));
Action action2 = delegate
{
Job job = new Job(DefDatabase<JobDef>.GetNamed("ClutterUseItem", true), this, this.Position);
myPawn.drafter.TakeOrderedJob(job);
OwnerPawn = myPawn;
};
list.Add(new FloatMenuOption("Use" + this.def.LabelCap, action2));
}
return list;
}
示例15: GetFloatMenuOptions
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn)
{
List<FloatMenuOption> list = new List<FloatMenuOption>();
{
if (!myPawn.CanReserve(this))
{
FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null);
return new List<FloatMenuOption>
{
item
};
}
if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some))
{
FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null);
return new List<FloatMenuOption>
{
item2
};
}
if (OwnerPawn == null)
{
Action action = delegate
{
job1 = new Job(JobDefOf.Goto, this.InteractionCell);
job2 = new Job(JobDefOf.Wait, 18100);
myPawn.drafter.TakeOrderedJob(job1);
myPawn.drafter.pawn.QueueJob(job2);
JobPawn = myPawn;
myPawn.Reserve(this);
};
list.Add(new FloatMenuOption("Use Dermal Regenerator", action));
}
}
return list;
}