public static T TryGetComp <T>(this Hediff hd) where T : HediffComp { HediffWithComps hediffWithComps = hd as HediffWithComps; T result; if (hediffWithComps == null) { result = (T)((object)null); } else { if (hediffWithComps.comps != null) { for (int i = 0; i < hediffWithComps.comps.Count; i++) { T t = hediffWithComps.comps[i] as T; if (t != null) { return(t); } } } result = (T)((object)null); } return(result); }
public static bool FullyImmune(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } return(hediffWithComps.TryGetComp <HediffComp_Immunizable>()?.FullyImmune ?? false); }
public static bool IsPermanent(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } return(hediffWithComps.TryGetComp <HediffComp_GetsPermanent>()?.IsPermanent ?? false); }
public static bool IsTended(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } return(hediffWithComps.TryGetComp <HediffComp_TendDuration>()?.IsTended ?? false); }
public static bool FullyImmune(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } HediffComp_Immunizable hediffComp_Immunizable = hediffWithComps.TryGetComp <HediffComp_Immunizable>(); return(hediffComp_Immunizable != null && hediffComp_Immunizable.FullyImmune); }
public static bool IsPermanent(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } HediffComp_GetsPermanent hediffComp_GetsPermanent = hediffWithComps.TryGetComp <HediffComp_GetsPermanent>(); return(hediffComp_GetsPermanent != null && hediffComp_GetsPermanent.IsPermanent); }
public static bool IsTended(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } HediffComp_TendDuration hediffComp_TendDuration = hediffWithComps.TryGetComp <HediffComp_TendDuration>(); return(hediffComp_TendDuration != null && hediffComp_TendDuration.IsTended); }
public static bool IsOld(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(false); } HediffComp_GetsOld hediffComp_GetsOld = hediffWithComps.TryGetComp <HediffComp_GetsOld>(); return(hediffComp_GetsOld != null && hediffComp_GetsOld.IsOld); }
public IEnumerable <HediffComp> GetAllComps() { foreach (Hediff hediff in hediffs) { HediffWithComps hediffWithComps = hediff as HediffWithComps; if (hediffWithComps != null) { foreach (HediffComp comp in hediffWithComps.comps) { yield return(comp); } } } }
public static bool FullyImmune(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; bool result; if (hediffWithComps == null) { result = false; } else { HediffComp_Immunizable hediffComp_Immunizable = hediffWithComps.TryGetComp <HediffComp_Immunizable>(); result = (hediffComp_Immunizable != null && hediffComp_Immunizable.FullyImmune); } return(result); }
public static bool IsPermanent(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; bool result; if (hediffWithComps == null) { result = false; } else { HediffComp_GetsPermanent hediffComp_GetsPermanent = hediffWithComps.TryGetComp <HediffComp_GetsPermanent>(); result = (hediffComp_GetsPermanent != null && hediffComp_GetsPermanent.IsPermanent); } return(result); }
public static bool IsTended(this Hediff hd) { HediffWithComps hediffWithComps = hd as HediffWithComps; bool result; if (hediffWithComps == null) { result = false; } else { HediffComp_TendDuration hediffComp_TendDuration = hediffWithComps.TryGetComp <HediffComp_TendDuration>(); result = (hediffComp_TendDuration != null && hediffComp_TendDuration.IsTended); } return(result); }
public static T TryGetComp <T>(this Hediff hd) where T : HediffComp { HediffWithComps hediffWithComps = hd as HediffWithComps; if (hediffWithComps == null) { return(null); } if (hediffWithComps.comps != null) { for (int i = 0; i < hediffWithComps.comps.Count; i++) { T val = hediffWithComps.comps[i] as T; if (val != null) { return(val); } } } return(null); }