Пример #1
0
        protected override bool TryCastShot()
        {
            bool flagRawResource = false;
            bool flagStuffItem   = false;
            bool flagNoStuffItem = false;
            bool flagNutrition   = false;
            bool flagCorpse      = false;


            Thing transmutateThing = TM_Calc.GetTransmutableThingFromCell(this.currentTarget.Cell, this.CasterPawn, out flagRawResource, out flagStuffItem, out flagNoStuffItem, out flagNutrition, out flagCorpse, true);

            //List<Thing> thingList = this.currentTarget.Cell.GetThingList(caster.Map);

            //for (int i = 0; i < thingList.Count; i++)
            //{
            //    if (thingList[i] != null && !(thingList[i] is Pawn) && !(thingList[i] is Building))
            //    {
            //        //if (thingList[i].def.thingCategories != null && thingList[i].def.thingCategories.Count > 0 && (thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.ResourcesRaw) || thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.StoneBlocks) || thingList[i].def.defName == "RawMagicyte"))
            //        if (thingList[i].def.MadeFromStuff && verVal >= 3)
            //        {
            //            //Log.Message("stuff item");
            //            flagStuffItem = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if(!thingList[i].def.MadeFromStuff && thingList[i].TryGetComp<CompQuality>() != null && verVal >= 3)
            //        {
            //            //Log.Message("non stuff item");
            //            flagNoStuffItem = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if ((thingList[i].def.statBases != null && thingList[i].GetStatValue(StatDefOf.Nutrition) > 0) && !(thingList[i] is Corpse) && verVal >= 1)
            //        {
            //            //Log.Message("food item");
            //            flagNutrition = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if(thingList[i] is Corpse && verVal >= 2)
            //        {
            //            //Log.Message("corpse");
            //            flagCorpse = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //        if (thingList[i].def != null && !thingList[i].def.IsIngestible && ((thingList[i].def.stuffProps != null && thingList[i].def.stuffProps.categories != null && thingList[i].def.stuffProps.categories.Count > 0) || thingList[i].def.defName == "RawMagicyte" || thingList[i].def.IsWithinCategory(ThingCategoryDefOf.ResourcesRaw) || thingList[i].def.IsWithinCategory(ThingCategoryDefOf.Leathers)))
            //        {
            //            //Log.Message("resource");
            //            flagRawResource = true;
            //            transmutateThing = thingList[i];
            //            break;
            //        }
            //    }
            //}

            if (transmutateThing != null)
            {
                TM_Action.DoTransmutate(this.CasterPawn, transmutateThing, flagNoStuffItem, flagRawResource, flagStuffItem, flagNutrition, flagCorpse);
            }
            else
            {
                Messages.Message("TM_NoThingToTransmutate".Translate(
                                     this.CasterPawn.LabelShort
                                     ), MessageTypeDefOf.RejectInput);
            }

            this.burstShotsLeft = 0;
            return(false);
        }
Пример #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            if (TargetA.Thing != null)
            {
                targetThing = TargetA.Thing;
            }
            Toil gotoThing = new Toil()
            {
                initAction = () =>
                {
                    pawn.pather.StartPath(TargetA, PathEndMode.Touch);
                },
                defaultCompleteMode = ToilCompleteMode.PatherArrival
            };

            yield return(gotoThing);

            Toil doSpell = new Toil();

            doSpell.initAction = delegate
            {
                if (ability != null)
                {
                    this.duration = (int)(ability.Def.MainVerb.warmupTime * 60 * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false));
                }
                if (age > duration)
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
                if (targetThing != null && (targetThing.DestroyedOrNull() || targetThing.Map == null))
                {
                    this.EndJobWith(JobCondition.Incompletable);
                }

                if (targetThing != null)
                {
                    this.pawn.rotationTracker.FaceTarget(targetThing);
                }
            };
            doSpell.tickAction = delegate
            {
                if (targetThing != null && (targetThing.DestroyedOrNull() || targetThing.Map == null))
                {
                    this.EndJobWith(JobCondition.Incompletable);
                }
                age++;
                ticksLeftThisToil = duration - age;
                if (Find.TickManager.TicksGame % 12 == 0)
                {
                    TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                }

                if (age > duration)
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
            };
            doSpell.defaultCompleteMode = ToilCompleteMode.Never;
            doSpell.defaultDuration     = this.duration;
            doSpell.AddFinishAction(delegate
            {
                if (ability != null)
                {
                    if (ability.Def == TorannMagicDefOf.TM_Transmutate && targetThing != null)
                    {
                        bool flagRawResource = false;
                        bool flagStuffItem   = false;
                        bool flagNoStuffItem = false;
                        bool flagNutrition   = false;
                        bool flagCorpse      = false;

                        TM_Calc.GetTransmutableThingFromCell(targetThing.Position, pawn, out flagRawResource, out flagStuffItem, out flagNoStuffItem, out flagNutrition, out flagCorpse);
                        TM_Action.DoTransmutate(pawn, targetThing, flagNoStuffItem, flagRawResource, flagStuffItem, flagNutrition, flagCorpse);
                    }
                    else if (ability.Def == TorannMagicDefOf.TM_RegrowLimb)
                    {
                        AbilityUser.SpawnThings tempThing = new SpawnThings();
                        tempThing.def = ThingDef.Named("SeedofRegrowth");
                        Verb_RegrowLimb.SingleSpawnLoop(tempThing, TargetA.Cell, pawn.Map);
                    }
                    ability.PostAbilityAttempt();
                }
                //AssignXP();
            });
            yield return(doSpell);
        }