Пример #1
0
 public static bool ShouldPatch(string patchkey)
 {
     if (!DEBUG)
     {
         return(true);
     }
     if (!Patches.ContainsKey(patchkey))
     {
         ULog.Warning("ShouldPatch called for non-initialized patchkey.");
         return(true);
     }
     return(Patches[patchkey].apply);
 }
Пример #2
0
            public static bool DoLeavingsForPrefix(Thing diedThing, Map map, DestroyMode mode, CellRect leavingsRect, Predicate <IntVec3> nearPlaceValidator = null)
            {
                if (mode != DestroyMode.Deconstruct)
                {
                    return(true);                                 //just to make it more readable
                }
                ThingOwner <Thing> thingOwner = new ThingOwner <Thing>();

                if (GenLeaving.CanBuildingLeaveResources(diedThing, mode))
                {
                    Frame frame = diedThing as Frame;
                    if (frame != null)
                    {
                        for (int frameResCt = frame.resourceContainer.Count - 1; frameResCt >= 0; frameResCt--)
                        {
                            int gblrc;
                            if ((gblrc = GBRLC(diedThing)(frame.resourceContainer[frameResCt].stackCount)) > 0)
                            {
                                frame.resourceContainer.TryTransferToContainer(frame.resourceContainer[frameResCt], thingOwner, gblrc, true);
                            }
                        }
                        frame.resourceContainer.ClearAndDestroyContents(mode);
                    }
                    else
                    {
                        // TODO: ModExtension specifying drop rates per ThingDef. Needs to be relatively optimized.
                        List <ThingDefCountClass> list = diedThing.CostListAdjusted();
                        for (int l = 0; l < list.Count; l++)
                        {
                            ThingDefCountClass tdcc = list[l];
                            int gblrc;
                            if ((gblrc = GBRLC(diedThing)(tdcc.count)) > 0)
                            {
                                Thing thing = ThingMaker.MakeThing(tdcc.thingDef, null);
                                thing.stackCount = gblrc;
                                thingOwner.TryAdd(thing, true);
                            }
                        }
                    }
                }
                List <IntVec3> cellList = leavingsRect.Cells.InRandomOrder(null).ToList();
                int            cellInd  = 0;

                while (true)
                {
                    if (thingOwner.Count > 0)
                    {
                        ThingOwner <Thing> thingOwner2 = thingOwner;
                        Thing          thing           = thingOwner[0];
                        IntVec3        dropLoc         = cellList[cellInd];
                        ThingPlaceMode mode2           = ThingPlaceMode.Near;
                        Thing          thing4          = default(Thing);
                        if (thingOwner2.TryDrop(thing, dropLoc, map, mode2, out thing4, null, nearPlaceValidator))
                        {
                            cellInd++;
                            if (cellInd >= cellList.Count)
                            {
                                cellInd = 0;
                            }
                            continue;
                        }
                        break;
                    }
                    return(false);
                }
                ULog.Warning("Deconstruct Return Fix: Failed to place all leavings for destroyed thing " + diedThing + " at " + leavingsRect.CenterCell, false);
                return(false);
            }//end DoLeavingsForPrefix