Example #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);
        }
Example #2
0
 private Thing ProduceThing()
 {
     if (chunkRecords.Count != 0)
     {
         ChunkRecord chunkRecord = chunkRecords.RandomElement();
         chunkRecord.amount--;
         if (chunkRecord.amount <= 0)
         {
             chunkRecords.Remove(chunkRecord);
         }
         return(ThingMaker.MakeThing(chunkRecord.chunkDef));
     }
     return(null);
 }
Example #3
0
 private void UnProduceThing(Thing thing)
 {
     if (thing != null)
     {
         ChunkRecord chunkRecord = chunkRecords.Find(x => x.chunkDef == thing.def);
         if (chunkRecord != null)
         {
             chunkRecord.amount++;
         }
         else
         {
             chunkRecord          = new ChunkRecord();
             chunkRecord.amount   = 1;
             chunkRecord.chunkDef = thing.def;
             chunkRecords.Add(chunkRecord);
         }
     }
 }
 private void UnProduceThing(Thing thing)
 {
     if (thing != null)
     {
         ChunkRecord chunkRecord = chunkRecords.Find(x => x.chunkDef == thing.def);
         if (chunkRecord != null)
         {
             chunkRecord.amount++;
         }
         else
         {
             chunkRecord = new ChunkRecord();
             chunkRecord.amount = 1;
             chunkRecord.chunkDef = thing.def;
             chunkRecords.Add(chunkRecord);
         }
     }
 }
 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;
 }