コード例 #1
0
        public static Toil TakeEnchantGem(TargetIndex ind, Func <int> countGetter)
        {
            Toil takeThing = new Toil();

            takeThing.initAction = delegate
            {
                Pawn  actor = takeThing.actor;
                Thing thing = actor.CurJob.GetTarget(ind).Thing;
                Toils_Enchant.ErrorCheck(actor, thing);
                int num = Mathf.Min(countGetter(), thing.stackCount);
                if (num <= 0)
                {
                    actor.jobs.curDriver.ReadyForNextToil();
                }
                else
                {
                    CompEnchant comp = actor.GetComp <CompEnchant>();
                    if (comp != null)
                    {
                        if (comp.enchantingContainer.Count > 0)
                        {
                            comp.enchantingContainer.TryDropAll(actor.Position, actor.Map, ThingPlaceMode.Near);
                        }
                        comp.enchantingContainer.TryAdd(thing.SplitOff(1), true);
                        thing.def.soundPickup.PlayOneShot(new TargetInfo(actor.Position, actor.Map, false));
                    }
                    else
                    {
                        Log.Message("comp was null");
                    }
                }
            };
            return(takeThing);
        }
コード例 #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            Toil gotoThing = new Toil();

            gotoThing.initAction = delegate
            {
                this.pawn.pather.StartPath(this.TargetThingA, PathEndMode.ClosestTouch);
            };
            gotoThing.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            gotoThing.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            yield return(gotoThing);

            yield return(Toils_Enchant.TakeEnchantGem(TargetIndex.A, this.job.count));
        }
コード例 #3
0
 public static Toil TakeEnchantGem(TargetIndex ind, int count)
 {
     return(Toils_Enchant.TakeEnchantGem(ind, () => count));
 }