Ejemplo n.º 1
0
 private static string <PlantsBasics> m__5(ThingDef d)
 {
     return((d.ingestible == null) ? "-" : (d.GetStatValueAbstract(StatDefOf.Nutrition, null) / d.plant.growDays).ToString("F4"));
 }
		public BattleLogEntry_MeleeCombat(RulePackDef ruleDef, bool alwaysShowInCompact, Pawn initiator, Thing recipient, ImplementOwnerTypeDef implementType, string toolLabel, ThingDef ownerEquipmentDef = null, HediffDef ownerHediffDef = null, LogEntryDef def = null)
			: base(def)
		{
			this.ruleDef = ruleDef;
			this.alwaysShowInCompact = alwaysShowInCompact;
			this.initiator = initiator;
			this.implementType = implementType;
			this.ownerEquipmentDef = ownerEquipmentDef;
			this.ownerHediffDef = ownerHediffDef;
			this.toolLabel = toolLabel;
			if (recipient is Pawn)
			{
				recipientPawn = (recipient as Pawn);
			}
			else if (recipient != null)
			{
				recipientThing = recipient.def;
			}
			if (ownerEquipmentDef != null && ownerHediffDef != null)
			{
				Log.ErrorOnce($"Combat log owned by both equipment {ownerEquipmentDef.label} and hediff {ownerHediffDef.label}, may produce unexpected results", 96474669);
			}
		}
Ejemplo n.º 3
0
        private static float TrueWorkWithCarryTime(RecipeDef d)
        {
            ThingDef stuffDef = DebugOutputsEconomy.CheapestNonDerpStuff(d);

            return((float)d.ingredients.Count * 90f + d.WorkAmountTotal(stuffDef) + 90f);
        }
Ejemplo n.º 4
0
 public bool HasAttachment(ThingDef def)
 {
     return(this.GetAttachment(def) != null);
 }
Ejemplo n.º 5
0
 public BattleLogEntry_RangedImpact(Thing initiator, Thing recipient, Thing originalTarget, ThingDef weaponDef, ThingDef projectileDef, ThingDef coverDef)
 {
     if (initiator is Pawn)
     {
         initiatorPawn = (initiator as Pawn);
     }
     else if (initiator != null)
     {
         initiatorThing = initiator.def;
     }
     if (recipient is Pawn)
     {
         recipientPawn = (recipient as Pawn);
     }
     else if (recipient != null)
     {
         recipientThing = recipient.def;
     }
     if (originalTarget is Pawn)
     {
         originalTargetPawn   = (originalTarget as Pawn);
         originalTargetMobile = (!originalTargetPawn.Downed && !originalTargetPawn.Dead && originalTargetPawn.Awake());
     }
     else if (originalTarget != null)
     {
         originalTargetThing = originalTarget.def;
     }
     this.weaponDef     = weaponDef;
     this.projectileDef = projectileDef;
     this.coverDef      = coverDef;
 }
        public static bool Includes(this ThingRequestGroup group, ThingDef def)
        {
            switch (group)
            {
            case ThingRequestGroup.Undefined:
                return(false);

            case ThingRequestGroup.Nothing:
                return(false);

            case ThingRequestGroup.Everything:
                return(true);

            case ThingRequestGroup.HaulableEver:
                return(def.EverHaulable);

            case ThingRequestGroup.HaulableAlways:
                return(def.alwaysHaulable);

            case ThingRequestGroup.FoodSource:
                return(def.IsNutritionGivingIngestible || def.thingClass == typeof(Building_NutrientPasteDispenser));

            case ThingRequestGroup.FoodSourceNotPlantOrTree:
                return((def.IsNutritionGivingIngestible && (def.ingestible.foodType & ~FoodTypeFlags.Plant & ~FoodTypeFlags.Tree) != FoodTypeFlags.None) || def.thingClass == typeof(Building_NutrientPasteDispenser));

            case ThingRequestGroup.Corpse:
                return(def.thingClass == typeof(Corpse));

            case ThingRequestGroup.Blueprint:
                return(def.IsBlueprint);

            case ThingRequestGroup.BuildingArtificial:
                return(def.IsBuildingArtificial);

            case ThingRequestGroup.BuildingFrame:
                return(def.IsFrame);

            case ThingRequestGroup.Pawn:
                return(def.category == ThingCategory.Pawn);

            case ThingRequestGroup.PotentialBillGiver:
                return(!def.AllRecipes.NullOrEmpty <RecipeDef>());

            case ThingRequestGroup.Medicine:
                return(def.IsMedicine);

            case ThingRequestGroup.Filth:
                return(def.filth != null);

            case ThingRequestGroup.AttackTarget:
                return(typeof(IAttackTarget).IsAssignableFrom(def.thingClass));

            case ThingRequestGroup.Weapon:
                return(def.IsWeapon);

            case ThingRequestGroup.Refuelable:
                return(def.HasComp(typeof(CompRefuelable)));

            case ThingRequestGroup.HaulableEverOrMinifiable:
                return(def.EverHaulable || def.Minifiable);

            case ThingRequestGroup.Drug:
                return(def.IsDrug);

            case ThingRequestGroup.Shell:
                return(def.IsShell);

            case ThingRequestGroup.HarvestablePlant:
                return(def.category == ThingCategory.Plant && def.plant.Harvestable);

            case ThingRequestGroup.Fire:
                return(typeof(Fire).IsAssignableFrom(def.thingClass));

            case ThingRequestGroup.Plant:
                return(def.category == ThingCategory.Plant);

            case ThingRequestGroup.Construction:
                return(def.IsBlueprint || def.IsFrame);

            case ThingRequestGroup.HasGUIOverlay:
                return(def.drawGUIOverlay);

            case ThingRequestGroup.Apparel:
                return(def.IsApparel);

            case ThingRequestGroup.MinifiedThing:
                return(typeof(MinifiedThing).IsAssignableFrom(def.thingClass));

            case ThingRequestGroup.Grave:
                return(typeof(Building_Grave).IsAssignableFrom(def.thingClass));

            case ThingRequestGroup.Art:
                return(def.HasComp(typeof(CompArt)));

            case ThingRequestGroup.ThingHolder:
                return(def.ThisOrAnyCompIsThingHolder());

            case ThingRequestGroup.ActiveDropPod:
                return(typeof(IActiveDropPod).IsAssignableFrom(def.thingClass));

            case ThingRequestGroup.Transporter:
                return(def.HasComp(typeof(CompTransporter)));

            case ThingRequestGroup.LongRangeMineralScanner:
                return(def.HasComp(typeof(CompLongRangeMineralScanner)));

            case ThingRequestGroup.AffectsSky:
                return(def.HasComp(typeof(CompAffectsSky)));

            case ThingRequestGroup.PsychicDroneEmanator:
                return(def.HasComp(typeof(CompPsychicDrone)));

            case ThingRequestGroup.WindSource:
                return(def.HasComp(typeof(CompWindSource)));

            case ThingRequestGroup.AlwaysFlee:
                return(def.alwaysFlee);

            case ThingRequestGroup.ResearchBench:
                return(typeof(Building_ResearchBench).IsAssignableFrom(def.thingClass));

            case ThingRequestGroup.Facility:
                return(def.HasComp(typeof(CompFacility)));

            case ThingRequestGroup.AffectedByFacilities:
                return(def.HasComp(typeof(CompAffectedByFacilities)));

            case ThingRequestGroup.CreatesInfestations:
                return(def.HasComp(typeof(CompCreatesInfestations)));

            default:
                throw new ArgumentException("group");
            }
        }
Ejemplo n.º 7
0
 public bool CanEverEat(ThingDef t)
 {
     return(this.EatsFood && t.ingestible != null && t.ingestible.preferability != FoodPreferability.Undefined && this.Eats(t.ingestible.foodType));
 }
Ejemplo n.º 8
0
 private static string <BiomePlantsExpectedCount> m__1F(ThingDef d)
 {
     return(d.defName);
 }
Ejemplo n.º 9
0
 private static string <PlantCountsOnMap> m__21(ThingDef p)
 {
     return(p.defName);
 }
Ejemplo n.º 10
0
 private static string <BiomePlantsExpectedCount> m__1D(ThingDef k)
 {
     return(k.defName);
 }
Ejemplo n.º 11
0
 private static bool <BiomePlantsExpectedCount> m__1E(ThingDef d)
 {
     return(d.category == ThingCategory.Plant);
 }
Ejemplo n.º 12
0
 private static string <BiomePlantsExpectedCount> m__1A(ThingDef p, BiomeDef b)
 {
     return((b.CommonalityOfPlant(p) * b.plantDensity * 4000f).ToString("F0"));
 }
Ejemplo n.º 13
0
 private static string <PlantsBasics> m__7(ThingDef d)
 {
     return(d.plant.fertilitySensitivity.ToString("F2"));
 }
Ejemplo n.º 14
0
 private static string <PlantsBasics> m__6(ThingDef d)
 {
     return(d.plant.fertilityMin.ToString("F2"));
 }
Ejemplo n.º 15
0
 public virtual void ResolveReferences(ThingDef parentDef)
 {
 }
Ejemplo n.º 16
0
 private static bool <Biomes> m__22(ThingDef pd)
 {
     return(pd.plant.harvestedThingDef != null && pd.plant.harvestedThingDef.IsNutritionGivingIngestible);
 }
Ejemplo n.º 17
0
        public static void FlavorfulCombatTest()
        {
            List <DebugMenuOption>    list      = new List <DebugMenuOption>();
            IEnumerable <ManeuverDef> maneuvers = DefDatabase <ManeuverDef> .AllDefsListForReading;

            Func <ManeuverDef, RulePackDef>[] results = new Func <ManeuverDef, RulePackDef>[5]
            {
                (ManeuverDef m) => new RulePackDef[4]
                {
                    m.combatLogRulesHit,
                    m.combatLogRulesDeflect,
                    m.combatLogRulesMiss,
                    m.combatLogRulesDodge
                }.RandomElement(),
                (ManeuverDef m) => m.combatLogRulesHit,
                (ManeuverDef m) => m.combatLogRulesDeflect,
                (ManeuverDef m) => m.combatLogRulesMiss,
                (ManeuverDef m) => m.combatLogRulesDodge
            };
            string[] array = new string[5]
            {
                "(random)",
                "Hit",
                "Deflect",
                "Miss",
                "Dodge"
            };
            foreach (Pair <ManeuverDef, int> maneuverresult in maneuvers.Concat(null).Cross(Enumerable.Range(0, array.Length)))
            {
                DebugMenuOption item = new DebugMenuOption(string.Format("{0}/{1}", (maneuverresult.First == null) ? "(random)" : maneuverresult.First.defName, array[maneuverresult.Second]), DebugMenuOptionMode.Action, delegate
                {
                    CreateDamagedDestroyedMenu(delegate(Action <List <BodyPartRecord>, List <bool> > bodyPartCreator)
                    {
                        StringBuilder stringBuilder7 = new StringBuilder();
                        ManeuverDef maneuver         = default(ManeuverDef);
                        for (int num3 = 0; num3 < 100; num3++)
                        {
                            maneuver = maneuverresult.First;
                            if (maneuver == null)
                            {
                                maneuver = maneuvers.RandomElement();
                            }
                            RulePackDef rulePackDef     = results[maneuverresult.Second](maneuver);
                            List <BodyPartRecord> list8 = null;
                            List <bool> list9           = null;
                            if (rulePackDef == maneuver.combatLogRulesHit)
                            {
                                list8 = new List <BodyPartRecord>();
                                list9 = new List <bool>();
                                bodyPartCreator(list8, list9);
                            }
                            ImplementOwnerTypeDef implementOwnerTypeDef;
                            string toolLabel;
                            if (!(from ttp in DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef td) => td.IsMeleeWeapon && !td.tools.NullOrEmpty()).SelectMany((ThingDef td) => td.tools.Select((Tool tool) => new Pair <ThingDef, Tool>(td, tool)))
                                  where ttp.Second.capacities.Contains(maneuver.requiredCapacity)
                                  select ttp).TryRandomElement(out Pair <ThingDef, Tool> result))
                            {
                                Log.Warning("Melee weapon with tool with capacity " + maneuver.requiredCapacity + " not found.");
                                implementOwnerTypeDef = ImplementOwnerTypeDefOf.Bodypart;
                                toolLabel             = "(" + implementOwnerTypeDef.defName + ")";
                            }
                            else
                            {
                                implementOwnerTypeDef = ((result.Second == null) ? ImplementOwnerTypeDefOf.Bodypart : ImplementOwnerTypeDefOf.Weapon);
                                toolLabel             = ((result.Second != null) ? result.Second.label : ("(" + implementOwnerTypeDef.defName + ")"));
                            }
                            BattleLogEntry_MeleeCombat battleLogEntry_MeleeCombat = new BattleLogEntry_MeleeCombat(rulePackDef, alwaysShowInCompact: false, RandomPawnForCombat(), RandomPawnForCombat(), implementOwnerTypeDef, toolLabel, result.First);
                            battleLogEntry_MeleeCombat.FillTargets(list8, list9, battleLogEntry_MeleeCombat.RuleDef.defName.Contains("Deflect"));
                            battleLogEntry_MeleeCombat.Debug_OverrideTicks(Rand.Int);
                            stringBuilder7.AppendLine(battleLogEntry_MeleeCombat.ToGameStringFromPOV(null));
                        }
                        Log.Message(stringBuilder7.ToString());
                    });
                });
                list.Add(item);
            }
            int rf = 0;

            while (rf < 2)
            {
                list.Add(new DebugMenuOption((rf == 0) ? "Ranged fire singleshot" : "Ranged fire burst", DebugMenuOptionMode.Action, delegate
                {
                    StringBuilder stringBuilder6 = new StringBuilder();
                    for (int num2 = 0; num2 < 100; num2++)
                    {
                        ThingDef thingDef = DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef td) => td.IsRangedWeapon && td.IsWeaponUsingProjectiles && !td.menuHidden).RandomElement();
                        bool flag         = Rand.Value < 0.2f;
                        bool flag2        = !flag && Rand.Value < 0.95f;
                        BattleLogEntry_RangedFire battleLogEntry_RangedFire = new BattleLogEntry_RangedFire(RandomPawnForCombat(), flag ? null : RandomPawnForCombat(), flag2 ? null : thingDef, null, rf != 0);
                        battleLogEntry_RangedFire.Debug_OverrideTicks(Rand.Int);
                        stringBuilder6.AppendLine(battleLogEntry_RangedFire.ToGameStringFromPOV(null));
                    }
                    Log.Message(stringBuilder6.ToString());
                }));
                int num = ++rf;
            }
            list.Add(new DebugMenuOption("Ranged impact hit", DebugMenuOptionMode.Action, delegate
            {
                CreateDamagedDestroyedMenu(delegate(Action <List <BodyPartRecord>, List <bool> > bodyPartCreator)
                {
                    StringBuilder stringBuilder5 = new StringBuilder();
                    for (int n = 0; n < 100; n++)
                    {
                        ThingDef weaponDef3         = DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef td) => td.IsRangedWeapon && td.IsWeaponUsingProjectiles && !td.menuHidden).RandomElement();
                        List <BodyPartRecord> list6 = new List <BodyPartRecord>();
                        List <bool> list7           = new List <bool>();
                        bodyPartCreator(list6, list7);
                        Pawn pawn2 = RandomPawnForCombat();
                        BattleLogEntry_RangedImpact battleLogEntry_RangedImpact3 = new BattleLogEntry_RangedImpact(RandomPawnForCombat(), pawn2, pawn2, weaponDef3, null, ThingDefOf.Wall);
                        battleLogEntry_RangedImpact3.FillTargets(list6, list7, Rand.Chance(0.5f));
                        battleLogEntry_RangedImpact3.Debug_OverrideTicks(Rand.Int);
                        stringBuilder5.AppendLine(battleLogEntry_RangedImpact3.ToGameStringFromPOV(null));
                    }
                    Log.Message(stringBuilder5.ToString());
                });
            }));
            list.Add(new DebugMenuOption("Ranged impact miss", DebugMenuOptionMode.Action, delegate
            {
                StringBuilder stringBuilder4 = new StringBuilder();
                for (int l = 0; l < 100; l++)
                {
                    ThingDef weaponDef2 = DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef td) => td.IsRangedWeapon && td.IsWeaponUsingProjectiles && !td.menuHidden).RandomElement();
                    BattleLogEntry_RangedImpact battleLogEntry_RangedImpact2 = new BattleLogEntry_RangedImpact(RandomPawnForCombat(), null, RandomPawnForCombat(), weaponDef2, null, ThingDefOf.Wall);
                    battleLogEntry_RangedImpact2.Debug_OverrideTicks(Rand.Int);
                    stringBuilder4.AppendLine(battleLogEntry_RangedImpact2.ToGameStringFromPOV(null));
                }
                Log.Message(stringBuilder4.ToString());
            }));
            list.Add(new DebugMenuOption("Ranged impact hit incorrect", DebugMenuOptionMode.Action, delegate
            {
                CreateDamagedDestroyedMenu(delegate(Action <List <BodyPartRecord>, List <bool> > bodyPartCreator)
                {
                    StringBuilder stringBuilder3 = new StringBuilder();
                    for (int k = 0; k < 100; k++)
                    {
                        ThingDef weaponDef          = DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef td) => td.IsRangedWeapon && td.IsWeaponUsingProjectiles && !td.menuHidden).RandomElement();
                        List <BodyPartRecord> list4 = new List <BodyPartRecord>();
                        List <bool> list5           = new List <bool>();
                        bodyPartCreator(list4, list5);
                        BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(RandomPawnForCombat(), RandomPawnForCombat(), RandomPawnForCombat(), weaponDef, null, ThingDefOf.Wall);
                        battleLogEntry_RangedImpact.FillTargets(list4, list5, Rand.Chance(0.5f));
                        battleLogEntry_RangedImpact.Debug_OverrideTicks(Rand.Int);
                        stringBuilder3.AppendLine(battleLogEntry_RangedImpact.ToGameStringFromPOV(null));
                    }
                    Log.Message(stringBuilder3.ToString());
                });
            }));
            foreach (RulePackDef transition in DefDatabase <RulePackDef> .AllDefsListForReading.Where((RulePackDef def) => def.defName.Contains("Transition") && !def.defName.Contains("Include")))
            {
                list.Add(new DebugMenuOption(transition.defName, DebugMenuOptionMode.Action, delegate
                {
                    StringBuilder stringBuilder2 = new StringBuilder();
                    for (int j = 0; j < 100; j++)
                    {
                        Pawn pawn                 = RandomPawnForCombat();
                        Pawn initiator            = RandomPawnForCombat();
                        BodyPartRecord partRecord = pawn.health.hediffSet.GetNotMissingParts().RandomElement();
                        BattleLogEntry_StateTransition battleLogEntry_StateTransition = new BattleLogEntry_StateTransition(pawn, transition, initiator, HediffMaker.MakeHediff(DefDatabase <HediffDef> .AllDefsListForReading.RandomElement(), pawn, partRecord), pawn.RaceProps.body.AllParts.RandomElement());
                        battleLogEntry_StateTransition.Debug_OverrideTicks(Rand.Int);
                        stringBuilder2.AppendLine(battleLogEntry_StateTransition.ToGameStringFromPOV(null));
                    }
                    Log.Message(stringBuilder2.ToString());
                }));
            }
            foreach (RulePackDef damageEvent in DefDatabase <RulePackDef> .AllDefsListForReading.Where((RulePackDef def) => def.defName.Contains("DamageEvent") && !def.defName.Contains("Include")))
            {
                list.Add(new DebugMenuOption(damageEvent.defName, DebugMenuOptionMode.Action, delegate
                {
                    CreateDamagedDestroyedMenu(delegate(Action <List <BodyPartRecord>, List <bool> > bodyPartCreator)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        for (int i = 0; i < 100; i++)
                        {
                            List <BodyPartRecord> list2 = new List <BodyPartRecord>();
                            List <bool> list3           = new List <bool>();
                            bodyPartCreator(list2, list3);
                            BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(RandomPawnForCombat(), damageEvent);
                            battleLogEntry_DamageTaken.FillTargets(list2, list3, deflected: false);
                            battleLogEntry_DamageTaken.Debug_OverrideTicks(Rand.Int);
                            stringBuilder.AppendLine(battleLogEntry_DamageTaken.ToGameStringFromPOV(null));
                        }
                        Log.Message(stringBuilder.ToString());
                    });
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
Ejemplo n.º 18
0
 private static string <Biomes> m__23(ThingDef pd)
 {
     return(pd.defName);
 }
 public static IEnumerable <Rule> RulesForOptionalWeapon(string prefix, ThingDef weaponDef, ThingDef projectileDef)
 {
     if (weaponDef != null)
     {
         foreach (Rule rule in GrammarUtility.RulesForDef(prefix, weaponDef))
         {
             yield return(rule);
         }
         ThingDef projectile = projectileDef;
         if (projectile == null && !weaponDef.Verbs.NullOrEmpty <VerbProperties>())
         {
             projectile = weaponDef.Verbs[0].defaultProjectile;
         }
         if (projectile != null)
         {
             foreach (Rule rule2 in GrammarUtility.RulesForDef(prefix + "_projectile", projectile))
             {
                 yield return(rule2);
             }
         }
     }
     yield break;
 }
Ejemplo n.º 20
0
 public DamageInfo(DamageDef def, float amount, float armorPenetration = 0f, float angle = -1f, Thing instigator = null, BodyPartRecord hitPart = null, ThingDef weapon = null, SourceCategory category = SourceCategory.ThingOrUnknown, Thing intendedTarget = null)
 {
     defInt              = def;
     amountInt           = amount;
     armorPenetrationInt = armorPenetration;
     if (angle < 0f)
     {
         angleInt = (float)Rand.RangeInclusive(0, 359);
     }
     else
     {
         angleInt = angle;
     }
     instigatorInt             = instigator;
     categoryInt               = category;
     hitPartInt                = hitPart;
     heightInt                 = BodyPartHeight.Undefined;
     depthInt                  = BodyPartDepth.Undefined;
     weaponInt                 = weapon;
     weaponBodyPartGroupInt    = null;
     weaponHediffInt           = null;
     instantPermanentInjuryInt = false;
     allowDamagePropagationInt = true;
     intendedTargetInt         = intendedTarget;
 }
Ejemplo n.º 21
0
        public int MaxStackSpaceEver(ThingDef td)
        {
            int b = Mathf.RoundToInt(pawn.GetStatValue(StatDefOf.CarryingCapacity) / td.VolumePerUnit);

            return(Mathf.Min(td.stackLimit, b));
        }
Ejemplo n.º 22
0
 private static float RaceMeleeDpsEstimate(ThingDef race)
 {
     return(race.GetStatValueAbstract(StatDefOf.MeleeDPS, null));
 }
Ejemplo n.º 23
0
        public static IntVec3 InteractionCellWhenAt(ThingDef def, IntVec3 center, Rot4 rot, Map map)
        {
            if (def.hasInteractionCell)
            {
                IntVec3 b = def.interactionCellOffset.RotatedBy(rot);
                return(center + b);
            }
            IntVec2 size = def.Size;

            if (size.x == 1)
            {
                IntVec2 size2 = def.Size;
                if (size2.z == 1)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 intVec = center + GenAdj.AdjacentCells[i];
                        if (intVec.Standable(map) && intVec.GetDoor(map) == null && ReachabilityImmediate.CanReachImmediate(intVec, center, map, PathEndMode.Touch, null))
                        {
                            return(intVec);
                        }
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        IntVec3 intVec2 = center + GenAdj.AdjacentCells[j];
                        if (intVec2.Standable(map) && ReachabilityImmediate.CanReachImmediate(intVec2, center, map, PathEndMode.Touch, null))
                        {
                            return(intVec2);
                        }
                    }
                    for (int k = 0; k < 8; k++)
                    {
                        IntVec3 intVec3 = center + GenAdj.AdjacentCells[k];
                        if (intVec3.Walkable(map) && ReachabilityImmediate.CanReachImmediate(intVec3, center, map, PathEndMode.Touch, null))
                        {
                            return(intVec3);
                        }
                    }
                    return(center);
                }
            }
            List <IntVec3> list = GenAdjFast.AdjacentCells8Way(center, rot, def.size);
            CellRect       rect = GenAdj.OccupiedRect(center, rot, def.size);

            for (int l = 0; l < list.Count; l++)
            {
                if (list[l].Standable(map) && list[l].GetDoor(map) == null && ReachabilityImmediate.CanReachImmediate(list[l], rect, map, PathEndMode.Touch, null))
                {
                    return(list[l]);
                }
            }
            for (int m = 0; m < list.Count; m++)
            {
                if (list[m].Standable(map) && ReachabilityImmediate.CanReachImmediate(list[m], rect, map, PathEndMode.Touch, null))
                {
                    return(list[m]);
                }
            }
            for (int n = 0; n < list.Count; n++)
            {
                if (list[n].Walkable(map) && ReachabilityImmediate.CanReachImmediate(list[n], rect, map, PathEndMode.Touch, null))
                {
                    return(list[n]);
                }
            }
            return(center);
        }
Ejemplo n.º 24
0
 public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation)
 {
     this.DrawMoteInternal(loc, rot, thingDef, thing, 0);
 }
Ejemplo n.º 25
0
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient)
        {
            float efficiency = (float)((recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat, true) : 1.0);

            if (recipeDef.products != null)
            {
                int k = 0;
                if (k < recipeDef.products.Count)
                {
                    ThingCountClass prod     = recipeDef.products[k];
                    ThingDef        stuffDef = (!prod.thingDef.MadeFromStuff) ? null : dominantIngredient.def;
                    Thing           product3 = ThingMaker.MakeThing(prod.thingDef, stuffDef);
                    product3.stackCount = Mathf.CeilToInt((float)prod.count * efficiency);
                    if (dominantIngredient != null)
                    {
                        product3.SetColor(dominantIngredient.DrawColor, false);
                    }
                    CompIngredients ingredientsComp = product3.TryGetComp <CompIngredients>();
                    if (ingredientsComp != null)
                    {
                        for (int l = 0; l < ingredients.Count; l++)
                        {
                            ingredientsComp.RegisterIngredient(ingredients[l].def);
                        }
                    }
                    CompFoodPoisonable foodPoisonable = product3.TryGetComp <CompFoodPoisonable>();
                    if (foodPoisonable != null)
                    {
                        float num  = worker.GetStatValue(StatDefOf.FoodPoisonChance, true);
                        Room  room = worker.GetRoom(RegionType.Set_Passable);
                        if (room != null)
                        {
                            num *= room.GetStat(RoomStatDefOf.FoodPoisonChanceFactor);
                        }
                        if (Rand.Value < num)
                        {
                            foodPoisonable.PoisonPercent = 1f;
                        }
                    }
                    yield return(GenRecipe.PostProcessProduct(product3, recipeDef, worker));

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (recipeDef.specialProducts != null)
            {
                for (int j = 0; j < recipeDef.specialProducts.Count; j++)
                {
                    for (int i = 0; i < ingredients.Count; i++)
                    {
                        Thing ing = ingredients[i];
                        switch (recipeDef.specialProducts[j])
                        {
                        case SpecialProductType.Butchery:
                            using (IEnumerator <Thing> enumerator2 = ing.ButcherProducts(worker, efficiency).GetEnumerator())
                            {
                                if (enumerator2.MoveNext())
                                {
                                    Thing product = enumerator2.Current;
                                    yield return(GenRecipe.PostProcessProduct(product, recipeDef, worker));

                                    /*Error: Unable to find new state assignment for yield return*/;
                                }
                            }
                            break;

                        case SpecialProductType.Smelted:
                            using (IEnumerator <Thing> enumerator = ing.SmeltProducts(efficiency).GetEnumerator())
                            {
                                if (enumerator.MoveNext())
                                {
                                    Thing product2 = enumerator.Current;
                                    yield return(GenRecipe.PostProcessProduct(product2, recipeDef, worker));

                                    /*Error: Unable to find new state assignment for yield return*/;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            yield break;
IL_0473:
            /*Error near IL_0474: Unexpected return in MoveNext()*/;
        }
Ejemplo n.º 26
0
 public BattleLogEntry_ExplosionImpact(Thing initiator, Thing recipient, ThingDef weaponDef, ThingDef projectileDef, DamageDef damageDef) : base(null)
 {
     if (initiator is Pawn)
     {
         this.initiatorPawn = (initiator as Pawn);
     }
     else if (initiator != null)
     {
         this.initiatorThing = initiator.def;
     }
     if (recipient is Pawn)
     {
         this.recipientPawn = (recipient as Pawn);
     }
     else if (recipient != null)
     {
         this.recipientThing = recipient.def;
     }
     this.weaponDef     = weaponDef;
     this.projectileDef = projectileDef;
     this.damageDef     = damageDef;
 }
Ejemplo n.º 27
0
        private static void DoTablesInternalMelee(ThingDef stuff, bool doRaces = false)
        {
            Func <Def, float> meleeDamageGetter = delegate(Def d)
            {
                List <Verb> concreteExampleVerbs = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                if (concreteExampleVerbs.OfType <Verb_MeleeAttack>().Any <Verb_MeleeAttack>())
                {
                    return(concreteExampleVerbs.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>           concreteExampleVerbs  = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                Verb_LaunchProjectile verb_LaunchProjectile = concreteExampleVerbs.OfType <Verb_LaunchProjectile>().FirstOrDefault <Verb_LaunchProjectile>();
                if (verb_LaunchProjectile != null && verb_LaunchProjectile.GetProjectile() != null)
                {
                    return((float)verb_LaunchProjectile.GetProjectile().projectile.GetDamageAmount(null, null));
                }
                return(-1f);
            };
            Func <Def, float> rangedWarmupGetter = delegate(Def d)
            {
                List <Verb>           concreteExampleVerbs  = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                Verb_LaunchProjectile verb_LaunchProjectile = concreteExampleVerbs.OfType <Verb_LaunchProjectile>().FirstOrDefault <Verb_LaunchProjectile>();
                if (verb_LaunchProjectile != null)
                {
                    return(verb_LaunchProjectile.verbProps.warmupTime);
                }
                return(-1f);
            };
            Func <Def, float> meleeCooldownGetter = delegate(Def d)
            {
                List <Verb> concreteExampleVerbs = VerbUtility.GetConcreteExampleVerbs(d, stuff);
                if (concreteExampleVerbs.OfType <Verb_MeleeAttack>().Any <Verb_MeleeAttack>())
                {
                    return(concreteExampleVerbs.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);
                Verb_LaunchProjectile verb_LaunchProjectile = concreteExampleVerbs.OfType <Verb_LaunchProjectile>().FirstOrDefault <Verb_LaunchProjectile>();
                if (verb_LaunchProjectile != null)
                {
                    return(verb_LaunchProjectile.verbProps.defaultCooldownTime);
                }
                return(-1f);
            };
            Func <Def, float> meleeDpsGetter    = (Def d) => meleeDamageGetter(d) * 0.82f / meleeCooldownGetter(d);
            Func <Def, float> marketValueGetter = delegate(Def d)
            {
                ThingDef thingDef = d as ThingDef;
                if (thingDef != null)
                {
                    return(thingDef.GetStatValueAbstract(StatDefOf.MarketValue, stuff));
                }
                HediffDef hediffDef = d as HediffDef;
                if (hediffDef == null)
                {
                    return(-1f);
                }
                if (hediffDef.spawnThingOnRemoved == null)
                {
                    return(0f);
                }
                return(hediffDef.spawnThingOnRemoved.GetStatValueAbstract(StatDefOf.MarketValue, null));
            };
            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;

            IEnumerable <Def> arg_299_0 = enumerable;

            TableDataGetter <Def>[] expr_13D = new TableDataGetter <Def> [11];
            expr_13D[0] = new TableDataGetter <Def>("defName", (Def d) => d.defName);
            expr_13D[1] = new TableDataGetter <Def>("melee\ndamage\naverage", (Def d) => meleeDamageGetter(d).ToString("F2"));
            expr_13D[2] = new TableDataGetter <Def>("melee\ncooldown\naverage", (Def d) => meleeCooldownGetter(d).ToString("F2"));
            expr_13D[3] = new TableDataGetter <Def>("melee\nDPS", (Def d) => meleeDpsGetter(d).ToString("F2"));
            expr_13D[4] = new TableDataGetter <Def>("ranged\ndamage", (Def d) => rangedDamageGetter(d).ToString());
            expr_13D[5] = new TableDataGetter <Def>("ranged\nwarmup", (Def d) => rangedWarmupGetter(d).ToString("F2"));
            expr_13D[6] = new TableDataGetter <Def>("ranged\ncooldown", (Def d) => rangedCooldownGetter(d).ToString("F2"));
            expr_13D[7] = new TableDataGetter <Def>("market value", (Def d) => marketValueGetter(d).ToStringMoney(null));
            expr_13D[8] = new TableDataGetter <Def>("work to make", delegate(Def d)
            {
                ThingDef thingDef = d as ThingDef;
                if (thingDef == null)
                {
                    return("-");
                }
                return(thingDef.GetStatValueAbstract(StatDefOf.WorkToMake, stuff).ToString("F0"));
            });
            expr_13D[9] = 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());
            });
            expr_13D[10] = new TableDataGetter <Def>("assumed\nmelee\nhit chance", (Def d) => 0.82f.ToStringPercent());
            DebugTables.MakeTablesDialog <Def>(arg_299_0, expr_13D);
        }
Ejemplo n.º 28
0
 public virtual void DrawGhost(IntVec3 center, Rot4 rot, ThingDef thingDef, Color ghostCol, AltitudeLayer drawAltitude)
 {
 }
Ejemplo n.º 29
0
 private static IEnumerable <IngestionOutcomeDoer_GiveHediff> GetValidNarcoDoers(Verse.ThingDef def)
 {
     return(def.ingestible?.outcomeDoers?.OfType <IngestionOutcomeDoer_GiveHediff>().Where(d => d.hediffDef?.stages != null));
 }
Ejemplo n.º 30
0
 private static string <PlantsBasics> m__4(ThingDef d)
 {
     return((d.ingestible == null) ? "-" : d.GetStatValueAbstract(StatDefOf.Nutrition, null).ToString("F2"));
 }