本文整理汇总了C#中Pawn.TryGetAttackVerb方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.TryGetAttackVerb方法的具体用法?C# Pawn.TryGetAttackVerb怎么用?C# Pawn.TryGetAttackVerb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.TryGetAttackVerb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGiveTerminalJob
private const float maxCoverDist = 10f; //Maximum distance to run for cover to
#endregion Fields
#region Methods
protected override Job TryGiveTerminalJob(Pawn pawn)
{
//Calculate cover position
CompSuppressable comp = pawn.TryGetComp<CompSuppressable>();
if (comp == null)
{
return null;
}
float distToSuppressor = (pawn.Position - comp.suppressorLoc).LengthHorizontal;
Verb verb = pawn.TryGetAttackVerb(!pawn.IsColonist);
IntVec3 coverPosition;
//Try to find cover position to move up to
if (!this.GetCoverPositionFrom(pawn, comp.suppressorLoc, maxCoverDist, out coverPosition))
{
return null;
}
//Sanity check
if (pawn.Position == coverPosition)
{
return null;
}
//Tell pawn to move to position
Find.PawnDestinationManager.ReserveDestinationFor(pawn, coverPosition);
return new Job(DefDatabase<JobDef>.GetNamed("RunForCover", true), coverPosition)
{
locomotionUrgency = LocomotionUrgency.Sprint,
playerForced = true
};
}
示例2: JobOnThing
public override Job JobOnThing( Pawn pawn, Thing t )
{
//Log.Message( string.Format( "WorkGiver_Warden_ArrestLawBreaker( {0}, {1} )", pawn.LabelShort, t.ThingID ) );
if( Monitor.laws.NullOrEmpty() )
{ // No laws to enforce
return null;
}
var otherPawn = t as Pawn;
if( otherPawn == null )
{ // Thing isn't a pawn
return null;
}
if( !pawn.CanReserveAndReach( otherPawn, PathEndMode.ClosestTouch, Danger.Deadly, 1 ) )
{ // Can't get to other pawn
//Log.Message( string.Format( "\t{0} cannot reach and reserve {1}", pawn.LabelShort, t.ThingID ) );
return null;
}
var compPrisoner = otherPawn.TryGetComp<CompPrisoner>();
if( compPrisoner == null )
{ // Pawn is missing comp
//Log.ErrorOnce( string.Format( "{0} is missing CompPrisoner!", otherPawn.LabelShort ), ( 0x0BAD0000 | ( otherPawn.GetHashCode() & 0x0000FFFF ) ) );
return null;
}
if( compPrisoner.wasArrested )
{ // Pawn was already arrested
//Log.Message( string.Format( "\t{0} wasArrested already", pawn.LabelShort ) );
return null;
}
LawDef lawBroken = compPrisoner.lawBroken;
if( otherPawn.CanBeSeenByColony() )
{ // Pawn can be seen, check for laws being broken
foreach( var law in Monitor.laws )
{
if(
( law.lawWorker.CanArrestFor( otherPawn ) )&&
( law.lawWorker.LawBroken( otherPawn ) )
)
{
if(
( lawBroken == null )||
( law.severity > lawBroken.severity )
)
{ // No outstanding warrant or the new crime is more severe than the current one
lawBroken = law;
}
}
}
}
if( lawBroken == null )
{ // No laws broken
return null;
}
//Log.Message( string.Format( "{0} wants to arrest {1} for {2}", pawn.NameStringShort, otherPawn.NameStringShort, lawBroken.label ) );
compPrisoner.lawBroken = lawBroken;
if( !otherPawn.CanBeArrested() )
{ // Needs to be subdued first
//Log.Message( string.Format( "{0} can't arrest {1}, refuses to be arrested", pawn.NameStringShort, otherPawn.NameStringShort ) );
var attackVerb = pawn.TryGetAttackVerb();
bool nonLethal = (
( attackVerb == null )||
( attackVerb.verbProps.meleeDamageDef == DamageDefOf.Stun )
);
if(
( !lawBroken.allowLethalForceToSubdue )&&
( !nonLethal )
)
{
//Log.Message( string.Format( "{0} needs to subdue {1} but is using a weapon with lethal force which the law doesn't allow", pawn.NameStringShort, otherPawn.NameStringShort ) );
return null;
}
//Log.Message( string.Format( "{0} is subduing {1}", pawn.NameStringShort, otherPawn.NameStringShort ) );
var subdueJob = new Job( JobDefOf.AttackStatic, otherPawn );
return subdueJob;
}
Building_Bed bedFor = null;
List<Building_Door> doors = null;
if(
( lawBroken.takeHomeByDefault )&&
( otherPawn.IsColonist )
)
{ // Take the offender home (only if they are a colonist)
//Log.Message( string.Format( "{0} wants to take {1} home", pawn.NameStringShort, otherPawn.NameStringShort ) );
bedFor = otherPawn.ownership.OwnedBed;
doors = bedFor.GetRoom().Portals();
}
if(
( bedFor == null )&&
( lawBroken.takeToPrisonIfNoHome )
//.........这里部分代码省略.........