public static void ApparelGizmosFromComps(Cloakgen __instance, ref IEnumerable <Gizmo> __result)
        {
            if (__instance == null)
            {
                Log.Warning("ApparelGizmosFromComps cannot access Apparel.");
                return;
            }
            if (__result == null)
            {
                Log.Warning("ApparelGizmosFromComps creating new list.");
                return;
            }

            // Find all comps on the apparel. If any have gizmos, add them to the result returned from apparel already (typically empty set).
            List <Gizmo> l2 = new List <Gizmo>(__result);

            foreach (CompWearable comp in __instance.GetComps <CompWearable>())
            {
                foreach (Gizmo gizmo in comp.CompGetGizmosWorn())
                {
                    l2.Add(gizmo);
                }
            }
            __result = l2;
        }
        // Token: 0x06002ADD RID: 10973 RVA: 0x00143464 File Offset: 0x00141864
        public override bool CanBeUsedBy(Pawn p, out string failReason)
        {
            bool selected = Find.Selector.SelectedObjects.Contains(p);
            bool flag     = GenCollection.Any <Apparel>(p.apparel.WornApparel, (Apparel x) => x.def == YautjaDefOf.RRY_Equipment_HunterGauntlet);

            if (flag)
            {
                Cloakgen injector = (Cloakgen)p.apparel.WornApparel.Find((Apparel x) => x.def == YautjaDefOf.RRY_Equipment_HunterGauntlet);
                if (injector != null)
                {
                    CompMedicalInjector medicalInjector = injector.TryGetComp <CompMedicalInjector>();
                    if (injector.uses < medicalInjector.Props.Uses)
                    {
                        failReason = null;
                        return(true);
                    }
                    else
                    {
                        failReason = "Injector full";
                        return(false);
                    }
                }
                else
                {
                    failReason = "Not wearing Injector";
                    return(false);
                }
            }
            else
            {
                failReason = "Not wearing Injector";
                return(false);
            }
            return(base.CanBeUsedBy(p, out failReason));
        }
Beispiel #3
0
        // Token: 0x06000026 RID: 38 RVA: 0x000026A3 File Offset: 0x000008A3
        protected override IEnumerable <Toil> MakeNewToils()
        {
            base.AddEndCondition(delegate()
            {
                if (this.pawn.Faction == Faction.OfPlayer && HealthAIUtility.ShouldBeTendedNowByPlayer(this.pawn))
                {
                    return(JobCondition.Ongoing);
                }
                if (this.pawn.Faction != Faction.OfPlayer && this.pawn.health.HasHediffsNeedingTend(false))
                {
                    return(JobCondition.Ongoing);
                }
                return(JobCondition.Succeeded);
            });
            int ticks = (int)(1f / StatExtension.GetStatValue(this.pawn, StatDefOf.MedicalTendSpeed, true) * 600f);

            yield return(ToilEffects.PlaySustainerOrSound(ToilEffects.WithProgressBarToilDelay(Toils_General.Wait(ticks, 0), (TargetIndex)1, false, -0.5f), SoundDefOf.Interact_Tend));

            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Pawn     actor  = toil.actor;
                Cloakgen medkit = actor.apparel.WornApparel.OfType <Cloakgen>().FirstOrDefault <Cloakgen>();
                float    num    = (!actor.RaceProps.Animal) ? 500f : 175f;
                float    num2   = (medkit != null) ? medkit.kitComp.Props.medicine.MedicineTendXpGainFactor : 0.5f;
                actor.skills.Learn(SkillDefOf.Medicine, num * num2, false);
                HealthShardTendUtility.DoTend(actor, actor, medkit);
            };
            toil.defaultCompleteMode = (ToilCompleteMode)1;
            yield return(toil);

            yield break;
        }
Beispiel #4
0
 public static void ThoughtsFromIngestingPostPrefix(Pawn pawn, ref bool __result)
 {
     if (pawn == null)
     {
         return;
     }
     if (pawn.CarriedBy != null)
     {
         __result = pawn.CarriedBy.IsInvisible();
         return;
     }
     if (pawn.isXenomorph(out Comp_Xenomorph xenomorph))
     {
         if (pawn.Dead || pawn.Downed || pawn.def == XenomorphRacesDefOf.RRY_Xenomorph_Queen || pawn.def == XenomorphRacesDefOf.RRY_Xenomorph_Thrumbomorph)
         {
             __result = false;
             return;
         }
         if (xenomorph != null)
         {
             if (xenomorph.hidden)
             {
                 //    Log.Message("xenomorph.hidden");
                 __result = true;
                 return;
             }
             if (xenomorph.spotted || !xenomorph.CanHide)
             {
                 //    Log.Message("xenomorph.spotted || !xenomorph.CanHide");
                 __result = false;
                 return;
             }
         }
     }
     else
     {
         if (pawn.RaceProps.Humanlike)
         {
             if (pawn.apparel.WornApparel.Any(x => x.GetType() == typeof(Cloakgen)))
             {
                 Cloakgen cloak = (Cloakgen)pawn.apparel.WornApparel.First(x => x.GetType() == typeof(Cloakgen));
                 if (cloak != null)
                 {
                     __result = __result || cloak.cloakMode == Cloakgen.CloakMode.On;
                 }
             }
         }
     }
 }
Beispiel #5
0
        // Token: 0x0600002F RID: 47 RVA: 0x00002870 File Offset: 0x00000A70
        public static void UseShard(Pawn doctor, Pawn patient, Cloakgen medkit)
        {
            bool flag = patient.health.HasHediffsNeedingTend(false);

            Log.Message(string.Format("UseShard flag: {0}, doctor: {1}, patient: {2}", flag, doctor, patient));
            if (flag)
            {
                Hediff hediff = HealthShardTendUtility.FindLifeThreateningHediff(patient);
                if (hediff != null)
                {
                    Log.Message(string.Format("hediff: {0}", hediff));
                    medkit.UseKit();
                    HealthShardTendUtility.Cure(hediff);
                    return;
                }
                if (HealthUtility.TicksUntilDeathDueToBloodLoss(patient) < 2500)
                {
                    Log.Message(string.Format("TicksUntilDeathDueToBloodLoss: {0}", HealthUtility.TicksUntilDeathDueToBloodLoss(patient)));
                    Hediff hediff2 = HealthShardTendUtility.FindMostBleedingHediff(patient);
                    if (hediff2 != null)
                    {
                        Log.Message(string.Format("hediff2: {0}", hediff2));
                        medkit.UseKit();
                        HealthShardTendUtility.Cure(hediff2);
                        return;
                    }
                }
                Hediff_Injury hediff_Injury3 = HealthShardTendUtility.FindInjury(patient, null);
                if (hediff_Injury3 != null)
                {
                    Log.Message(string.Format("hediff2: {0}", hediff_Injury3));
                    medkit.UseKit();
                    HealthShardTendUtility.Cure(hediff_Injury3);
                    return;
                }
            }
        }
        // Token: 0x06002ADC RID: 10972 RVA: 0x001433C0 File Offset: 0x001417C0
        public override void DoEffect(Pawn user)
        {
            Cloakgen            injector        = (Cloakgen)user.apparel.WornApparel.Find((Apparel x) => x.def == YautjaDefOf.RRY_Equipment_HunterGauntlet);
            CompMedicalInjector medicalInjector = injector.TryGetComp <CompMedicalInjector>();
            bool selected = Find.Selector.SelectedObjects.Contains(user);
            int  needed   = medicalInjector.Props.Uses - injector.uses;

            if (needed > 0)
            {
                if (this.parent.stackCount >= needed)
                {
                    injector.uses          = medicalInjector.Props.Uses;
                    this.parent.stackCount = this.parent.stackCount - needed;
                }
                else if (this.parent.stackCount < needed)
                {
                    injector.uses          = this.parent.stackCount;
                    this.parent.stackCount = 0;
                    this.parent.Destroy();
                }
            }

            //    base.DoEffect(user);
        }
Beispiel #7
0
        // Token: 0x0600002F RID: 47 RVA: 0x00002870 File Offset: 0x00000A70
        public static void DoTend(Pawn doctor, Pawn patient, Cloakgen medkit)
        {
            bool flag = patient.health.HasHediffsNeedingTend(false);

            if (flag)
            {
                bool flag2 = medkit != null && medkit.Destroyed;
                if (flag2)
                {
                    Log.Warning("Tried to use destroyed medkit.", false);
                    medkit = null;
                }
                float num = HealthShardTendUtility.CalculateBaseTendQuality(doctor, patient, medkit.kitComp.Props.medicine ?? null);
                HealthShardTendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medkit.kitComp.Props.medicine != null, HealthShardTendUtility.tmpHediffsToTend, null);
                for (int i = 0; i < HealthShardTendUtility.tmpHediffsToTend.Count; i++)
                {
                    HealthShardTendUtility.tmpHediffsToTend[i].Tended(num, i);
                }
                bool flag3 = doctor != null && doctor.Faction == Faction.OfPlayer && patient.Faction != doctor.Faction && !patient.IsPrisoner && patient.Faction != null;
                if (flag3)
                {
                    patient.mindState.timesGuestTendedToByPlayer++;
                }
                bool flag4 = doctor != null && doctor.IsColonistPlayerControlled;
                if (flag4)
                {
                    patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer);
                }
                bool flag5 = doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal;
                if (flag5)
                {
                    bool flag6 = RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f);
                    if (flag6)
                    {
                        bool flag7 = doctor.Faction != null && doctor.Faction != patient.Faction;
                        if (flag7)
                        {
                            InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
                        }
                    }
                }
                patient.records.Increment(RecordDefOf.TimesTendedTo);
                bool flag8 = doctor != null;
                if (flag8)
                {
                    doctor.records.Increment(RecordDefOf.TimesTendedOther);
                }
                bool flag9 = doctor == patient && !doctor.Dead;
                if (flag9)
                {
                    doctor.mindState.Notify_SelfTended();
                }
                bool flag10 = medkit.kitComp.Props.medicine != null;
                if (flag10)
                {
                    bool flag11 = patient.Spawned || (doctor != null && doctor.Spawned);
                    if (flag11)
                    {
                        bool flag12 = medkit.kitComp.Props.medicine != null && StatExtension.GetStatValueAbstract(medkit.kitComp.Props.medicine, StatDefOf.MedicalPotency, null) > StatExtension.GetStatValueAbstract(ThingDefOf.MedicineIndustrial, StatDefOf.MedicalPotency, null);
                        if (flag12)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.TechMedicineUsed, new TargetInfo(patient.Position, patient.Map, false));
                        }
                    }
                }
            }
        }