本文整理汇总了C#中Pawn.TryGetComp方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.TryGetComp方法的具体用法?C# Pawn.TryGetComp怎么用?C# Pawn.TryGetComp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.TryGetComp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Satisfied
protected override bool Satisfied(Pawn pawn)
{
CompSuppressable comp = pawn.TryGetComp<CompSuppressable>();
if (comp == null)
{
return false;
}
float distToSuppressor = (pawn.Position - comp.suppressorLoc).LengthHorizontal;
if (distToSuppressor < CompSuppressable.minSuppressionDist)
{
return false;
}
return comp.isSuppressed;
}
示例3: _ShouldBeFed
internal static bool _ShouldBeFed( Pawn p )
{
if(
( !p.InBed() )||
( !p.health.PrefersMedicalRest )
)
{
return false;
}
if( p.IsPrisonerOfColony )
{
return p.guest.ShouldBeBroughtFood;
}
var compPrisoner = p.TryGetComp<CompPrisoner>();
if( compPrisoner != null )
{
return compPrisoner.wasArrested;
}
return false;
}
示例4: CurrentStateInternal
protected override ThoughtState CurrentStateInternal(Pawn p)
{
CompSuppressable comp = p.TryGetComp<CompSuppressable>();
if (comp != null)
{
if (comp.isHunkering)
{
return ThoughtState.ActiveAtStage(2);
}
else if (comp.isSuppressed)
{
return ThoughtState.ActiveAtStage(1);
}
else if (comp.currentSuppression > 0)
{
return ThoughtState.ActiveAtStage(0);
}
}
return ThoughtState.Inactive;
}
示例5: PawnCanOpen
public override bool PawnCanOpen( Pawn p, bool isEscaping )
{
// Not locked or picked
if( !Locked )
{ // Not locked to anyone
return true;
}
var compPrisoner = p.TryGetComp<CompPrisoner>();
if(
( p.IsPrisonerOfColony )||
(
( compPrisoner != null )&&
( compPrisoner.wasArrested )
)
)
{ // Locked to prisoners, slaves and colonists under house arrest
//Log.Message( string.Format( "\tCompLockable: door {0} is locked and pawn {1} is a prisoner/slave", this.parent.ThingID, p.NameStringShort ) );
return false;
}
if( p.Faction != Faction.OfPlayer )
{ // Locked to non-colonists
//Log.Message( string.Format( "\tCompLockable: door {0} is locked and pawn {1} is part of the colony", this.parent.ThingID, p.NameStringShort ) );
return false;
}
//Log.Message( string.Format( "{0}.Drafted = {1}", p.NameStringShort, p.Drafted ) );
if(
( Data.LockedDoorsAllowDrafted )&&
( p.Drafted )
)
{ // Is it unlocked to drafted?
//Log.Message( string.Format( "\tCompLockable: door {0} is locked but pawn {1} is drafted", this.parent.ThingID, p.NameStringShort ) );
return true;
}
if( // Is it unlocked to wardens or doctors?
( p.workSettings != null )&&
( p.workSettings.EverWork )&&
(
(
( Data.LockedDoorsAllowWardens )&&
( p.workSettings.WorkIsActive( WorkTypeDefOf.Warden ) )
) ||
(
( Data.LockedDoorsAllowDoctors )&&
( p.workSettings.WorkIsActive( WorkTypeDefOf.Doctor ) )
)
)
)
{
//Log.Message( string.Format( "\tCompLockable: door {0} is locked but pawn {1} is a doctor/warden", this.parent.ThingID, p.NameStringShort ) );
return true;
}
// Locked to everyone else
//Log.Message( string.Format( "\tCompLockable: door {0} is locked to pawn {1}", this.parent.ThingID, p.NameStringShort ) );
return false;
}
示例6: DrawPawnRow_Restrictions
private void DrawPawnRow_Restrictions( Rect r, Pawn p )
{
var compPrisoner = p.TryGetComp<CompPrisoner>();
if( compPrisoner == null )
{
Log.ErrorOnce( string.Format( "Pawn {0} is missing CompPrisoner!", p.NameStringShort ), ( p.thingIDNumber & 0xFFFF ) | 0x0BAD0000 );
return;
}
GUI.BeginGroup( r );
{
var rect1 = new Rect( 175f, 0.0f, 24f, 24f );
if( CCL_Widgets.ButtonImage( rect1, Data.Icons.Copy, "C", Data.Strings.Copy.Translate() ) )
{
this.CopyFrom_Restrictions( p );
SoundStarter.PlayOneShotOnCamera( SoundDefOf.TickHigh );
}
if( this.clipboard != null )
{
Rect rect2 = rect1;
rect2.x = rect1.xMax + 2f;
if( CCL_Widgets.ButtonImage( rect2, Data.Icons.Paste, "P", Data.Strings.Paste.Translate() ) )
{
this.PasteTo_Restrictions( p );
SoundStarter.PlayOneShotOnCamera( SoundDefOf.TickLow );
}
}
var left1 = 227f;
this.hourWidth = 20.83333f;
for( int hour = 0; hour < 24; ++hour )
{
this.DoTimeAssignment( new Rect( left1, 0.0f, this.hourWidth, r.height ), p, hour );
left1 += this.hourWidth;
}
GUI.color = Color.white;
var left2 = left1 + 6f;
var vector = new Vector2( 0f, 0f );
vector.x = left2 + ( widthGetsFood - 24f ) / 2f;
bool getsFood = p.guest.GetsFood;
Widgets.Checkbox( vector, ref getsFood );
p.guest.GetsFood = getsFood;
left2 += widthGetsFood + 6f;
vector.x = left2 + ( widthRestrainCuff - 24f ) / 2f;
Widgets.Checkbox( vector, ref compPrisoner.ShouldBeCuffed );
left2 += widthRestrainCuff + 6f;
vector.x = left2 + ( widthRestrainShackle - 24f ) / 2f;
Widgets.Checkbox( vector, ref compPrisoner.ShouldBeShackled );
left2 += widthRestrainShackle + 6f;
var rect3 = new Rect( left2, 0f, MedicalCareUtility.CareSetterWidth, 28f );
MedicalCareUtility.MedicalCareSetter( rect3, ref p.playerSettings.medCare );
}
GUI.EndGroup();
}
示例7: DrawAnimalRow
private void DrawAnimalRow( ref Vector2 cur, Vector2 size, Pawn p, bool alt )
{
// highlights and interactivity.
var row = new Rect( cur.x, cur.y, size.x, size.y );
if ( alt )
{
Widgets.DrawAltRect( row );
}
Widgets.DrawHighlightIfMouseover( row );
if ( Widgets.ButtonInvisible( row ) )
{
// move camera and select
Find.MainTabsRoot.EscapeCurrentTab();
Find.CameraDriver.JumpTo( p.PositionHeld );
Find.Selector.ClearSelection();
if ( p.Spawned )
{
Find.Selector.Select( p );
}
}
// use a third of available screenspace for labels
var nameRect = new Rect( cur.x, cur.y, size.x / 3f, size.y );
Utilities.Label( nameRect, p.LabelCap, anchor: TextAnchor.MiddleCenter, font: GameFont.Tiny );
cur.x += size.x / 3f;
// gender, lifestage, current meat (and if applicable, milking + shearing)
var cols = 3;
// extra columns?
if ( p.kindDef.Milkable() )
cols++;
if ( p.kindDef.Shearable() )
cols++;
float colwidth = size.x * 2 / 3 / cols;
// gender column
var genderRect = new Rect( cur.x, cur.y, colwidth, size.y );
Rect genderIconRect =
new Rect( 0f, 0f, _smallIconSize, _smallIconSize ).CenteredIn( genderRect );
switch ( p.gender )
{
case Gender.Female:
GUI.DrawTexture( genderIconRect, Resources.FemaleIcon );
break;
case Gender.Male:
GUI.DrawTexture( genderIconRect, Resources.MaleIcon );
break;
case Gender.None:
GUI.DrawTexture( genderIconRect, Resources.UnkownIcon );
break;
}
TooltipHandler.TipRegion( genderRect, p.gender.GetLabel() );
cur.x += colwidth;
// lifestage column
var ageRect = new Rect( cur.x, cur.y, colwidth, size.y );
Rect ageIconRect = new Rect( 0f, 0f, _smallIconSize, _smallIconSize ).CenteredIn( ageRect );
GUI.DrawTexture( ageIconRect, Resources.LifeStages[p.ageTracker.CurLifeStageIndex] );
TooltipHandler.TipRegion( ageRect, p.ageTracker.AgeTooltipString );
cur.x += colwidth;
// meat column
var meatRect = new Rect( cur.x, cur.y, colwidth, size.y );
// NOTE: When splitting tabs into separate mods; estimated meat count is defined in the Hunting helper.
Utilities.Label( meatRect, p.EstimatedMeatCount().ToString(), p.EstimatedMeatCount().ToString(),
TextAnchor.MiddleCenter,
font: GameFont.Tiny );
cur.x += colwidth;
// milk column
if ( p.Milkable() )
{
var milkRect = new Rect( cur.x, cur.y, colwidth, size.y );
var comp = p.TryGetComp<CompMilkable>();
Utilities.Label( milkRect, comp.Fullness.ToString( "0%" ),
"FML.Yields".Translate( comp.Props.milkDef.LabelCap, comp.Props.milkAmount ),
TextAnchor.MiddleCenter, font: GameFont.Tiny );
}
if ( p.kindDef.Milkable() )
cur.x += colwidth;
// wool column
if ( p.Shearable() )
{
var woolRect = new Rect( cur.x, cur.y, colwidth, size.y );
var comp = p.TryGetComp<CompShearable>();
Utilities.Label( woolRect, comp.Fullness.ToString( "0%" ),
"FML.Yields".Translate( comp.Props.woolDef.LabelCap, comp.Props.woolAmount ),
TextAnchor.MiddleCenter, font: GameFont.Tiny );
}
if ( p.kindDef.Milkable() )
cur.x += colwidth;
// do the carriage return on ref cur
cur.x = 0f;
cur.y += size.y;
//.........这里部分代码省略.........
示例8: _ShouldTakeCareOfPrisoner
internal bool _ShouldTakeCareOfPrisoner( Pawn warden, Thing thing )
{
var compPrisoner = warden.TryGetComp<CompPrisoner>();
if(
( compPrisoner != null )&&
( compPrisoner.wasArrested )
)
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - warden has been arrested themselves!", warden.LabelShort ) );
return false;
}
var prisoner = thing as Pawn;
if( prisoner == null )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - is not a Pawn", thing.ThingID ) );
return false;
}
if( prisoner.InAggroMentalState )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - InAggroMentalState", prisoner.LabelShort ) );
return false;
}
if( warden.IsForbidden( prisoner ) )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - IsForbidden( {1} )", prisoner.LabelShort, warden.LabelShort ) );
return false;
}
if( !warden.CanReserveAndReach( prisoner, PathEndMode.OnCell, warden.NormalMaxDanger(), 1 ) )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - !CanReserveAndReach( {1} )", prisoner.LabelShort, warden.LabelShort ) );
return false;
}
if( prisoner.Downed )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - Downed", prisoner.LabelShort ) );
return false;
}
if( !prisoner.Awake() )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - !Awake", prisoner.LabelShort ) );
return false;
}
if( prisoner.holder != null )
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - holder != null", prisoner.LabelShort ) );
return false;
}
if(
( prisoner.IsPrisonerOfColony )&&
( prisoner.guest.PrisonerIsSecure )
)
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - PrisonerIsSecure", prisoner.LabelShort ) );
return true;
}
compPrisoner = prisoner.TryGetComp<CompPrisoner>();
if(
( compPrisoner != null )&&
( compPrisoner.wasArrested )
)
{
//Log.Message( string.Format( "\t_ShouldTakeCareOfPrisoner - {0} - wasArrested", prisoner.LabelShort ) );
return true;
}
return false;
}