public static bool UpdateBuilding(ListerBuildingsRepairable __instance, Building b) { Faction faction = b.Faction; if (faction == null || !b.def.building.repairable) { return(false); } lock (__instance) { List <Thing> thingList = __instance.ListFor(faction); HashSet <Thing> thingSet = __instance.HashSetFor(faction); if (b.HitPoints < b.MaxHitPoints) { if (!thingList.Contains((Thing)b)) { thingList.Add((Thing)b); } thingSet.Add((Thing)b); } else { List <Thing> newthingList = new List <Thing>(thingList); newthingList.Remove((Thing)b); __instance.repairables[faction] = newthingList; HashSet <Thing> newthingSet = new HashSet <Thing>(thingSet); newthingSet.Remove((Thing)b); __instance.repairablesSet[faction] = newthingSet; } } return(false); }
public void FindAvailableRepairables(Pawn pawn) { // find all available repairables availableRepairables = ListerBuildingsRepairable.RepairableBuildings(pawn.Faction); // needed to avoid null references if availableRepairables == 0 if (availableRepairables.Any()) { // repairable is in home area, can e reserved, not being decontructed, not burning availableRepairables = availableRepairables.Where(Repairable => pawn.Faction == Faction.OfPlayer && Find.AreaHome[Repairable.Position] && pawn.CanReserve(Repairable) && Repairable.def.useHitPoints && Repairable.HitPoints < Repairable.MaxHitPoints && Find.DesignationManager.DesignationOn(Repairable, DesignationDefOf.Deconstruct) == null && !Repairable.IsBurning()); } }
public static bool Notify_RepairedVehicle(Building b, ListerBuildingsRepairable __instance) { if (b is VehicleBuilding building && b.def is VehicleBuildDef vehicleDef && vehicleDef.thingToSpawn != null) { if (b.HitPoints < b.MaxHitPoints) { return(true); } Pawn vehicle; if (building.vehicleReference != null) { vehicle = building.vehicleReference; vehicle.health.Reset(); } else { vehicle = PawnGenerator.GeneratePawn(vehicleDef.thingToSpawn.VehicleKindDef); } Map map = b.Map; IntVec3 position = b.Position; Rot4 rotation = b.Rotation; AccessTools.Method(typeof(ListerBuildingsRepairable), "UpdateBuilding").Invoke(__instance, new object[] { b }); if (vehicleDef.soundBuilt != null) { vehicleDef.soundBuilt.PlayOneShot(new TargetInfo(position, map, false)); } if (vehicle.Faction != Faction.OfPlayer) { vehicle.SetFaction(Faction.OfPlayer); } b.Destroy(DestroyMode.Vanish); vehicle.ForceSetStateToUnspawned(); GenSpawn.Spawn(vehicle, position, map, rotation, WipeMode.FullRefund, false); return(false); } return(true); }
public void ConstructComponents() { this.spawnedThings = new ThingOwner <Thing>(this); this.cellIndices = new CellIndices(this); this.listerThings = new ListerThings(ListerThingsUse.Global); this.listerBuildings = new ListerBuildings(); this.mapPawns = new MapPawns(this); this.dynamicDrawManager = new DynamicDrawManager(this); this.mapDrawer = new MapDrawer(this); this.tooltipGiverList = new TooltipGiverList(); this.pawnDestinationReservationManager = new PawnDestinationReservationManager(); this.reservationManager = new ReservationManager(this); this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager(); this.designationManager = new DesignationManager(this); this.lordManager = new LordManager(this); this.debugDrawer = new DebugCellDrawer(); this.passingShipManager = new PassingShipManager(this); this.haulDestinationManager = new HaulDestinationManager(this); this.gameConditionManager = new GameConditionManager(this); this.weatherManager = new WeatherManager(this); this.zoneManager = new ZoneManager(this); this.resourceCounter = new ResourceCounter(this); this.mapTemperature = new MapTemperature(this); this.temperatureCache = new TemperatureCache(this); this.areaManager = new AreaManager(this); this.attackTargetsCache = new AttackTargetsCache(this); this.attackTargetReservationManager = new AttackTargetReservationManager(this); this.lordsStarter = new VoluntarilyJoinableLordsStarter(this); this.thingGrid = new ThingGrid(this); this.coverGrid = new CoverGrid(this); this.edificeGrid = new EdificeGrid(this); this.blueprintGrid = new BlueprintGrid(this); this.fogGrid = new FogGrid(this); this.glowGrid = new GlowGrid(this); this.regionGrid = new RegionGrid(this); this.terrainGrid = new TerrainGrid(this); this.pathGrid = new PathGrid(this); this.roofGrid = new RoofGrid(this); this.fertilityGrid = new FertilityGrid(this); this.snowGrid = new SnowGrid(this); this.deepResourceGrid = new DeepResourceGrid(this); this.exitMapGrid = new ExitMapGrid(this); this.linkGrid = new LinkGrid(this); this.glowFlooder = new GlowFlooder(this); this.powerNetManager = new PowerNetManager(this); this.powerNetGrid = new PowerNetGrid(this); this.regionMaker = new RegionMaker(this); this.pathFinder = new PathFinder(this); this.pawnPathPool = new PawnPathPool(this); this.regionAndRoomUpdater = new RegionAndRoomUpdater(this); this.regionLinkDatabase = new RegionLinkDatabase(); this.moteCounter = new MoteCounter(); this.gatherSpotLister = new GatherSpotLister(); this.windManager = new WindManager(this); this.listerBuildingsRepairable = new ListerBuildingsRepairable(); this.listerHaulables = new ListerHaulables(this); this.listerMergeables = new ListerMergeables(this); this.listerFilthInHomeArea = new ListerFilthInHomeArea(this); this.reachability = new Reachability(this); this.itemAvailability = new ItemAvailability(this); this.autoBuildRoofAreaSetter = new AutoBuildRoofAreaSetter(this); this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this); this.roofCollapseBuffer = new RoofCollapseBuffer(); this.wildAnimalSpawner = new WildAnimalSpawner(this); this.wildPlantSpawner = new WildPlantSpawner(this); this.steadyEnvironmentEffects = new SteadyEnvironmentEffects(this); this.skyManager = new SkyManager(this); this.overlayDrawer = new OverlayDrawer(); this.floodFiller = new FloodFiller(this); this.weatherDecider = new WeatherDecider(this); this.fireWatcher = new FireWatcher(this); this.dangerWatcher = new DangerWatcher(this); this.damageWatcher = new DamageWatcher(); this.strengthWatcher = new StrengthWatcher(this); this.wealthWatcher = new WealthWatcher(this); this.regionDirtyer = new RegionDirtyer(this); this.cellsInRandomOrder = new MapCellsInRandomOrder(this); this.rememberedCameraPos = new RememberedCameraPos(this); this.mineStrikeManager = new MineStrikeManager(); this.storyState = new StoryState(this); this.retainedCaravanData = new RetainedCaravanData(this); this.components.Clear(); this.FillComponents(); }
public override bool ShouldSkip(Pawn pawn) { return(ListerBuildingsRepairable.RepairableBuildings(pawn.Faction).Count == 0); }
public override IEnumerable <Thing> PotentialWorkThingsGlobal(Pawn pawn) { return(ListerBuildingsRepairable.RepairableBuildings(pawn.Faction)); }