Beispiel #1
0
        public static bool TryFindRandomCellInSermonArea(BuildingAltar altar, Pawn pawn, out IntVec3 result)
        {
            IntVec3  cell;
            Building chair;

            WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, true, out cell, out chair);


            if (chair != null)
            {
                result = chair.Position;
                return(true);
            }

            result = cell;
            if (cell == null)
            {
                return(false);
            }
            return(true);
        }
        protected virtual Job TryGiveAltarJob(Pawn pawn, Thing totem)
        {
            IntVec3  result;
            Building chair;

            if (!WatchBuildingUtility.TryFindBestWatchCell(totem, pawn, this.def.desireSit, out result, out chair))
            {
                if (this.def.desireSit)
                {
                    if (!WatchBuildingUtility.TryFindBestWatchCell(totem, pawn, false, out result, out chair))
                    {
                        return((Job)null);
                    }
                }
            }
            if (chair != null)
            {
                return(new Job(this.def.jobDef, totem, chair));
            }
            return(new Job(this.def.jobDef, totem, result));
        }
Beispiel #3
0
        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>());
        }
Beispiel #4
0
        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;
                }
            }
        }
Beispiel #5
0
 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);
        }