示例#1
0
        private void IL_SetHealthRegen(ILContext il)
        {
            ILCursor c = new ILCursor(il);

            //bool ILFound;

            c.TryGotoNext(
                x => x.MatchRet());

            c.Emit(OpCodes.Ldarg_0);
            c.Emit(OpCodes.Ldloc, 46); //corresponds to num15 in the method. Factors titanic knurl bonus.
            c.Emit(OpCodes.Ldloc, 50); //corresponds to num56 in the method. Factors radiant pearl.
            c.Emit(OpCodes.Ldloc, 51); //corresponds to num46 in the method. Factors difficulty and fire
            c.EmitDelegate <Action <CharacterBody, float, float, float> >((body, knurlRegen, shinyPearlRegen, difficultyAndFireRegen) =>
            {
                PrimordialFleshComponent cpt = body.gameObject.GetComponent <PrimordialFleshComponent>();
                if (!cpt || cpt.cachedIcnt == 0)
                {
                    return;
                }

                float baseRegen = body.baseRegen + body.levelRegen * (body.level - 1); //base regen with no items
                float regen     = (baseRegen + knurlRegen + shinyPearlRegen) * difficultyAndFireRegen;

                float curseDebuff = body.inventory.GetItemCount(ItemIndex.HealthDecay);
                if (curseDebuff > 0)
                {
                    regen = Math.Min(regen, 0f) - body.maxHealth / body.cursePenalty / (float)curseDebuff; //factors in the curse
                }
                float velocity = body.rigidbody.velocity.magnitude;
                body.regen     = regen * velocity * cpt.cachedIcnt * regenMult;
            });
        }
示例#2
0
        public override void StoreItemCount(CharacterBody self)
        {
            PrimordialFleshComponent cpt = self.gameObject.GetComponent <PrimordialFleshComponent>();

            if (GetCount(self) > 0 || cpt)
            {
                if (!cpt)
                {
                    cpt = self.gameObject.AddComponent <PrimordialFleshComponent>();
                    cpt.characterBody = self;
                }
                cpt.cachedIcnt = GetCount(self);
                if (GetCount(self) == 0)
                {
                    cpt.enabled = false;
                }
                else
                {
                    cpt.enabled = true;
                }
            }
        }