本文整理汇总了C#中Pawn.GetStatValue方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.GetStatValue方法的具体用法?C# Pawn.GetStatValue怎么用?C# Pawn.GetStatValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.GetStatValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGuestImproveRelationship
private static readonly string txtRecruitSuccess = "MessageRecruitSuccess".Translate(); // from core
#endregion Fields
#region Methods
public static bool TryGuestImproveRelationship(Pawn recruiter, Pawn guest)
{
if (recruiter == null || guest == null || guest.guest == null) return false;
recruiter.skills.Learn(SkillDefOf.Social, 25f);
float chance = recruiter.GetStatValue(statOffendGuestChance);
bool result = false;
if (Rand.Value <= chance)
{
//Log.Message("textAnger");
Messages.Message(string.Format(txtImproveFactionAnger, recruiter.Nickname, guest.Faction.name, chance.ToStringPercent()), MessageSound.Negative);
float impact = -(Rand.Range(3, 8) * (1 - 0.0375f * recruiter.skills.GetSkill(SkillDefOf.Social).level)); //Social skill level 20 reduces negative impact by 75%, Skilllevel 0 results in full impact; linear
guest.Faction.AffectGoodwillWith(Faction.OfColony, impact);
guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestOffendedRelationship"));
//Log.Message("Goodwill changed by : " + impact);
}
else
{
//Log.Message("textPlease");
Messages.Message(string.Format(txtImproveFactionPlease, recruiter.Nickname, guest.Faction.name, (1 - chance).ToStringPercent()), MessageSound.Benefit);
guest.Faction.AffectGoodwillWith(Faction.OfColony, 0.1f + 0.045f * recruiter.skills.GetSkill(SkillDefOf.Social).level); //Social skilllevel 20 results in +1 relationship, Skilllevel 0 results in +0.1 change, linear
guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestPleasedRelationship"));
result = true;
//Log.Message("Goodwill changed by : " + (0.1f + 0.05f * recruiter.skills.GetSkill(SkillDefOf.Social).level));
}
if (Rand.Value <= GuestUtility.GetDismissiveChance(guest))
{
//Log.Message("DismissiveChance SUCCESS - " + guest.Name + " will not talk with you for a while!");
//Message einbauen
guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestDismissiveAttitude"));
}
//else Log.Message("DismissiveChance FAILED - " + guest.Name + " will continue to talk with you!");
return result;
}
示例2: Draw
public void Draw(Rect rect, Pawn ownerPawn)
{
switch (oType)
{
case objectType.Stat:
Text.Anchor = TextAnchor.MiddleCenter;
StatDef stat = (StatDef)displayObject;
string statValue = (stat.ValueToString(ownerPawn.GetStatValue((StatDef)displayObject, true)));
Widgets.Label(rect, statValue);
if (Mouse.IsOver(rect))
{
GUI.DrawTexture(rect, TexUI.HighlightTex);
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine(stat.LabelCap);
stringBuilder.AppendLine();
stringBuilder.AppendLine(stat.description);
TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), rect.GetHashCode()));
break;
case objectType.Skill:
DrawSkill(rect, ownerPawn);
break;
case objectType.Need:
DrawNeed(rect, ownerPawn);
break;
case objectType.Gear:
DrawGear(rect, ownerPawn);
break;
case objectType.ControlPrisonerGetsFood:
if (Mouse.IsOver(rect))
{
GUI.DrawTexture(rect, TexUI.HighlightTex);
}
bool getsFood = ownerPawn.guest.GetsFood;
Widgets.LabelCheckbox(new Rect(rect.x + 8f, rect.y + 3f, 27f, 27f), "", ref getsFood, false);
ownerPawn.guest.GetsFood = getsFood;
break;
case objectType.ControlPrisonerInteraction:
if (Mouse.IsOver(rect))
{
GUI.DrawTexture(rect, TexUI.HighlightTex);
}
float x = 8f;
GUI.BeginGroup(rect);
IEnumerator enumerator = Enum.GetValues(typeof(PrisonerInteractionMode)).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
PrisonerInteractionMode prisonerInteractionMode = (PrisonerInteractionMode)((byte)enumerator.Current);
if (Widgets.RadioButton(new Vector2(x, 3f), ownerPawn.guest.interactionMode == prisonerInteractionMode))
{
ownerPawn.guest.interactionMode = prisonerInteractionMode;
}
TooltipHandler.TipRegion(new Rect(x,0f,30f,30f), new TipSignal(prisonerInteractionMode.GetLabel()));
x += 30f;
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
GUI.EndGroup();
break;
case objectType.ControlMedicalCare:
MedicalCareSetter(rect, ref ownerPawn.playerSettings.medCare);
break;
}
}
示例3: GetMoveSpeed
/// <summary>
/// Calculates the actual current movement speed of a pawn
/// </summary>
private float GetMoveSpeed(Pawn pawn)
{
float movePerTick = 60 / pawn.GetStatValue(StatDefOf.MoveSpeed, false); //Movement per tick
movePerTick += PathGrid.CalculatedCostAt(pawn.Position, false);
Building edifice = pawn.Position.GetEdifice();
if (edifice != null)
{
movePerTick += (int)edifice.PathWalkCostFor(pawn);
}
//Case switch to handle walking, jogging, etc.
if (pawn.CurJob != null)
{
switch (pawn.CurJob.locomotionUrgency)
{
case LocomotionUrgency.Amble:
movePerTick *= 3;
if (movePerTick < 60)
{
movePerTick = 60;
}
break;
case LocomotionUrgency.Walk:
movePerTick *= 2;
if (movePerTick < 50)
{
movePerTick = 50;
}
break;
case LocomotionUrgency.Jog:
break;
case LocomotionUrgency.Sprint:
movePerTick = Mathf.RoundToInt(movePerTick * 0.75f);
break;
}
}
return 60 / movePerTick;
}
示例4: TryGuestRecruit
public static bool TryGuestRecruit(Pawn recruiter, Pawn guest)
{
if (recruiter == null || guest == null || guest.guest == null) return false;
recruiter.skills.Learn(SkillDefOf.Social, 35f);
float recruitDifficulty = guest.guest.RecruitDifficulty;
if (guest.needs.mood.CurLevel*100 >= recruitDifficulty)
{
float recruitChance = recruiter.GetStatValue(StatDefOf.RecruitPrisonerChance);
recruitChance *= 1f - recruitDifficulty/100f;
if (recruitChance < 0.011f)
{
recruitChance = 0.011f;
}
if (DebugSettings.instantRecruit)
{
recruitChance = 1f;
}
if (Rand.Value <= recruitChance)
{
//Log.Message("txtRecruitSuccess");
Find.LetterStack.ReceiveLetter(labelRecruitSuccess,
string.Format(txtRecruitSuccess, recruiter, guest, recruitChance.ToStringPercent()),
LetterType.Good, guest);
//if (guest.JailerFaction != null)
if (guest.Faction != recruiter.Faction)
{
if (guest.Faction != null)
{
guest.Faction.AffectGoodwillWith(Faction.OfColony, -guest.RecruitPenalty());
if (guest.RecruitPenalty() >= 1)
{
//Log.Message("txtRecruitFactionAnger");
var message = "";
if (guest.Faction.leader != null)
{
message = string.Format(txtRecruitFactionAnger, guest.Faction.leader.Name, guest.Faction.name, guest.Nickname, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.FloatZero, ToStringNumberSense.Offset));
Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefAnger, message, LetterType.BadNonUrgent);
}
else
{
message = string.Format(txtRecruitFactionAngerLeaderless, guest.Faction.name, guest.Nickname, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.FloatZero, ToStringNumberSense.Offset));
Find.LetterStack.ReceiveLetter(labelRecruitFactionAnger, message, LetterType.BadNonUrgent);
}
}
else if (guest.RecruitPenalty() <= -1)
{
//Log.Message("txtRecruitFactionPlease");
var message = "";
if (guest.Faction.leader != null)
{
message = string.Format(txtRecruitFactionPlease, guest.Faction.leader.Name, guest.Faction.name, guest.Nickname, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.FloatZero, ToStringNumberSense.Offset));
Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefPlease, message, LetterType.Good);
}
else
{
message = string.Format(txtRecruitFactionPleaseLeaderless, guest.Faction.name, guest.Nickname, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.FloatZero, ToStringNumberSense.Offset));
Find.LetterStack.ReceiveLetter(labelRecruitFactionPlease, message, LetterType.Good);
}
}
}
//guest.mindState.duty = null;
AdoptGuest(guest, recruiter.Faction);
}
var taleParams = new object[] {recruiter, guest};
TaleRecorder.RecordTale(TaleDef.Named("Recruited"), taleParams);
return true;
}
Messages.Message(string.Format(txtRecruitFail, recruiter, guest, recruitChance.ToStringPercent()), MessageSound.Negative);
}
//Messages.Message(string.Format(txtRecruitFailMood, recruiter.Nickname, guest), MessageSound.Negative);
//var difference = recruitDifficulty - guest.needs.mood.CurLevel;
//var thought = ThoughtDef.Named(difference >= 10 ? "GuestOffended" : "GuestConvinced");
// guest.needs.mood.thoughts.TryGainThought(thought);
float chance = recruiter.GetStatValue(statOffendGuestChance);
if (Rand.Value < chance)
{
var isAbrasive = recruiter.story.traits.HasTrait(TraitDefOf.Abrasive);
int multiplier = isAbrasive ? 2 : 1;
string multiplierText = multiplier > 1 ? " x" + multiplier : string.Empty;
//Log.Message("textAnger");
string textAnger = recruiter.gender == Gender.Female ? txtRecruitAngerSelfF : txtRecruitAngerSelfM;
Messages.Message(string.Format(textAnger, recruiter.Nickname, guest.Nickname, chance.ToStringPercent(), multiplierText), MessageSound.Negative);
guest.Faction.AffectGoodwillWith(Faction.OfColony, -1f + 0.045f * recruiter.skills.GetSkill(SkillDefOf.Social).level);
for (int i = 0; i < multiplier; i++)
{
guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestOffended"));
}
}
else
{
var statValue = recruiter.GetStatValue(statRecruitEffectivity);
var floor = Mathf.FloorToInt(statValue);
int multiplier = floor + (Rand.Value < statValue - floor?1:0);
string multiplierText = multiplier > 1 ? " x" + multiplier : string.Empty;
//Log.Message("textPlease");
//.........这里部分代码省略.........
示例5: CheckAnger
private static void CheckAnger(Pawn recruiter, Pawn guest)
{
if (guest.Faction == null || recruiter == null || guest.Faction==Faction.OfColony) return;
var allies = Find.ListerPawns.PawnsInFaction(guest.Faction);
foreach (var ally in allies)
{
if (ally != guest && !ally.Dead && ally.SpawnedInWorld && ally.CanSee(recruiter) && ally.CanSee(guest))
{
float chance = recruiter.GetStatValue(statOffendGuestChance);
if (Rand.Value < chance)
{
//Log.Message("txtRecruitAngerOther");
Messages.Message(string.Format(txtRecruitAngerOther, recruiter.Nickname, guest.Nickname, chance.ToStringPercent(), ally.Nickname), MessageSound.Negative);
ally.Faction.AffectGoodwillWith(Faction.OfColony, -1f + 0.045f * recruiter.skills.GetSkill(SkillDefOf.Social).level); //Skill based influence -0.1 ... -1
ally.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestAngered"));
}
}
}
}
示例6: GetAfterArmorDamage
/// <summary>
/// Calculates deflection chance and damage through armor
/// </summary>
public static int GetAfterArmorDamage(Pawn pawn, int amountInt, BodyPartRecord part, DamageInfo dinfo, bool damageArmor, ref bool deflected)
{
DamageDef damageDef = dinfo.Def;
if (damageDef.armorCategory == DamageArmorCategory.IgnoreArmor)
{
return amountInt;
}
float damageAmount = (float)amountInt;
StatDef deflectionStat = damageDef.armorCategory.DeflectionStat();
float pierceAmount = 0f;
//Check if the projectile has the armor-piercing comp
CompProperties_AP props = null;
if (dinfo.Source != null)
{
VerbProperties verbProps = dinfo.Source.Verbs.Where(x => x.isPrimary).First();
if (verbProps != null)
{
ThingDef projectile = verbProps.projectileDef;
if (projectile != null && projectile.HasComp(typeof(CompAP)))
{
props = (CompProperties_AP)projectile.GetCompProperties(typeof(CompAP));
}
}
//Check weapon for comp if projectile doesn't have it
if (props == null && dinfo.Source.HasComp(typeof(CompAP)))
{
props = (CompProperties_AP)dinfo.Source.GetCompProperties(typeof(CompAP));
}
}
if (props != null)
{
pierceAmount = props.armorPenetration;
}
//Run armor calculations on all apparel
if (pawn.apparel != null)
{
List<Apparel> wornApparel = new List<Apparel>(pawn.apparel.WornApparel);
for (int i = wornApparel.Count - 1; i >= 0; i--)
{
if (wornApparel[i].def.apparel.CoversBodyPart(part))
{
Thing armorThing = damageArmor ? wornApparel[i] : null;
//Check for deflection
if (Utility.ApplyArmor(ref damageAmount, ref pierceAmount, wornApparel[i].GetStatValue(deflectionStat, true), armorThing, damageDef))
{
deflected = true;
if (damageDef != absorbDamageDef)
{
damageDef = absorbDamageDef;
deflectionStat = damageDef.armorCategory.DeflectionStat();
i++;
}
}
if (damageAmount < 0.001)
{
return 0;
}
}
}
}
//Check for pawn racial armor
if (Utility.ApplyArmor(ref damageAmount, ref pierceAmount, pawn.GetStatValue(deflectionStat, true), null, damageDef))
{
deflected = true;
if (damageAmount < 0.001)
{
return 0;
}
damageDef = absorbDamageDef;
deflectionStat = damageDef.armorCategory.DeflectionStat();
Utility.ApplyArmor(ref damageAmount, ref pierceAmount, pawn.GetStatValue(deflectionStat, true), pawn, damageDef);
}
return Mathf.RoundToInt(damageAmount);
}
示例7: ApparelScoreRaw
public static float ApparelScoreRaw( Apparel apparel, Pawn pawn )
{
// relevant apparel stats
HashSet<StatDef> equippedOffsets = new HashSet<StatDef>();
if ( apparel.def.equippedStatOffsets != null )
{
foreach ( StatModifier equippedStatOffset in apparel.def.equippedStatOffsets )
{
equippedOffsets.Add( equippedStatOffset.stat );
}
}
HashSet<StatDef> statBases = new HashSet<StatDef>();
if ( apparel.def.statBases != null )
{
foreach ( StatModifier statBase in apparel.def.statBases )
{
statBases.Add( statBase.stat );
}
}
// start score at 1
float score = 1;
// make infusions ready
InfusionSet infusions;
bool infused = false;
StatMod mod;
InfusionDef prefix = null;
InfusionDef suffix = null;
if ( apparel.TryGetInfusions( out infusions ) )
{
infused = true;
prefix = infusions.Prefix.ToInfusionDef();
suffix = infusions.Suffix.ToInfusionDef();
}
// add values for each statdef modified by the apparel
foreach( ApparelStatCache.StatPriority statPriority in pawn.GetApparelStatCache().StatCache )
{
// statbases, e.g. armor
if ( statBases.Contains( statPriority.Stat ) )
{
// add stat to base score before offsets are handled ( the pawn's apparel stat cache always has armors first as it is initialized with it).
score += apparel.GetStatValue( statPriority.Stat ) * statPriority.Weight;
}
// equipped offsets, e.g. movement speeds
if ( equippedOffsets.Contains( statPriority.Stat ) )
{
// base value
float norm = apparel.GetStatValue( statPriority.Stat );
float adjusted = norm;
// add offset
adjusted += apparel.def.equippedStatOffsets.GetStatOffsetFromList( statPriority.Stat ) *
statPriority.Weight;
// normalize
if ( norm != 0 )
{
adjusted /= norm;
}
// multiply score to favour items with multiple offsets
score *= adjusted;
//debug.AppendLine( statWeightPair.Key.LabelCap + ": " + score );
}
// infusions
if( infused ) {
// prefix
if ( !infusions.PassPre &&
prefix.GetStatValue( statPriority.Stat, out mod ) )
{
score += mod.offset * statPriority.Weight;
score += score * ( mod.multiplier - 1 ) * statPriority.Weight;
//debug.AppendLine( statWeightPair.Key.LabelCap + " infusion: " + score );
}
if ( !infusions.PassSuf &&
suffix.GetStatValue( statPriority.Stat, out mod ) )
{
score += mod.offset * statPriority.Weight;
score += score * ( mod.multiplier - 1 ) * statPriority.Weight;
//debug.AppendLine( statWeightPair.Key.LabelCap + " infusion: " + score );
}
}
}
// offset for apparel hitpoints
if ( apparel.def.useHitPoints )
{
// durability on 0-1 scale
float x = apparel.HitPoints / (float)apparel.MaxHitPoints;
score *= HitPointsPercentScoreFactorCurve.Evaluate( x );
}
// temperature
//.........这里部分代码省略.........