示例#1
0
        public static ThingDef GetProjectile(this Verb verb)
        {
            Verb_LaunchProjectile verb_LaunchProjectile = verb as Verb_LaunchProjectile;

            return((verb_LaunchProjectile == null) ? null : verb_LaunchProjectile.Projectile);
        }
示例#2
0
        private static void DoTablesInternalMelee(ThingDef stuff, bool doRaces = false)
        {
            Func <Def, float> meleeDamageGetter = delegate(Def d)
            {
                List <Verb> concreteExampleVerbs5 = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                if (concreteExampleVerbs5.OfType <Verb_MeleeAttack>().Any())
                {
                    return(concreteExampleVerbs5.OfType <Verb_MeleeAttack>().AverageWeighted((Verb_MeleeAttack v) => v.verbProps.AdjustedMeleeSelectionWeight(v, null), (Verb_MeleeAttack v) => v.verbProps.AdjustedMeleeDamageAmount(v, null)));
                }
                return(-1f);
            };
            Func <Def, float> rangedDamageGetter = delegate(Def d)
            {
                List <Verb>           concreteExampleVerbs4 = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                Verb_LaunchProjectile verb_LaunchProjectile = concreteExampleVerbs4.OfType <Verb_LaunchProjectile>().FirstOrDefault();
                if (verb_LaunchProjectile != null && verb_LaunchProjectile.GetProjectile() != null)
                {
                    return((float)verb_LaunchProjectile.GetProjectile().projectile.GetDamageAmount(null));
                }
                return(-1f);
            };
            Func <Def, float> rangedWarmupGetter = delegate(Def d)
            {
                List <Verb> concreteExampleVerbs3 = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                return(concreteExampleVerbs3.OfType <Verb_LaunchProjectile>().FirstOrDefault()?.verbProps.warmupTime ?? (-1f));
            };
            Func <Def, float> meleeCooldownGetter = delegate(Def d)
            {
                List <Verb> concreteExampleVerbs2 = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                if (concreteExampleVerbs2.OfType <Verb_MeleeAttack>().Any())
                {
                    return(concreteExampleVerbs2.OfType <Verb_MeleeAttack>().AverageWeighted((Verb_MeleeAttack v) => v.verbProps.AdjustedMeleeSelectionWeight(v, null), (Verb_MeleeAttack v) => v.verbProps.AdjustedCooldown(v, null)));
                }
                return(-1f);
            };
            Func <Def, float> rangedCooldownGetter = delegate(Def d)
            {
                List <Verb> concreteExampleVerbs = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                return(concreteExampleVerbs.OfType <Verb_LaunchProjectile>().FirstOrDefault()?.verbProps.defaultCooldownTime ?? (-1f));
            };
            Func <Def, float> meleeDpsGetter    = (Def d) => meleeDamageGetter(d) * 0.82f / meleeCooldownGetter(d);
            Func <Def, float> marketValueGetter = delegate(Def d)
            {
                ThingDef thingDef3 = d as ThingDef;
                if (thingDef3 != null)
                {
                    return(thingDef3.GetStatValueAbstract(StatDefOf.MarketValue, stuff));
                }
                HediffDef hediffDef = d as HediffDef;
                if (hediffDef != null)
                {
                    if (hediffDef.spawnThingOnRemoved == null)
                    {
                        return(0f);
                    }
                    return(hediffDef.spawnThingOnRemoved.GetStatValueAbstract(StatDefOf.MarketValue));
                }
                return(-1f);
            };
            IEnumerable <Def> enumerable = (from d in DefDatabase <ThingDef> .AllDefs
                                            where d.IsWeapon
                                            select d).Cast <Def>().Concat((from h in DefDatabase <HediffDef> .AllDefs
                                                                           where h.CompProps <HediffCompProperties_VerbGiver>() != null
                                                                           select h).Cast <Def>());

            if (doRaces)
            {
                enumerable = enumerable.Concat((from d in DefDatabase <ThingDef> .AllDefs
                                                where d.race != null
                                                select d).Cast <Def>());
            }
            enumerable = from h in enumerable
                         orderby meleeDpsGetter(h) descending
                         select h;

            DebugTables.MakeTablesDialog(enumerable, new TableDataGetter <Def>("defName", (Def d) => d.defName), new TableDataGetter <Def>("melee\ndamage\naverage", (Def d) => meleeDamageGetter(d).ToString("F2")), new TableDataGetter <Def>("melee\ncooldown\naverage", (Def d) => meleeCooldownGetter(d).ToString("F2")), new TableDataGetter <Def>("melee\nDPS", (Def d) => meleeDpsGetter(d).ToString("F2")), new TableDataGetter <Def>("ranged\ndamage", (Def d) => rangedDamageGetter(d).ToString()), new TableDataGetter <Def>("ranged\nwarmup", (Def d) => rangedWarmupGetter(d).ToString("F2")), new TableDataGetter <Def>("ranged\ncooldown", (Def d) => rangedCooldownGetter(d).ToString("F2")), new TableDataGetter <Def>("market value", (Def d) => marketValueGetter(d).ToStringMoney()), new TableDataGetter <Def>("work to make", delegate(Def d)
            {
                ThingDef thingDef2 = d as ThingDef;
                if (thingDef2 == null)
                {
                    return("-");
                }
                return(thingDef2.GetStatValueAbstract(StatDefOf.WorkToMake, stuff).ToString("F0"));
            }), new TableDataGetter <Def>((stuff == null) ? "CanMake" : (stuff.defName + " CanMake"), delegate(Def d)
            {
                if (stuff == null)
                {
                    return("n/a");
                }
                ThingDef thingDef = d as ThingDef;
                if (thingDef == null)
                {
                    return("-");
                }
                return(stuff.stuffProps.CanMake(thingDef).ToStringCheckBlank());
            }), new TableDataGetter <Def>("assumed\nmelee\nhit chance", (Def d) => 0.82f.ToStringPercent()));
        }