internal static void Durability(this CompBreakdownable _this, float value) { if (_this?.parent?.Map == null) { return; } MapComponent_Durability.ForMap(_this.parent.Map).SetDurability(_this, value); }
internal static float Durability(this CompBreakdownable _this) { if (_this?.parent?.Map == null) { return(1f); } return(MapComponent_Durability.ForMap(_this.parent.Map).GetDurability(_this)); }
public override bool HasJobOnThing(Pawn pawn, Thing thing, bool forced = false) { if (thing.Faction != pawn.Faction) { return(false); } if (pawn.Faction == Faction.OfPlayer && Settings.MaintainHomeOnly && !pawn.Map.areaManager.Home[thing.Position] && !forced) { return(false); } if (thing.IsBurning()) { return(false); } if (thing.Map.designationManager.DesignationOn(thing, DesignationDefOf.Deconstruct) != null) { return(false); } var twc = thing as ThingWithComps; if (twc == null) { return(false); } var comp = twc.TryGetComp <CompBreakdownable>(); if (comp == null) { return(false); } if (!MapComponent_Durability.ForMap(thing.Map).RequiresMaintenance(comp)) { return(false); } if (!pawn.CanReserveAndReach(thing, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, forced)) { return(false); } return(true); }
public static MapComponent_Durability ForMap(Map map) { if (map == null) { return(null); } var comp = map.GetComponent <MapComponent_Durability>(); if (comp == null) { comp = new MapComponent_Durability(map); map.components.Add(comp); } return(comp); }
public override bool ShouldSkip(Pawn pawn, bool forced) { return(!MapComponent_Durability.ForMap(pawn.Map).potentialMaintenanceThings.Any()); }
public override IEnumerable <Thing> PotentialWorkThingsGlobal(Pawn pawn) { return(MapComponent_Durability.ForMap(pawn.Map).potentialMaintenanceThings); }