Beispiel #1
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            //this.Map is null after base.Destroy(mode);
            //Spawn Items in Queue on Deconstruct or Destruction of Assembler
            for (int i = thingQueue.Count - 1; i >= 0; i--)
            {
                PlaceThingUtility.PRFTryPlaceThing(this, thingQueue[i], this.Position, this.Map, true);
            }

            base.Destroy(mode);

            prf_gamecomp.DeRegisterAssemblerQueue(this);
        }
Beispiel #2
0
        public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
        {
            //Spawn Items in Queue on Minify
            for (int i = thingQueue.Count - 1; i >= 0; i--)
            {
                //some of the things contaned are marked as Destroyed for some reason. they should not be Destroyed
                if (thingQueue[i].Destroyed)
                {
                    thingQueue[i].ForceSetStateToUnspawned();
                }

                PlaceThingUtility.PRFTryPlaceThing(this, thingQueue[i], this.Position, this.Map, true);
            }

            base.DeSpawn(mode);

            prf_gamecomp.DeRegisterAssemblerQueue(this);
        }
Beispiel #3
0
 public override void Tick()
 {
     base.Tick();
     if (this.IsHashIntervalTick(10) && Active)
     {
         if (thingQueue.Count > 0 &&
             PlaceThingUtility.PRFTryPlaceThing(this, thingQueue[0],
                                                OutputComp.CurrentCell, Map))
         {
             thingQueue.RemoveAt(0);
         }
         if (currentBillReport != null)
         {
             //Update the Required Work
             currentBillReport.workLeft -= 10f * ProductionSpeedFactor * (this.TryGetComp <CompPowerWorkSetting>()?.GetSpeedFactor() ?? 1f);
             //If Work Finished
             if (currentBillReport.workLeft <= 0)
             {
                 try
                 {
                     ProduceItems();
                     currentBillReport.bill.Notify_IterationCompleted(buildingPawn, currentBillReport.selected);
                     Notify_RecipeCompleted(currentBillReport.bill.recipe);
                 }
                 catch (Exception ex)
                 {
                     Log.Error($"Error producing items for {GetUniqueLoadID()}: " + ex);
                 }
                 finally
                 {
                     currentBillReport = null;
                 }
             }
         }
         else if (this.IsHashIntervalTick(60) && AllowProduction_thingQueue)
         {
             //Start Bill if Possible
             if ((currentBillReport = TryGetNextBill()) != null)
             {
                 Notify_BillStarted();
             }
         }
     }
     // Effect.
     if (currentBillReport != null && Active)
     {
         var ext = this.def.GetModExtension <AssemblerDefModExtension>();
         if (this.effecter == null)
         {
             this.effecter = (ext == null ? currentBillReport.bill.recipe?.effectWorking : ext.GetEffecter(this.currentBillReport.bill.recipe))?.Spawn();
         }
         if (this.sound == null)
         {
             this.sound = (ext == null ? currentBillReport.bill.recipe?.soundWorking : ext.GetSound(this.currentBillReport.bill.recipe))?.TrySpawnSustainer(this);
         }
         this.effecter?.EffectTick(this, this);
         this.sound?.SustainerUpdate();
         if (this.GetComp <CompGlowerPulse>() != null)
         {
             this.GetComp <CompGlowerPulse>().Glows = true;
         }
     }
     else
     {
         if (this.effecter != null)
         {
             this.effecter.Cleanup();
             this.effecter = null;
         }
         if (this.sound != null)
         {
             this.sound.End();
             this.sound = null;
         }
         if (this.GetComp <CompGlowerPulse>() != null)
         {
             this.GetComp <CompGlowerPulse>().Glows = false;
         }
     }
     //Fuel
     if (compRefuelable != null && Active && currentBillReport != null)
     {
         compRefuelable.Notify_UsedThisTick();
     }
 }