//moved it to util for easier implementation with MAD public static void DestroyNCreateGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius, Map map) { CompGlower oldGlower = null; CompPowerTrader pwrTrader = null; List <ThingComp> list = parent.GetComps(); foreach (ThingComp comp in list) { if (typeof(CompGlower) == comp.GetType()) { oldGlower = (CompGlower)comp; } if (typeof(CompPowerTrader) == comp.GetType()) { pwrTrader = (CompPowerTrader)comp; } } if (oldGlower != null) { //Boolean isLit = oldGlower.; //oldGlower.Lit = false; //parent.BroadcastCompSignal("FlickedOff"); //oldGlower.PostDeSpawn(); map.glowGrid.DeRegisterGlower(oldGlower); CompGlower newGlower = Util.newCompGlower(parent, glowColour, glowRadius); list.Remove(oldGlower); list.Add(newGlower); //Find.GlowGrid.RegisterGlower(newGlower); //(CompGlower)oldGlower. //replaced with an extention to thingWithComps... doesnt feel safe but hey //typeof(BuildingGlowTnC).GetField("comps", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(parent, List_AllThingComps); parent.SetComps(list); //parent.BroadcastCompSignal("FlickedOn"); newGlower.UpdateLit(map); //newGlower.Lit = false; updateMap(parent.Position, map); //if (pwrTrader != null) //{ // if (isLit && pwrTrader.PowerOn) // { // newGlower.Lit = true; // } //} } }
public static bool Draw_VampBed(ThingWithComps __instance) { if (__instance is Building_Casket casket) { if (__instance.GetComps <CompVampBed>() is CompVampBed b) { if (!casket.Spawned || casket.GetDirectlyHeldThings()?.Count == 0) { casket.Draw(); } return(false); } } return(true); }
//moved it to util for easier implementation with MAD public static void DestroyNCreateGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius) { CompGlower oldGlower = null; CompPowerTrader pwrTrader = null; List<ThingComp> list = parent.GetComps(); foreach (ThingComp comp in list) { if (typeof(CompGlower) == comp.GetType()) { if (oldGlower == null) { oldGlower = (CompGlower)comp; } } if (typeof(CompPowerTrader) == comp.GetType()) { pwrTrader = (CompPowerTrader)comp; } } if (oldGlower != null) { Boolean isLitoldGlower = oldGlower.Lit; oldGlower.Lit = false; CompGlower newGlower = Util.newCompGlower(parent, glowColour, glowRadius); list.Remove(oldGlower); list.Add(newGlower); parent.SetComps(list); newGlower.Lit = false; updateMap(parent.Position); if (pwrTrader != null) { if (isLitoldGlower && pwrTrader.PowerOn) { newGlower.Lit = true; } } } }
IEnumerable <CompIrradiator> GetIrradiators() { foreach (var v in parent.GetComp <CompAffectedByFacilities>().LinkedFacilitiesListForReading) { ThingWithComps thing = v as ThingWithComps; if (thing == null) { continue; } foreach (CompIrradiator comp in thing.GetComps <CompIrradiator>()) { yield return(comp); } } yield break; }
//moved it to util for easier implementation with MAD public static void DestroyNCreateGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius) { CompGlower oldGlower = null; CompPowerTrader pwrTrader = null; List <ThingComp> list = parent.GetComps(); foreach (ThingComp comp in list) { if (typeof(CompGlower) == comp.GetType()) { if (oldGlower == null) { oldGlower = (CompGlower)comp; } } if (typeof(CompPowerTrader) == comp.GetType()) { pwrTrader = (CompPowerTrader)comp; } } if (oldGlower != null) { Boolean isLitoldGlower = oldGlower.Lit; oldGlower.Lit = false; CompGlower newGlower = Util.newCompGlower(parent, glowColour, glowRadius); list.Remove(oldGlower); list.Add(newGlower); parent.SetComps(list); newGlower.Lit = false; updateMap(parent.Position); if (pwrTrader != null) { if (isLitoldGlower && pwrTrader.PowerOn) { newGlower.Lit = true; } } } }
public static void Notify_EquipmentRemoved_PostFix(Pawn_EquipmentTracker __instance, ThingWithComps eq) { foreach (var cai in eq.GetComps <CompAbilityItem>() ) //((Pawn)__instance.ParentHolder).GetComps<CompAbilityItem>() ) //Log.Message("Notify_EquipmentAdded_PostFix 1 : "+eq.ToString()); //Log.Message(" Found CompAbilityItem, for CompAbilityUser of "+cai.Props.AbilityUserClass.ToString()); { foreach (var cau in ((Pawn)__instance.ParentHolder).GetComps <CompAbilityUser>()) { //Log.Message(" Found CompAbilityUser, "+cau.ToString() +" : "+ cau.GetType()+":"+cai.Props.AbilityUserClass ); //Props.AbilityUserTarget.ToString()); if (cau.GetType() == cai.Props.AbilityUserClass) { foreach (var abdef in cai.Props.Abilities) { cau.RemoveWeaponAbility(abdef); } } } } }
public static void GetFloatMenuOptions_VampBed(ThingWithComps __instance, Pawn selPawn, ref IEnumerable <FloatMenuOption> __result) { if (__instance.GetComps <CompVampBed>() is CompVampBed b) { if (selPawn?.IsVampire() ?? false) { __result = __result.Concat(new[] { new FloatMenuOption("ROMV_EnterTorpor".Translate(new object[] { selPawn.Label }), delegate { selPawn.jobs.TryTakeOrderedJob(new Job(VampDefOf.ROMV_EnterTorpor, __instance)); }) }); } } }
public static void Notify_EquipmentRemovedPostfix(Pawn_EquipmentTracker __instance, ThingWithComps eq) { bool abilityitem = eq.TryGetComp <CompAbilityItem>() != null; if (abilityitem) { foreach (CompAbilityItem compAbilityItem in eq.GetComps <CompAbilityItem>()) { foreach (CompAbilityUser compAbilityUser in __instance.pawn.GetComps <CompAbilityUser>()) { if (compAbilityUser.AbilityData.TemporaryWeaponPowers.Any(x => compAbilityItem.Props.Abilities.Contains(x.Def))) { foreach (AbilityDef abilityDef in compAbilityItem.Props.Abilities) { compAbilityUser.RemoveWeaponAbility(abilityDef); } } } } } }