Exemple #1
0
        public bool ReceiveThing(Thing thingToReceive)
        {
            IntVec3 cellReceiving = parent.OccupiedRect().CenterCell;

            if (thingToReceive != null &&
                thingToReceive.Spawned &&
                !thingToReceive.Destroyed &&
                thingToReceive.IsChunk() &&
                ChunkTotalFast() < maxChunks &&
                cellReceiving.AllowedToAccept(parent.Map, thingToReceive) &&
                cellReceiving.Priority(parent.Map) >= thingToReceive.Position.Priority(parent.Map))
            {
                if (compWarehouse != null)
                {
                    compWarehouse.buffer.RemoveAll(x => x == thingToReceive);
                }
                ChunkRecord chunkRecord = chunkRecords.Find(x => x.chunkDef == thingToReceive.def);
                if (chunkRecord != null)
                {
                    chunkRecord.amount++;
                }
                else
                {
                    chunkRecord          = new ChunkRecord();
                    chunkRecord.amount   = 1;
                    chunkRecord.chunkDef = thingToReceive.def;
                    chunkRecords.Add(chunkRecord);
                }
                thingToReceive.Position.ThrowDustPuff(parent.Map);
                thingToReceive.Position.DropSound(parent.Map, thingToReceive.def);
                thingToReceive.DeSpawn();
                return(true);
            }
            return(false);
        }
Exemple #2
0
        public static bool AllowedToAccept(this IntVec3 cell, ThingDef thingDef)
        {
            Thing thing = ThingMaker.MakeThing(thingDef);

            return(cell.AllowedToAccept(thing));
        }