当前位置: 首页>>代码示例>>C#>>正文


C# Pawn.GetApparelStatCache方法代码示例

本文整理汇总了C#中Pawn.GetApparelStatCache方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.GetApparelStatCache方法的具体用法?C# Pawn.GetApparelStatCache怎么用?C# Pawn.GetApparelStatCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pawn的用法示例。


在下文中一共展示了Pawn.GetApparelStatCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

 public void Delete( Pawn pawn )
 {
     pawn.GetApparelStatCache()._cache.Remove( this );
 }
开发者ID:FluffierThanThou,项目名称:RW_Outfitter,代码行数:4,代码来源:ApparelStatCache.cs

示例2: 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
//.........这里部分代码省略.........
开发者ID:FluffierThanThou,项目名称:RW_Outfitter,代码行数:101,代码来源:ApparelStatsHelper.cs


注:本文中的Pawn.GetApparelStatCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。