예제 #1
0
        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);
        }
        public void GainFilth(ThingDef filthDef, IEnumerable <string> sources)
        {
            Filth filth = null;
            int   num   = 0;

            while (num < this.carriedFilth.Count)
            {
                if (this.carriedFilth[num].def != filthDef)
                {
                    num++;
                    continue;
                }
                filth = this.carriedFilth[num];
                break;
            }
            if (filth != null)
            {
                if (filth.CanBeThickened)
                {
                    filth.ThickenFilth();
                    filth.AddSources(sources);
                }
            }
            else
            {
                Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null);
                filth2.AddSources(sources);
                this.carriedFilth.Add(filth2);
            }
        }
예제 #3
0
        public void GainFilth(ThingDef filthDef, IEnumerable <string> sources)
        {
            if (filthDef.filth.terrainSourced)
            {
                lastTerrainFilthDef = filthDef;
            }
            Filth filth = null;

            for (int i = 0; i < carriedFilth.Count; i++)
            {
                if (carriedFilth[i].def == filthDef)
                {
                    filth = carriedFilth[i];
                    break;
                }
            }
            if (filth != null)
            {
                if (filth.CanBeThickened)
                {
                    filth.ThickenFilth();
                    filth.AddSources(sources);
                }
            }
            else
            {
                Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef);
                filth2.AddSources(sources);
                carriedFilth.Add(filth2);
            }
        }
예제 #4
0
        public void GainFilth(ThingDef filthDef, IEnumerable <string> sources)
        {
            Filth filth = null;

            for (int i = 0; i < this.carriedFilth.Count; i++)
            {
                if (this.carriedFilth[i].def == filthDef)
                {
                    filth = this.carriedFilth[i];
                    break;
                }
            }
            if (filth != null)
            {
                if (filth.CanBeThickened)
                {
                    filth.ThickenFilth();
                    filth.AddSources(sources);
                }
            }
            else
            {
                Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null);
                filth2.AddSources(sources);
                this.carriedFilth.Add(filth2);
            }
        }
예제 #5
0
        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();

            if (c.Walkable(map) && (filth == null || filth.CanBeThickened))
            {
                if (filth != null)
                {
                    filth.ThickenFilth();
                    filth.AddSources(sources);
                }
                else
                {
                    Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null);
                    filth2.AddSources(sources);
                    GenSpawn.Spawn(filth2, c, map);
                }
                return(true);
            }
            if (shouldPropagate)
            {
                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = c + list[i];
                    if (c2.InBounds(map) && FilthMaker.MakeFilth(c2, map, filthDef, sources, false))
                    {
                        return(true);
                    }
                }
            }
            if (filth != null)
            {
                filth.AddSources(sources);
            }
            return(false);
        }
예제 #6
0
        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);
        }