public virtual bool ClaimableBy(Faction by) { if (!def.Claimable) { return(false); } if (base.Faction != null) { if (base.Faction == by) { return(false); } if (by == Faction.OfPlayer) { if (base.Faction == Faction.OfInsects) { if (HiveUtility.AnyHivePreventsClaiming(this)) { return(false); } } else { if (base.Faction == Faction.OfMechanoids) { return(false); } if (base.Spawned) { List <Pawn> list = base.Map.mapPawns.SpawnedPawnsInFaction(base.Faction); for (int i = 0; i < list.Count; i++) { if (list[i].RaceProps.ToolUser && GenHostility.IsActiveThreatToPlayer(list[i])) { return(false); } } } } } } return(true); }
public virtual bool ClaimableBy(Faction by) { if (!def.Claimable) { return(false); } if (Faction != null) { if (Faction == by) { return(false); } if (by == Faction.OfPlayer) { // if there's any undowned humanlike of this faction spawned here, then don't allow claiming this building if (Faction == Faction.OfInsects) { if (HiveUtility.AnyHivePreventsClaiming(this)) { return(false); } } else if (Spawned) { var pawns = Map.mapPawns.SpawnedPawnsInFaction(Faction); for (int i = 0; i < pawns.Count; i++) { if (pawns[i].RaceProps.Humanlike && GenHostility.IsActiveThreatToPlayer(pawns[i])) { return(false); } } } } } return(true); }
public bool BuildingClaimableBy(Building building, Pawn by, CellRect cellRect) { //Log.Warning($"[ZzZomboRW.CompClaimable] Check: pawn={by}, int.={by.RaceProps.intelligence}, building={building}, claimable = {building.def.Claimable}, `by.faction`={by.Faction}, tooluser={by.RaceProps.ToolUser}, is wild={by.IsWildMan()}."); //Log.Warning($"[ZzZomboRW.CompClaimable] Condition: factions={building.Faction == by.Faction || building.Faction == Faction.OfMechanoids}."); //Log.Warning($"[ZzZomboRW.CompClaimable] Condition: enemies={!building.Faction.HostileTo(by.Faction)}."); //Log.Warning($"[ZzZomboRW.CompClaimable] Condition: hives={HiveUtility.AnyHivePreventsClaiming(building)}."); if (by == null || building == null || !building.Spawned || !building.def.Claimable || by.Faction == null || !by.RaceProps.ToolUser || by.IsWildMan()) { return(false); } if (building.Faction == by.Faction || building.Faction == Faction.OfMechanoids) { return(false); } if (!building.Faction.HostileTo(by.Faction)) { return(false); } if (by.Faction != Faction.OfPlayer) { if (!this.Props.byEnemies) { //Log.Warning("[ZzZomboRW.CompClaimable] Check: by enemies=false."); return(false); } } else { if (!this.Props.byPlayer || building.Fogged()) { //Log.Warning($"[ZzZomboRW.CompClaimable] Check: by player={this.Props.byPlayer}."); //Log.Warning($"[ZzZomboRW.CompClaimable] Check: fogged={building.Fogged()}."); return(false); } } if (!GenHostility.IsActiveThreatTo(by, building.Faction)) { //Log.Warning("[ZzZomboRW.CompClaimable] Check: not a threat."); return(false); } foreach (var pawn in building.Map.mapPawns.SpawnedPawnsInFaction(by.Faction)) { if (pawn.mindState?.enemyTarget == building) { //Log.Warning("[ZzZomboRW.CompClaimable] Check: target."); return(false); } } if (HiveUtility.AnyHivePreventsClaiming(building)) { return(false); } var dest = new LocalTargetInfo(building); foreach (var c in cellRect) { foreach (var t in c.GetThingList(building.Map)) { if (t is Pawn pawn && pawn.RaceProps.ToolUser && GenHostility.IsActiveThreatTo(pawn, by.Faction) && GenSight.LineOfSightToThing(pawn.Position, building, building.Map) && pawn.CanReach(dest, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { //Log.Warning($"[ZzZomboRW.CompClaimable] Check: {pawn} prevents capture."); return(false); } } } //Log.Warning($"[ZzZomboRW.CompClaimable] Condition: reachable={GenSight.LineOfSightToThing(by.Position, building, building.Map) && by.CanReach(dest, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)}!"); return(GenSight.LineOfSightToThing(by.Position, building, building.Map) && by.CanReach(dest, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)); }