예제 #1
0
        public static float?MeleeDpsBluntFactorOverall(this ThingDef d)
        {
            float damage   = d.GetStatValueAbstract(StatDefOf.BluntDamageMultiplier);
            float?cooldown = d.GetStatFactorValue(StatDefOf.MeleeWeapon_CooldownMultiplier);

            return(cooldown == null ? null : (damage / cooldown).RoundTo2());
        }
예제 #2
0
        private static Material MakeRow(ThingDef d)
        {
            var row = new Material {
                Label = d.LabelCap, Description = d.DescriptionDetailed, ItemsOnMap = d.CountOnMap()
            };

            try
            {
                row.TexturePath = d.modContentPack.RootDir + @"\Textures\" + d.graphicData.texPath;
            }
            catch
            {
            }

            var fields = typeof(StatDefOf).GetFields();

            foreach (var field in fields)
            {
                var rowProp = typeof(Material).GetProperty(field.Name);
                if (rowProp != null)
                {
                    StatDef statDef = (StatDef)field.GetValue(null);

                    IsStatFactor.TryGetValue(field.Name, out bool isStatFactor);

                    float?value = isStatFactor ? d.GetStatFactorValue(statDef) : d.GetStatValueAbstract(statDef);
                    rowProp.SetValue(row, value.Nullify().ByStyle(statDef.toStringStyle), null);
                }
            }

            row.HitPoints = d.GetStatFactorValue(StatDefOf.MaxHitPoints).Nullify().ToPercent();

            // CombatExtended
            if (CE_MeleePenetrationFactor != null)
            {
                row.CE_MeleePenetrationFactor = d.GetStatFactorValue(CE_MeleePenetrationFactor);
            }

            row.Category = GetCategory(d);

            return(row);
        }
예제 #3
0
        //public static float GetStatValue(this Thing thing, StatDef stat, bool applyPostProcess = true)
        //{
        //    return stat.Worker.GetValue(thing, applyPostProcess);
        //}

        //public static float GetStatValueAbstract(this BuildableDef def, StatDef stat, ThingDef stuff = null)
        //{
        //    return stat.Worker.GetValueAbstract(def, stuff);
        //}

        public static float?MeleeDpsSharpFactorOverall(this ThingDef d)
        {
            float damage   = d.GetStatValueAbstract(StatDefOf.SharpDamageMultiplier);
            float?cooldown = d.GetStatFactorValue(StatDefOf.MeleeWeapon_CooldownMultiplier);

            if (cooldown == null)
            {
                return(null);
            }
            return((damage / cooldown).RoundTo2());
        }
예제 #4
0
        private static BuildingsFromMaterial MakeRow(ThingDef building, ThingDef stuff)
        {
            var row = new BuildingsFromMaterial
            {
                Label = building.LabelCap, Material = stuff.LabelCap, Description = building.DescriptionDetailed
            };

            try
            {
                row.TexturePath = building.modContentPack.RootDir + @"\Textures\" + building.graphicData.texPath;
            }
            catch
            {
            }

            row.ImmunityGainSpeedFactor  = stuff.GetStatFactorValue(StatDefOf.ImmunityGainSpeedFactor).ToPercent();
            row.BedRestEffectiveness     = stuff.GetStatFactorValue(StatDefOf.BedRestEffectiveness).ToPercent();
            row.WorkTableWorkSpeedFactor = stuff.GetStatFactorValue(StatDefOf.WorkTableWorkSpeedFactor).ToPercent();
            row.ResearchSpeedFactor      = stuff.GetStatFactorValue(StatDefOf.ResearchSpeedFactor).ToPercent();
            row.MaxHitPoints             = stuff.GetStatFactorValue(StatDefOf.MaxHitPoints).ToPercent();
            row.MarketValue = stuff.GetStatFactorValue(StatDefOf.MarketValue).ToPercent();

            return(row);
        }