public LordJob_Sermon(BuildingAltar altar, bool isMorningPrayer = true) { this.altar = altar; if (this.altar != null) { this.initialPosition = (WatchBuildingUtility.CalculateWatchCells(altar.def, altar.Position, altar.Rotation, altar.Map)).RandomElement(); } else { this.initialPosition = IntVec3.Invalid; } this.isMorningPrayer = isMorningPrayer; }
public override void PostSpawnSetup(bool respawningAfterLoad) { string debugStr = MyDebug ? parent.LabelShort + " PostSpawnSetup -" : ""; compFuel = parent.TryGetComp <CompRefuelable>(); compPower = parent.TryGetComp <CompPowerTrader>(); if (parent is Building b) { building = b; } RequiresReservationUpdate = AnyTaskRequiresReservationCheck; if (RequiresReservationUpdate) { this.UpdateReservationAndWorker(); Tools.Warn(debugStr + "updated reservation", MyDebug); } if (respawningAfterLoad) { for (PostDrawIndex = 0; PostDrawIndex < Props.postDraw.Count; PostDrawIndex++) { if (CurMaterialTracer.Displayed == true && CurPostDrawTask.HasSoundMaterialPool && CurPostDrawTask.soundMaterialPool.HasSustainSound) { CurMaterialTracer.sustainer = CurPostDrawTask.soundMaterialPool.soundSustain.TrySpawnSustainer(new TargetInfo(parent.Position, parent.Map)); } } return; } if (HasWatchArea) { WatchCells = WatchBuildingUtility.CalculateWatchCells(parent.def, parent.Position, parent.Rotation, parent.Map).ToList(); Tools.Warn(debugStr + "updated WatchCells " + (HasWatchCells ? WatchCells.Count().ToString() : ""), MyDebug); } for (PostDrawIndex = 0; PostDrawIndex < Props.postDraw.Count; PostDrawIndex++) { //MaterialIndexList.Add(0); MaterialIndexList.Add(new Tracer(0, false)); } Tools.Warn("MaterialIndexList size:" + MaterialIndexList.Count(), MyDebug); if (AnyTaskWithStuffMaterial && IsMadeOfStuff) { Tools.Warn(parent.Label + " is made of " + parent.Stuff, MyDebug); SetStuffMaterialIndexes(); } }
protected override Job TryGivePlayJob(Pawn pawn, Thing thing) { CompPowerTrader compPowerTrader = (CompPowerTrader)thing.TryGetComp <CompPowerTrader>(); if (compPowerTrader != null) { if (compPowerTrader.PowerNet.CurrentStoredEnergy() <= 0 || thing.IsBrokenDown() || !FlickUtility.WantsToBeOn(thing)) { return(null); } } Room room = pawn.GetRoom(RegionType.Set_Passable); if (room != null) { List <Building_Bed> containedBeds = room.ContainedBeds.ToList(); for (int i = 0; i < containedBeds.Count(); i++) { Building_Bed bed = containedBeds[i]; if (bed.owners != null) { for (int j = 0; j < bed.owners.Count(); j++) { Pawn bedOwner = bed.owners[j]; if (bedOwner.CurrentBed() == bed) { return(null); } } } } } List <IntVec3> thingWatchCells = WatchBuildingUtility.CalculateWatchCells(thing.def, thing.Position, thing.Rotation, thing.Map).ToList(); for (int i = 0; i < thingWatchCells.Count(); i++) { int cellRand = Rand.RangeInclusive(0, thingWatchCells.Count()); IntVec3 cell = thingWatchCells[cellRand]; if (cell.Standable(pawn.Map)) { //Log.Message(pawn + " watch cell = " + cellRand + " of " + thingWatchCells.Count()); return(new Job(def.jobDef, thing, cell)); } } return(null); }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null) { Map ourMap = Find.CurrentMap; GenDraw.DrawFieldEdges(WatchBuildingUtility.CalculateWatchCells(def, center, rot, ourMap).ToList <IntVec3>()); }
void BuildScanList() { // Default to interaction cell only, is also means that a pawn must // be using the building so star-gazers aren't turning the stove on. onIfOn = false; // Power cyclers don't need to scan anything if (IdleProps.operationalMode == LowIdleDrawMode.Cycle) { // Set default scan tick intervals { IdleProps.cycleLowTicks = 1000; } if (IdleProps.cycleHighTicks < 0) { IdleProps.cycleHighTicks = 500; } return; } else if (IdleProps.operationalMode == LowIdleDrawMode.Factory) { // Set default scan tick intervals if (IdleProps.cycleLowTicks < 0) { IdleProps.cycleLowTicks = 30; } if (IdleProps.cycleHighTicks < 0) { IdleProps.cycleHighTicks = 100; } return; } // If it's not a facility... if (CompFacility == null) { // List of cells to check scanPosition = new List <IntVec3>(); // Get the map positions to monitor if (parent.def.hasInteractionCell) { // Force-add interaction cell scanPosition.Add(parent.InteractionCell); if (IdleProps.operationalMode == LowIdleDrawMode.WhenNear) { // And the adjacent cells too foreach (IntVec3 curPos in GenAdj.CellsAdjacent8Way(parent.InteractionCell)) { AddScanPositionIfAllowed(curPos); } onIfOn = true; } } else { // Pawn standing on building means we need the buildings occupancy onIfOn = true; if (parent.def.passability == Traversability.Standable) { // Add building cells if it's standable foreach (IntVec3 curPos in GenAdj.CellsOccupiedBy(parent)) { AddScanPositionIfAllowed(curPos); } } if (IdleProps.operationalMode == LowIdleDrawMode.WhenNear) { // And the adjacent cells too??? foreach (var curPos in GenAdj.CellsAdjacent8Way(parent)) { AddScanPositionIfAllowed(curPos); } } if (IdleProps.operationalMode == LowIdleDrawMode.GroupUse) { // Group use adds cells "in front" of it // Only really used by TVs // WatchBuildingUtility already filters invalid cells for us var cells = WatchBuildingUtility.CalculateWatchCells(parent.def, parent.Position, parent.Rotation); foreach (var curPos in cells) { scanPosition.Add(curPos); } } } } // Set default scan tick intervals if (IdleProps.cycleLowTicks < 0) { IdleProps.cycleLowTicks = 30; } if (IdleProps.cycleHighTicks < 0) { if ((parent as Building_Door) != null) { // Doors can be computed IdleProps.cycleHighTicks = ((Building_Door)parent).TicksToOpenNow * 3; } else { // Give work tables more time so pawns have time to fetch ingredients IdleProps.cycleHighTicks = 500; } } }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot) { GenDraw.DrawFieldEdges(WatchBuildingUtility.CalculateWatchCells(def, center, rot, base.Map).ToList <IntVec3>()); }
bool SetParameters() { string DebugStr = PawnLabel + " " + MyName + " SetParameters"; Tools.Warn(DebugStr + " - Entering", MyDebug); if (pawn.CurJob == null) { Tools.Warn(DebugStr + " - no job for pawn", MyDebug); return(false); } else { Tools.Warn( DebugStr + " - pawn job: " + pawn.CurJobDef + " - GetType(): " + GetType() , MyDebug ); } IEnumerable <GameSettingsDef> myGSDList = DefDatabase <GameSettingsDef> .AllDefs .Where(gsd => gsd.gameSettingsList.Any(gs => gs.driverClass == GetType() && pawn.CurJobDef == gs.jobDef) ); if (myGSDList.EnumerableNullOrEmpty()) { Tools.Warn(DebugStr + " - 00 no GameProjectileDef found", MyDebug); return(false); } else { Tools.Warn(DebugStr + " - found " + myGSDList.EnumerableCount() + " GSD", MyDebug); } foreach (GameSettingsDef curGSD in myGSDList) { IEnumerable <GameSettings> myGPDItem = curGSD.gameSettingsList; foreach (GameSettings curGS in myGPDItem) { if ((curGS.driverClass == GetType()) && (pawn.CurJobDef == curGS.jobDef)) { gameSettings = curGS; Tools.Warn(DebugStr + " - found JobDef" + curGS.jobDef, MyDebug); break; } Tools.Warn(DebugStr + " - GetType():" + GetType() + " curGP.driverClass: " + curGS.driverClass + " curGP.jobDef: " + curGS.jobDef + " pawn.CurJobDef: " + pawn.CurJobDef , MyDebug ); } } if (!HasGameSettings) { Tools.Warn(DebugStr + " - 01 no HasGameSettings item found", MyDebug); return(false); } bool Didit = this.RetrieveProjectileParam(); Tools.Warn( DebugStr + " - 02 RetrieveProjectileParam:" + Didit + " - HasPickedMoteOption: " + HasPickedMoteOption + " - HasPickedShadowMoteOption: " + HasPickedShadowMoteOption , MyDebug); WatchCells = WatchBuildingUtility.CalculateWatchCells(JoyBuilding.def, PetanqueSpotCell, JoyBuilding.Rotation, Map); return(Didit); }