private static bool MakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate) { Filth filth = (Filth)(from t in c.GetThingList(map) where t.def == filthDef select t).FirstOrDefault <Thing>(); bool result; if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened)) { if (shouldPropagate) { List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized(); for (int i = 0; i < 8; i++) { IntVec3 c2 = c + list[i]; if (c2.InBounds(map)) { if (FilthMaker.MakeFilth(c2, map, filthDef, sources, false)) { return(true); } } } } if (filth != null) { filth.AddSources(sources); } result = false; } else { if (filth != null) { filth.ThickenFilth(); filth.AddSources(sources); } else { Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null); filth2.AddSources(sources); GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish); } FilthMonitor.Notify_FilthSpawned(); result = true; } return(result); }
private static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None) { Filth filth = (Filth)(from t in c.GetThingList(map) where t.def == filthDef select t).FirstOrDefault(); if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened)) { if (shouldPropagate) { List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized(); for (int i = 0; i < 8; i++) { IntVec3 c2 = c + list[i]; if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, shouldPropagate: false)) { return(true); } } } filth?.AddSources(sources); return(false); } if (filth != null) { filth.ThickenFilth(); filth.AddSources(sources); } else { if (!CanMakeFilth(c, map, filthDef, additionalFlags)) { return(false); } Filth obj = (Filth)ThingMaker.MakeThing(filthDef); obj.AddSources(sources); GenSpawn.Spawn(obj, c, map); } FilthMonitor.Notify_FilthSpawned(); return(true); }