static Exception Finalizer(Exception __exception, Vector3 clickPos, Pawn pawn)
            {
                // Time to clean up our mess
                if (pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        IntVec3 cell = IntVec3.FromVector3(clickPos);
                        DesignatorUtility.RestoreDesignationsOnCell(cell, pawn.MapHeld);
                    }
                }

                return(__exception);
            }
Exemple #2
0
 private void RestoreDesignations(IntVec3 cell)
 {
     DesignatorUtility.RestoreDesignationsOnCell(cell, base.Map);
 }
Exemple #3
0
        protected Job GetJobOnTarget(Pawn meeseeks, SavedTargetInfo targetInfo, WorkGiver_Scanner workGiverScanner, bool scanAllThingsOnCell = false)
        {
            Job job = null;

            try
            {
                DesignatorUtility.ForceAllDesignationsOnCell(targetInfo.Cell, meeseeks.MapHeld);

                if (targetInfo.HasThing && !targetInfo.ThingDestroyed)
                {
                    // Special case for uninstall, the workgiver doesn't check to see if its already uninstalled
                    if (workGiverScanner as WorkGiver_Uninstall != null && !targetInfo.Thing.Spawned)
                    {
                        Logger.WarningFormat(this, "Target is inside {0}", targetInfo.Thing.ParentHolder);
                        DesignatorUtility.RestoreDesignationsOnCell(targetInfo.Cell, meeseeks.MapHeld);
                        return(null);
                    }

                    // Have to try-catch all these damn things because other mods arent't doing null checks :(
                    try
                    {
                        //Logger.MessageFormat(this, "Checking {0} for job on {1}", workGiverScanner, targetInfo.Thing);
                        if (workGiverScanner.HasJobOnThing(meeseeks, targetInfo.Thing, true))
                        {
                            //Logger.MessageFormat(this, "Getting {0} for job on {1}", workGiverScanner, targetInfo.Thing);
                            job = workGiverScanner.JobOnThing(meeseeks, targetInfo.Thing, true);
                        }
                    }
                    catch (Exception e)
                    {
                    }
                    finally
                    {
                    }
                }
                else
                {
                    // Have to try-catch all these damn things because other mods arent't doing null checks :(
                    try
                    {
                        //Logger.MessageFormat(this, "Checking {0} for job on {1}", workGiverScanner, targetInfo.Cell);
                        if (job == null && workGiverScanner.HasJobOnCell(meeseeks, targetInfo.Cell, true))
                        {
                            job = workGiverScanner.JobOnCell(meeseeks, targetInfo.Cell, true);
                        }
                    }
                    catch (Exception e)
                    {
                    }
                    finally
                    {
                    }
                }

                if (job == null && scanAllThingsOnCell)
                {
                    var thingsAtCell = meeseeks.MapHeld.thingGrid.ThingsAt(targetInfo.Cell);
                    foreach (Thing thing in thingsAtCell)
                    {
                        //Logger.MessageFormat(this, "Checking {0} for {1}.", thing, workGiverScanner.def.defName);

                        // Have to try-catch all these damn things because other mods arent't doing null checks :(
                        try
                        {
                            Logger.MessageFormat(this, "Checking {0} for job on {1}", workGiverScanner, thing);
                            if (workGiverScanner.HasJobOnThing(meeseeks, thing, true))
                            {
                                job = workGiverScanner.JobOnThing(meeseeks, thing, true);
                            }
                        }
                        catch (Exception e)
                        {
                        }
                        finally
                        {
                        }

                        if (job != null)
                        {
                            break;
                        }
                    }
                }
            }
            finally
            {
                DesignatorUtility.RestoreDesignationsOnCell(targetInfo.Cell, meeseeks.MapHeld);
            }

            return(job);
        }