コード例 #1
0
        public static Toil UninstallIfMinifiable(TargetIndex thingInd)
        {
            Toil uninstallIfMinifiable = new Toil().FailOnDestroyedNullOrForbidden(thingInd);

            uninstallIfMinifiable.initAction = delegate
            {
                Pawn      actor2     = uninstallIfMinifiable.actor;
                JobDriver curDriver2 = actor2.jobs.curDriver;
                Thing     thing2     = actor2.CurJob.GetTarget(thingInd).Thing;
                if (thing2.def.Minifiable)
                {
                    curDriver2.uninstallWorkLeft = thing2.def.building.uninstallWork;
                }
                else
                {
                    curDriver2.ReadyForNextToil();
                }
            };
            uninstallIfMinifiable.tickAction = delegate
            {
                Pawn      actor     = uninstallIfMinifiable.actor;
                JobDriver curDriver = actor.jobs.curDriver;
                Job       curJob    = actor.CurJob;
                curDriver.uninstallWorkLeft -= actor.GetStatValue(StatDefOf.ConstructionSpeed) * 1.7f;
                if (curDriver.uninstallWorkLeft <= 0f)
                {
                    Thing         thing         = curJob.GetTarget(thingInd).Thing;
                    MinifiedThing minifiedThing = thing.MakeMinified();
                    GenSpawn.Spawn(minifiedThing, thing.Position, uninstallIfMinifiable.actor.Map);
                    curJob.SetTarget(thingInd, minifiedThing);
                    actor.jobs.curDriver.ReadyForNextToil();
                }
            };
            uninstallIfMinifiable.defaultCompleteMode = ToilCompleteMode.Never;
            uninstallIfMinifiable.WithProgressBar(thingInd, () => 1f - uninstallIfMinifiable.actor.jobs.curDriver.uninstallWorkLeft / uninstallIfMinifiable.actor.CurJob.targetA.Thing.def.building.uninstallWork);
            return(uninstallIfMinifiable);
        }
コード例 #2
0
 internal void SetThingToInstallFromMinified(MinifiedThing itemToInstall)
 {
     miniToInstall       = itemToInstall;
     buildingToReinstall = null;
 }
コード例 #3
0
        public override bool CanStackWith(Thing other)
        {
            MinifiedThing minifiedThing = other as MinifiedThing;

            return(minifiedThing != null && base.CanStackWith(other) && this.InnerThing.CanStackWith(minifiedThing.InnerThing));
        }