// RimWorld.Pawn_ApparelTracker
        public static bool InterfaceDrop_PreFix(ITab_Pawn_Gear __instance, Thing t)
        {
            ThingWithComps thingWithComps = t as ThingWithComps;
            Apparel        apparel        = t as Apparel;
            Pawn           __pawn         = (Pawn)AccessTools.Method(typeof(ITab_Pawn_Gear), "get_SelPawnForGear").Invoke(__instance, new object[0]);

            if (__pawn != null)
            {
                if (apparel != null)
                {
                    if (__pawn.apparel != null)
                    {
                        if (__pawn.apparel.WornApparel.Contains(apparel))
                        {
                            if (__pawn.apparel.WornApparel != null)
                            {
                                CompInstalledPart installedPart = apparel.GetComp <CompInstalledPart>();
                                if (installedPart != null)
                                {
                                    if (!installedPart.uninstalled)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
            public static void Postfix(Pawn __instance, DamageInfo dinfo, float totalDamageDealt)
            {
                if (__instance == null)
                {
                    return;
                }

                if (__instance.apparel != null)
                {
                    for (int i = 0; i < __instance.apparel.WornApparel.Count; ++i)
                    {
                        Apparel apparel = __instance.apparel.WornApparel[i];
                        CompIncreaseUserHediffSeverityWhenHurt comp = apparel.GetComp <CompIncreaseUserHediffSeverityWhenHurt>();

                        if (comp != null)
                        {
                            comp.PostPostApplyDamage(dinfo, totalDamageDealt);
                        }
                    }
                }

                if (__instance.equipment != null)
                {
                    for (int i = 0; i < __instance.equipment.AllEquipmentListForReading.Count; ++i)
                    {
                        ThingWithComps equipped = __instance.equipment.AllEquipmentListForReading[i];
                        CompIncreaseUserHediffSeverityWhenHurt comp = equipped.GetComp <CompIncreaseUserHediffSeverityWhenHurt>();

                        if (comp != null)
                        {
                            comp.PostPostApplyDamage(dinfo, totalDamageDealt);
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        private static bool RaceRestricted(Pawn pawn, Apparel app)
        {
            bool flag = app.GetComp <CompRestritctedRace>() != null;
            bool result;

            if (flag)
            {
                CompRestritctedRace comp = app.GetComp <CompRestritctedRace>();
                bool flag2 = comp.Props.RestrictedToRace != null;
                if (flag2)
                {
                    bool flag3 = pawn.kindDef.race.ToString() == comp.Props.RestrictedToRace;
                    if (flag3)
                    {
                        result = false;
                    }
                    else
                    {
                        bool flag4 = pawn.GetType() == typeof(AlienPawn);
                        if (flag4)
                        {
                            AlienPawn alienPawn = pawn as AlienPawn;
                            bool      flag5     = alienPawn.kindDef.race.ToString() == comp.Props.RestrictedToRace;
                            result = !flag5;
                        }
                        else
                        {
                            result = true;
                        }
                    }
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 4
0
        private static bool RaceRestricted(Pawn pawn, Apparel app)
        {
            if (app.GetComp <CompRestritctedRace>() != null)
            {
                CompRestritctedRace rcomp = app.GetComp <CompRestritctedRace>();

                if (rcomp.Props.RestrictedToRace != null)
                {
                    //   Log.Message(pawn.kindDef.race.defName.ToString());
                    //   Log.Message(rcomp.Props.RestrictedToRace);
                    if (pawn.kindDef.race.ToString() == rcomp.Props.RestrictedToRace)
                    {
                        return(false);
                    }
                    else if (pawn.GetType() == typeof(AlienRace.AlienPawn))
                    {
                        AlienPawn alpawn = pawn as AlienPawn;

                        //          Log.Message("Alpawn :"+ alpawn.kindDef.race.defName.ToString());
                        if (alpawn.kindDef.race.ToString() == rcomp.Props.RestrictedToRace)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public override void CompTickRare()
        {
            if (this.hediff != null)
            {
                Apparel artifact = this.parent as Apparel;
                if (artifact != null)
                {
                    if (artifact.Wearer != null)
                    {
                        //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort);
                        if (artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false) != null)
                        {
                        }
                        else
                        {
                            HealthUtility.AdjustSeverity(artifact.Wearer, hediff, hediffSeverity);
                            artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false).TryGetComp <HediffComp_EnchantedItem>().enchantedItem = artifact;
                            //HediffComp_EnchantedItem comp = diff.TryGetComp<HediffComp_EnchantedItem>();
                        }
                    }
                }
            }
            if (this.Props.hasAbility && !this.abilitiesInitialized)
            {
                Apparel artifact = this.parent as Apparel;
                if (artifact != null)
                {
                    if (artifact.Wearer != null)
                    {
                        //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort);
                        this.InitializeAbilities(artifact);
                    }

                    this.MagicAbilities = artifact.GetComp <CompAbilityItem>().Props.Abilities;
                    //this.MagicAbilities = new List<AbilityDef>();
                    //this.MagicAbilities.Clear();
                    // abilities;
                }
            }
            base.CompTickRare();
        }
Ejemplo n.º 6
0
        protected override bool TryCastShot()
        {
            bool result = false;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                if (this.currentTarget.Thing != null && this.currentTarget.Thing is Pawn)
                {
                    Pawn victim = this.currentTarget.Thing as Pawn;
                    if (victim.Faction != null && victim.RaceProps.Humanlike && victim.story != null && victim.story.traits != null && !TM_Calc.IsUndeadNotVamp(victim))
                    {
                        int            traitsApplied = 0;
                        List <Apparel> apparel       = this.CasterPawn.apparel.WornApparel;
                        List <Trait>   orbTraits     = new List <Trait>();
                        orbTraits.Clear();
                        CompEnchantedItem itemComp = null;
                        if (apparel != null)
                        {
                            for (int i = 0; i < apparel.Count; i++)
                            {
                                Apparel item = apparel[i];
                                if (item != null && item.def == TorannMagicDefOf.TM_Artifact_OrbOfSouls_Full)
                                {
                                    itemComp = item.GetComp <CompEnchantedItem>();
                                    if (itemComp != null)
                                    {
                                        orbTraits = itemComp.SoulOrbTraits;
                                    }
                                }
                            }
                        }
                        if (orbTraits.Count > 0)
                        {
                            for (int i = 0; i < orbTraits.Count; i++)
                            {
                                bool conflicting = false;
                                for (int j = 0; j < victim.story.traits.allTraits.Count; j++)
                                {
                                    if (victim.story.traits.allTraits[j].def.ConflictsWith(orbTraits[i]))
                                    {
                                        conflicting = true;
                                    }
                                }

                                if (!conflicting)
                                {
                                    AddTrait(victim, orbTraits[i]);
                                    traitsApplied++;
                                }
                            }

                            if (traitsApplied > 0)
                            {
                                Effects(victim.Position);
                                result = true;
                            }
                            else
                            {
                                Messages.Message("TM_NoTraitsApplied".Translate(victim), MessageTypeDefOf.RejectInput);
                                result = false;
                            }
                        }
                        else
                        {
                            Log.Message("no traits found in orb - was this dev-mode generated?");
                            result = true; //destroy anyways
                        }
                    }
                    else
                    {
                        //invalid target
                        Messages.Message("TM_InvalidTarget".Translate(
                                             this.CasterPawn.LabelShort,
                                             this.verbProps.label
                                             ), MessageTypeDefOf.RejectInput);
                    }
                }
                else
                {
                    //invalid target
                    Messages.Message("TM_InvalidTarget".Translate(
                                         this.CasterPawn.LabelShort,
                                         this.verbProps.label
                                         ), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            PostCastShot(result);
            return(false);
        }
Ejemplo n.º 7
0
        public override void CompTickRare()
        {
            if (this.hediff != null)
            {
                Apparel artifact = this.parent as Apparel;
                if (artifact != null)
                {
                    if (artifact.Wearer != null)
                    {
                        //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort);
                        if (artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false) != null)
                        {
                        }
                        else
                        {
                            HealthUtility.AdjustSeverity(artifact.Wearer, hediff, hediffSeverity);
                            HediffComp_EnchantedItem hdc = artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false).TryGetComp <HediffComp_EnchantedItem>();
                            if (hdc != null)
                            {
                                hdc.enchantedItem = artifact;
                            }
                            //HediffComp_EnchantedItem comp = diff.TryGetComp<HediffComp_EnchantedItem>();
                        }
                    }
                }
            }
            if (this.Props.hasAbility && !this.abilitiesInitialized)
            {
                Apparel artifact = this.parent as Apparel;
                if (artifact != null)
                {
                    if (artifact.Wearer != null)
                    {
                        //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort);
                        this.InitializeAbilities(artifact);
                    }

                    this.MagicAbilities = artifact.GetComp <CompAbilityItem>().Props.Abilities;
                    //this.MagicAbilities = new List<AbilityDef>();
                    //this.MagicAbilities.Clear();
                    // abilities;
                }
            }
            if (GetEnchantedStuff_HediffDef != null)
            {
                if (WearingPawn != null)
                {
                    hediffStuff.Clear();
                    List <Apparel> wornApparel = WearingPawn.apparel.WornApparel;
                    for (int i = 0; i < wornApparel.Count; i++)
                    {
                        CompEnchantedItem itemComp = wornApparel[i].TryGetComp <CompEnchantedItem>();
                        if (itemComp != null && itemComp.GetEnchantedStuff_HediffDef != null)
                        {
                            int hdCount = GetStuffCount_Hediff(itemComp.EnchantedStuff.appliedHediff);
                            if (hdCount >= itemComp.EnchantedStuff.applyHediffAtCount)
                            {
                                if (WearingPawn.health.hediffSet.HasHediff(itemComp.EnchantedStuff.appliedHediff))
                                {
                                    Hediff hd = WearingPawn.health.hediffSet.GetFirstHediffOfDef(itemComp.EnchantedStuff.appliedHediff);
                                    if (hd.Severity < (hdCount * itemComp.EnchantedStuff.severityPerCount))
                                    {
                                        WearingPawn.health.RemoveHediff(hd);
                                        HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount);
                                    }
                                }
                                else
                                {
                                    HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount);
                                }
                            }
                        }
                    }
                    if (WearingPawn.equipment != null && WearingPawn.equipment.Primary != null && !EnchantedStuff.apparelOnly)
                    {
                        ThingWithComps    eq       = WearingPawn.equipment.Primary;
                        CompEnchantedItem itemComp = eq.TryGetComp <CompEnchantedItem>();
                        if (itemComp != null && itemComp.GetEnchantedStuff_HediffDef != null)
                        {
                            int hdCount = GetStuffCount_Hediff(itemComp.EnchantedStuff.appliedHediff);
                            if (hdCount >= itemComp.EnchantedStuff.applyHediffAtCount)
                            {
                                if (WearingPawn.health.hediffSet.HasHediff(itemComp.EnchantedStuff.appliedHediff))
                                {
                                    Hediff hd = WearingPawn.health.hediffSet.GetFirstHediffOfDef(itemComp.EnchantedStuff.appliedHediff);
                                    if (hd.Severity < (hdCount * itemComp.EnchantedStuff.severityPerCount))
                                    {
                                        WearingPawn.health.RemoveHediff(hd);
                                        HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount);
                                    }
                                }
                                else
                                {
                                    HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount);
                                }
                            }
                        }
                    }
                }
            }
            base.CompTickRare();
        }