Esempio n. 1
0
        //检查是否能被控制
        public bool canBeControled(Pawn becontroler)
        {
            if (becontroler.kindDef.defName.EqualsIgnoreCase("ra2_yuriyuri"))
            {
                return(false);
            }
            float result = StatUtility.GetStatValueFromList(becontroler.def.statBases, StatDefOf.PsychicSensitivity, 1.0f);

            if (result == 0)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Calculates the extra yield for a given task and pawn.
        /// </summary>
        /// <param name="stat">The stat to check</param>
        /// <param name="req">The pawn we are checking the stat on</param>
        /// <returns>The extra yield</returns>
        private static float CuteboldCalculateExtraPercent(StatDef stat, StatRequest req, bool useMultiplier = true)
        {
            Pawn pawn = req.Pawn ?? (req.Thing is Pawn ? (Pawn)req.Thing : null);

            if (stat == null || req == null || pawn?.def != Cutebold_Assemblies.AlienRaceDef)
            {
                return(0f);
            }
            if (stat == StatDefOf.PlantHarvestYield)
            {
                useMultiplier = false;
            }

            float rawPercent           = stat.Worker.GetValueUnfinalized(req, false);
            float pawnBasePercent      = StatUtility.GetStatValueFromList(req.StatBases, stat, 1f);
            float defaultMaxPercent    = stat.maxValue;
            float adaptationMultiplier = MiningMultiplier(pawn, useMultiplier);

            float extraPercent = (rawPercent < defaultMaxPercent) ? 0f : (rawPercent - defaultMaxPercent) * adaptationMultiplier;

            return((extraPercent > 0f) ? extraPercent : 0f);
        }
        private static float SurvivalToolScore(Thing toolThing, List <StatDef> workRelevantStats)
        {
            SurvivalTool tool = toolThing as SurvivalTool;

            if (tool == null)
            {
                return(0f);
            }

            float optimality = 0f;

            foreach (StatDef stat in workRelevantStats)
            {
                optimality += StatUtility.GetStatValueFromList(tool.WorkStatFactors.ToList(), stat, 0f);
            }

            if (tool.def.useHitPoints)
            {
                float lifespanRemaining = tool.GetStatValue(ST_StatDefOf.ToolEstimatedLifespan, true) * ((float)tool.HitPoints * tool.MaxHitPoints);
                optimality *= LifespanDaysToOptimalityMultiplierCurve.Evaluate(lifespanRemaining);
            }
            return(optimality);
        }