Пример #1
0
        public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
        {
            Vector2 vector = Vector2.Lerp(base.firstChunk.lastPos, base.firstChunk.pos, timeStacker);

            if (vibrate > 0)
            {
                vector += Custom.DegToVec(Random.value * 360f) * 2f * Random.value;
            }
            Vector3 v = Vector3.Slerp(lastRotation, rotation, timeStacker);

            for (int i = 0; i >= 0; i--)
            {
                sLeaser.sprites[i].x        = vector.x - camPos.x;
                sLeaser.sprites[i].y        = vector.y - camPos.y;
                sLeaser.sprites[i].anchorY  = Mathf.Lerp((!lastPivotAtTip) ? 0.5f : 0.85f, (!pivotAtTip) ? 0.5f : 0.85f, timeStacker);
                sLeaser.sprites[i].rotation = Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), v);
            }
            if (blink > 0 && Random.value < 0.5f)
            {
                sLeaser.sprites[0].color = base.blinkColor;
            }
            else
            {
                sLeaser.sprites[0].color = color;
            }
            if (base.slatedForDeletetion || room != rCam.room)
            {
                sLeaser.CleanSpritesAndRemove();
            }
        }
Пример #2
0
 public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
 {
     sLeaser.sprites[0].x        = Mathf.Lerp(this.lastPos.x, this.pos.x, timeStacker) - camPos.x;
     sLeaser.sprites[0].y        = Mathf.Lerp(this.lastPos.y, this.pos.y, timeStacker) - camPos.y;
     sLeaser.sprites[0].rotation = Custom.AimFromOneVectorToAnother(Vector2.Lerp(this.lastLastPos, this.lastPos, timeStacker), Vector2.Lerp(this.lastPos, this.pos, timeStacker));
     sLeaser.sprites[0].scaleY   = Mathf.Max(0.45f, 0.45f + 0.1f * Vector2.Distance(Vector2.Lerp(this.lastLastPos, this.lastPos, timeStacker), Vector2.Lerp(this.lastPos, this.pos, timeStacker)));
     sLeaser.sprites[0].scaleX   = Custom.LerpMap(this.depth, 0f, 1f, 0.2f, 0.55f);
     sLeaser.sprites[0].alpha    = this.depth;
     base.DrawSprites(sLeaser, rCam, timeStacker, camPos);
 }
Пример #3
0
        public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
        {
            Vector2 vector = Vector2.Lerp(base.firstChunk.lastPos, base.firstChunk.pos, timeStacker);

            if (vibrate > 0)
            {
                vector += Custom.DegToVec(UnityEngine.Random.value * 360f) * 2f * UnityEngine.Random.value;
            }
            Vector3 v = Vector3.Slerp(lastRotation, rotation, timeStacker);

            for (int i = 1; i >= 0; i--)
            {
                sLeaser.sprites[i].x        = vector.x - camPos.x;
                sLeaser.sprites[i].y        = vector.y - camPos.y;
                sLeaser.sprites[i].rotation = Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), v);
            }

            if (blink > 0 && UnityEngine.Random.value < 0.5f)
            {
                sLeaser.sprites[1].color = base.blinkColor;
                sLeaser.sprites[0].color = base.blinkColor;
            }
            else
            {
                sLeaser.sprites[1].color = color;
                sLeaser.sprites[0].color = fadeColor;
            }

            if (base.slatedForDeletetion || room != rCam.room)
            {
                sLeaser.CleanSpritesAndRemove();
            }

            sLeaser.sprites[2].color = color;

            float   num            = 0f;
            Vector2 strapAttachPos = StrapAttachPos(timeStacker);

            for (int i = 0; i < strap.GetLength(0); i++)
            {
                float   f               = (float)i / (float)(strap.GetLength(0) - 1);
                Vector2 strapFollow     = Vector2.Lerp(strap[i, 1], strap[i, 0], timeStacker);
                float   num2            = (2f + 2f * Mathf.Sin(Mathf.Pow(f, 2f) * (float)System.Math.PI)) * Vector3.Slerp(strap[i, 4], strap[i, 3], timeStacker).x;
                Vector2 normalizedStrap = (strapAttachPos - strapFollow).normalized;
                Vector2 perpStrap       = Custom.PerpendicularVector(normalizedStrap);
                float   diff            = Vector2.Distance(strapAttachPos, strapFollow) / 5f;
                (sLeaser.sprites[2] as TriangleMesh).MoveVertice(i * 4, strapAttachPos - normalizedStrap * diff - perpStrap * (num2 + num) * 0.5f - camPos);
                (sLeaser.sprites[2] as TriangleMesh).MoveVertice(i * 4 + 1, strapAttachPos - normalizedStrap * diff + perpStrap * (num2 + num) * 0.5f - camPos);
                (sLeaser.sprites[2] as TriangleMesh).MoveVertice(i * 4 + 2, strapFollow + normalizedStrap * diff - perpStrap * num2 - camPos);
                (sLeaser.sprites[2] as TriangleMesh).MoveVertice(i * 4 + 3, strapFollow + normalizedStrap * diff + perpStrap * num2 - camPos);
                strapAttachPos = vector;
                num            = num2;
            }
        }
Пример #4
0
 public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
 {
     if (sLeaser.sprites[0].alpha < Mathf.Lerp(0f, Mathf.Lerp(0f, 0.55f, this.room.roomSettings.RainIntensity), Mathf.Lerp(0f, 1f, Mathf.InverseLerp(-0.5f, 0.5f, this.owner.TimePastCycleEnd))))
     {
         this.alpha += 0.015f * timeStacker;
     }
     sLeaser.sprites[0].alpha    = this.alpha;
     sLeaser.sprites[0].x        = Mathf.Lerp(this.lastPos.x, this.pos.x, timeStacker);
     sLeaser.sprites[0].y        = Mathf.Lerp(this.lastPos.y, this.pos.y, timeStacker);
     sLeaser.sprites[0].rotation = Custom.AimFromOneVectorToAnother(Vector2.Lerp(this.lastLastPos, this.lastPos, timeStacker), Vector2.Lerp(this.lastPos, this.pos, timeStacker));
     base.DrawSprites(sLeaser, rCam, timeStacker, camPos);
 }
    public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
    {
        base.DrawSprites(sLeaser, rCam, timeStacker, camPos);
        if (culled)
        {
            return;
        }
        float   num    = Mathf.Lerp(lastExtended, extended, timeStacker);
        Vector2 vector = worm.bodyChunks[1].pos + new Vector2(0f, -30f - 100f * (1f - num));
        float   num2   = 4f;

        for (int i = 0; i < worm.tentacle.tChunks.Length; i++)
        {
            Vector2 vector2 = Vector2.Lerp(worm.tentacle.tChunks[i].lastPos, worm.tentacle.tChunks[i].pos, timeStacker);
            float   num3    = (float)i / (float)(worm.tentacle.tChunks.Length - 1);
            float   num4    = Mathf.Pow(Mathf.Max(1f - num3 - num, 0f), 1.5f);
            if (num < 0.2f)
            {
                num4 = Mathf.Min(1f, num4 + Mathf.InverseLerp(0.2f, 0f, num));
            }
            vector2 = Vector2.Lerp(vector2, worm.bodyChunks[1].pos, num4) + new Vector2(0f, -100f * Mathf.Pow(num4, 0.5f));
            float d = Mathf.Sin((Mathf.Lerp(sinWave - sinSpeed, sinWave, timeStacker) + num3 * numberOfWavesOnBody) * 3.14159274f * 2f);
            vector2 += Custom.PerpendicularVector((vector2 - vector).normalized) * d * 11f * Mathf.Pow(Mathf.Max(0f, Mathf.Sin(num3 * 3.14159274f)), 0.75f) * num;
            Vector2 normalized = (vector2 - vector).normalized;
            Vector2 a          = Custom.PerpendicularVector(normalized);
            if (i == worm.tentacle.tChunks.Length - 1)
            {
                sLeaser.sprites[2].x        = vector2.x - camPos.x;
                sLeaser.sprites[2].y        = vector2.y - camPos.y;
                sLeaser.sprites[2].rotation = Custom.AimFromOneVectorToAnother(-normalized, normalized);
                float num5 = Mathf.Cos(Custom.AimFromOneVectorToAnother(-normalized, normalized) / 360f * 2f * 3.14159274f);
                num5 = Mathf.Pow(Mathf.Abs(num5), 0.25f) * Mathf.Sign(num5);
                int num6 = (num5 * Mathf.Sign(normalized.x) <= 0f) ? 0 : 3;
                sLeaser.sprites[3 - num6].x = vector2.x - camPos.x + normalized.x * 5f * worm.bodySize + a.x * 3f * Mathf.Lerp(worm.bodySize, 1f, 0.75f) * num5;
                sLeaser.sprites[3 - num6].y = vector2.y - camPos.y + normalized.y * 5f * worm.bodySize + a.y * 3f * Mathf.Lerp(worm.bodySize, 1f, 0.75f) * num5;
                sLeaser.sprites[num6].x     = vector2.x - camPos.x + normalized.x * 5f * worm.bodySize - a.x * 3f * Mathf.Lerp(worm.bodySize, 1f, 0.75f) * num5;
                sLeaser.sprites[num6].y     = vector2.y - camPos.y + normalized.y * 5f * worm.bodySize - a.y * 3f * Mathf.Lerp(worm.bodySize, 1f, 0.75f) * num5;
            }
            float d2   = Vector2.Distance(vector2, vector) / 7f;
            float num7 = worm.tentacle.tChunks[i].stretchedRad + swallowArray[i] * 5f;
            (sLeaser.sprites[1] as TriangleMesh).MoveVertice(i * 4, vector - a * (num7 + num2) * 0.5f + normalized * d2 - camPos);
            (sLeaser.sprites[1] as TriangleMesh).MoveVertice(i * 4 + 1, vector + a * (num7 + num2) * 0.5f + normalized * d2 - camPos);
            (sLeaser.sprites[1] as TriangleMesh).MoveVertice(i * 4 + 2, vector2 - a * num7 - normalized * d2 - camPos);
            (sLeaser.sprites[1] as TriangleMesh).MoveVertice(i * 4 + 3, vector2 + a * num7 - normalized * d2 - camPos);
            num2   = num7;
            vector = vector2;
        }
        sLeaser.sprites[0].color = Color.black;
        sLeaser.sprites[3].color = Color.black;
    }
Пример #6
0
        public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
        {
            Vector2 vector = Vector2.Lerp(base.firstChunk.lastPos, base.firstChunk.pos, timeStacker);

            if (vibrate > 0)
            {
                vector += Custom.DegToVec(UnityEngine.Random.value * 360f) * 2f * UnityEngine.Random.value;
            }
            Vector3 v = Vector3.Slerp(lastRotation, rotation, timeStacker);

            for (int i = 1; i >= 0; i--)
            {
                sLeaser.sprites[i].x        = vector.x - camPos.x;
                sLeaser.sprites[i].y        = vector.y - camPos.y;
                sLeaser.sprites[i].rotation = Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), v);
            }

            int drawState = Mathf.RoundToInt(Mathf.Lerp(1, 8, drawProgress));

            sLeaser.sprites[1].element = Futile.atlasManager.GetElementWithName("BowStringA" + drawState.ToString());

            if (mode != Weapon.Mode.OnBack)
            {
                sLeaser.sprites[0].anchorY = 0.1f;
                sLeaser.sprites[1].anchorY = -0.55f;
            }
            else
            {
                sLeaser.sprites[0].anchorY = 0.5f;
                sLeaser.sprites[1].anchorY = -0.15f;
            }

            if (blink > 0 && UnityEngine.Random.value < 0.5f)
            {
                sLeaser.sprites[0].color = base.blinkColor;
            }
            else
            {
                sLeaser.sprites[0].color = color;
            }

            if (base.slatedForDeletetion || room != rCam.room)
            {
                sLeaser.CleanSpritesAndRemove();
            }
        }
 // Token: 0x060024E4 RID: 9444 RVA: 0x0023CDB0 File Offset: 0x0023AFB0
 public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos, Vector2 partPos, Vector2 headPos, float useFade, float popOut, Color useColor)
 {
     base.DrawSprites(sLeaser, rCam, timeStacker, camPos, partPos, headPos, useFade, popOut, useColor);
     if (UnityEngine.Random.value > Mathf.InverseLerp(0.5f, 1f, useFade))
     {
         for (int i = 0; i < 4; i++)
         {
             sLeaser.sprites[this.firstSprite + i].isVisible = false;
         }
         return;
     }
     for (int j = 0; j < 4; j++)
     {
         sLeaser.sprites[this.firstSprite + j].isVisible = true;
         Vector2 vector = partPos + new Vector2(12f, 5f) + Custom.DegToVec(-90f - 90f * (float)j) * 4f;
         sLeaser.sprites[this.firstSprite + j].x = vector.x - camPos.x;
         sLeaser.sprites[this.firstSprite + j].y = vector.y - camPos.y;
         if (j < 3 && (this.hologram as OverseerDroughtTutorialBehavior.GamePadInstruction).buttons[j].pulsate)
         {
             sLeaser.sprites[this.firstSprite + j].color = (this.hologram as OverseerDroughtTutorialBehavior.GamePadInstruction).buttons[j].color;
         }
         else
         {
             sLeaser.sprites[this.firstSprite + j].color = useColor;
         }
         if (UnityEngine.Random.value > useFade)
         {
             sLeaser.sprites[this.firstSprite + j].element  = Futile.atlasManager.GetElementWithName("pixel");
             sLeaser.sprites[this.firstSprite + j].anchorY  = 0f;
             sLeaser.sprites[this.firstSprite + j].rotation = Custom.AimFromOneVectorToAnother(partPos, headPos);
             sLeaser.sprites[this.firstSprite + j].scaleY   = Vector2.Distance(partPos, headPos);
         }
         else
         {
             sLeaser.sprites[this.firstSprite + j].element  = Futile.atlasManager.GetElementWithName("Circle4");
             sLeaser.sprites[this.firstSprite + j].rotation = 0f;
             sLeaser.sprites[this.firstSprite + j].scaleY   = 1f;
             sLeaser.sprites[this.firstSprite + j].anchorY  = 0.5f;
         }
     }
 }
Пример #8
0
        public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
        {
            if (search)
            {
                if (warning == 0f)
                {
                    this.room.AddObject(new LightningFlash(pathPositions.Last() + new Vector2(0f, 15f), this.color, 15f, 30f, true));
                    this.room.PlaySound(SoundID.Thunder_Close, pathPositions.Last(), 0.7f, 1f);
                }
                warning += 0.024f * timeStacker;
                if (!spawn && warning >= 1f)
                {
                    this.InitiateSprites(sLeaser, rCam);
                    this.room.PlaySound(SoundID.Bomb_Explode, pathPositions.Last(), 1.3f, 0.8f);
                    this.room.PlaySound(SoundID.Thunder, pathPositions.Last(), 1f, 1f);
                    this.room.AddObject(new Smoke.BombSmoke(this.room, pathPositions.Last() + new Vector2(0f, 15f), null, new Color(0.01f, 0.01f, 0.01f)));
                    this.room.AddObject(new SootMark(this.room, pathPositions.Last() + new Vector2(0f, 15f), 50f, false));
                    this.room.AddObject(new LightningFlash(pathPositions.Last() + new Vector2(0f, 15f), this.color, 90f, 1f, false));
                    this.room.AddObject(new LightningImpact(pathPositions.Last() + new Vector2(0f, 10f), 35f, this.color));
                    switch (Downpour.strikeDamage)
                    {
                    case 0:
                        this.room.AddObject(new Explosion(this.room, null, pathPositions.Last() + new Vector2(0f, 15f), 7, 10f, 0f, 0f, 0f, 0.02f, null, 0.7f, 160f, 1f));
                        break;

                    case 1:
                        this.room.AddObject(new Explosion(this.room, null, pathPositions.Last() + new Vector2(0f, 15f), 7, 90f, 2f, 0f, 80f, 0.02f, null, 0.7f, 160f, 1f));
                        break;

                    case 2:
                        this.room.AddObject(new Explosion(this.room, null, pathPositions.Last() + new Vector2(0f, 15f), 7, 100f, 3f, 2f, 280f, 0.02f, null, 0.7f, 160f, 1f));
                        break;
                    }
                    for (int i = 0; i < pathPositions.Count; i++)
                    {
                        this.room.AddObject(new LightningImpact(pathPositions[i], 20f, this.color));
                    }
                    spawn = true;
                }
                for (int i = 0; i < pathPositions.Count; i++)
                {
                    pathPositions[i] += new Vector2(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f));
                }
                if (sLeaser.sprites != null)
                {
                    for (int i = 0; i < sLeaser.sprites.Length; i++)
                    {
                        if (i + 1 > pathPositions.Count - 1)
                        {
                            break;
                        }
                        sLeaser.sprites[i].rotation = Custom.AimFromOneVectorToAnother(pathPositions[i], pathPositions[i + 1]);
                        sLeaser.sprites[i].x        = Mathf.Lerp(pathPositions[i].x, pathPositions[i + 1].x, 0.5f) - camPos.x;
                        sLeaser.sprites[i].y        = Mathf.Lerp(pathPositions[i].y, pathPositions[i + 1].y, 0.5f) - camPos.y;
                        sLeaser.sprites[i].scaleY   = Vector2.Distance(pathPositions[i], pathPositions[i + 1]);
                        sLeaser.sprites[i].scaleX  -= 0.12f;
                        sLeaser.sprites[i].alpha   -= 0.03f;
                    }
                }
            }
            base.DrawSprites(sLeaser, rCam, timeStacker, camPos);
        }
Пример #9
0
 public void Update()
 {
     if (crit.pos != lastPos)
     {
         lastPos = crit.pos;
         if (!drag)
         {
             dragPos = drawPos;
         }
         drag = true;
     }
     drawPos = myMapPage.CreatureVisPos(crit.pos, crit.InDen, true);
     if (crit.realizedCreature == null && crit.distanceToMyNode < 0)
     {
         drawPos.y = drawPos.y + Mathf.Lerp(-2f, 2f, Random.value);
     }
     if (crit.InDen)
     {
         drawPos.y = drawPos.y - 10f;
     }
     sprite.x = drawPos.x;
     sprite.y = drawPos.y;
     if (drag)
     {
         dragPos        += Vector2.ClampMagnitude(drawPos - dragPos, 10f);
         sprite.scaleY   = Vector2.Distance(drawPos, dragPos);
         sprite.rotation = Custom.AimFromOneVectorToAnother(drawPos, dragPos);
         if (Custom.DistLess(dragPos, drawPos, 5f))
         {
             drag = false;
         }
     }
     else if (crit.pos.NodeDefined)
     {
         Vector2 vector = myMapPage.NodeVisPos(crit.pos.room, crit.pos.abstractNode);
         sprite.scaleY   = Vector2.Distance(drawPos, vector);
         sprite.rotation = Custom.AimFromOneVectorToAnother(drawPos, vector);
     }
     else
     {
         sprite.scaleY   = 10f;
         sprite.rotation = 135f;
     }
     if (crit.abstractAI != null)
     {
         Vector2 vector2 = myMapPage.CreatureVisPos(crit.abstractAI.destination, false, false);
         sprite2.x        = drawPos.x;
         sprite2.y        = drawPos.y;
         sprite2.color    = Color.Lerp(new Color(1f, 1f, 1f), label.color, Random.value);
         sprite2.scaleY   = Vector2.Distance(drawPos, vector2);
         sprite2.rotation = Custom.AimFromOneVectorToAnother(drawPos, vector2);
     }
     label.x      = drawPos.x;
     label.y      = drawPos.y;
     label.color  = CritCol(crit);
     sprite.color = label.color;
     label2.x     = drawPos.x + 1f;
     label2.y     = drawPos.y - 1f;
     label.text   = CritString(crit);
     label2.text  = label.text;
     if (crit.slatedForDeletion)
     {
         Destroy();
     }
 }
    // Token: 0x06001E2A RID: 7722 RVA: 0x001BE340 File Offset: 0x001BC540
    public override void DrawSprites(RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
    {
        base.DrawSprites(sLeaser, rCam, timeStacker, camPos);
        if (this.culled)
        {
            return;
        }
        for (int i = 0; i < this.danglers.Length; i++)
        {
            this.danglers[i].DrawSprite(HeadDanglerSprite(i), sLeaser, rCam, timeStacker, camPos);
        }
        Vector2 vector23 = Vector2.Lerp(this.fish.bodyChunks[2].lastPos, this.fish.bodyChunks[2].pos, timeStacker);
        Vector2 vector24 = Vector2.Lerp(this.fish.mainBodyChunk.lastPos, this.fish.mainBodyChunk.pos, timeStacker);
        Vector2 a2       = Custom.DirVec(Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker), Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker));;
        Vector2 vector25 = Vector2.Lerp(this.fish.neck.connectedChunk.lastPos, this.fish.neck.connectedChunk.pos, timeStacker);
        float   thick    = 2f;
        float   num23    = 3f;

        for (int l = 0; l < this.fish.neck.tChunks.Length; l++)
        {
            Vector2 vector6 = Vector2.Lerp(this.fish.neck.tChunks[l].lastPos, this.fish.neck.tChunks[l].pos, timeStacker);
            if (l == this.fish.neck.tChunks.Length - 1)
            {
                vector6 = Vector2.Lerp(vector6, vector23, 0.5f);
                thick   = 1f;
            }
            else if (l == 0)
            {
                vector6 = Vector2.Lerp(vector6, vector24 + a2 * 40f, 0.3f);
            }
            Vector2 normalized1 = (vector6 - vector25).normalized;
            Vector2 a3          = Custom.PerpendicularVector(normalized1);
            float   d           = Vector2.Distance(vector6, vector25) / 5f;
            (sLeaser.sprites[this.NeckSprite] as TriangleMesh).MoveVertice(l * 4, vector25 - a3 * (this.fish.neck.tChunks[l].stretchedRad + num23) * 0.5f * thick + normalized1 * d * ((l != 0) ? 1f : 0f) - camPos);
            (sLeaser.sprites[this.NeckSprite] as TriangleMesh).MoveVertice(l * 4 + 1, vector25 + a3 * (this.fish.neck.tChunks[l].stretchedRad + num23) * 0.5f * thick + normalized1 * d * ((l != 0) ? 1f : 0f) - camPos);
            if (l == this.fish.neck.tChunks.Length - 1)
            {
                thick = 0.2f;
            }
            (sLeaser.sprites[this.NeckSprite] as TriangleMesh).MoveVertice(l * 4 + 2, vector6 - a3 * this.fish.neck.tChunks[l].stretchedRad * thick - normalized1 * d * ((l != this.fish.neck.tChunks.Length - 1) ? 1f : 0f) - camPos);
            (sLeaser.sprites[this.NeckSprite] as TriangleMesh).MoveVertice(l * 4 + 3, vector6 + a3 * this.fish.neck.tChunks[l].stretchedRad * thick - normalized1 * d * ((l != this.fish.neck.tChunks.Length - 1) ? 1f : 0f) - camPos);
            num23    = this.fish.neck.tChunks[l].stretchedRad;
            vector25 = vector6;
        }

        Vector2 vector     = Vector3.Slerp(this.lastZRotation, this.zRotation, timeStacker);
        Vector2 vector2    = Vector2.Lerp(Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker), Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker), 0.3f);
        Vector2 normalized = (Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker) - Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker)).normalized;
        Vector2 a          = Custom.PerpendicularVector(-normalized);
        float   num        = Custom.AimFromOneVectorToAnother(normalized, -normalized);
        float   num2       = Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), vector);
        int     num3       = Custom.IntClamp(8 - (int)(Mathf.Abs(num2 / 180f) * 9f), 0, 8);
        float   num4       = (float)(8 - num3) * Mathf.Sign(num2) * 22.5f;

        //float wingLength = Mathf.Abs(Mathf.Clamp(8f - (Mathf.Abs(Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), Vector3.Slerp(this.lastZRotation, this.zRotation, timeStacker)) / 180f) * 9f), 0f, 8f) - 4f) / 4f;
        sLeaser.sprites[this.BodySprite].x        = vector2.x - camPos.x;
        sLeaser.sprites[this.BodySprite].y        = vector2.y - camPos.y;
        sLeaser.sprites[this.BodySprite].element  = Futile.atlasManager.GetElementWithName("SeaDrake" + num3);
        sLeaser.sprites[this.BodySprite].rotation = num - num4;
        sLeaser.sprites[this.BodySprite].scaleX   = ((num2 <= 0f) ? Mathf.Lerp(0.3f, 0.6f, this.fish.iVars.fatness) : -Mathf.Lerp(0.3f, 0.6f, this.fish.iVars.fatness));

        //vector = Custom.DirVec(Vector2.Lerp(this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 3].lastPos, this.fish.neck.tChunks[this.fish.neck.tChunks.Length-3].pos, timeStacker), Vector2.Lerp(this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].lastPos, this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].pos, timeStacker));
        num2 = Custom.VecToDeg(-vector);
        num3 = Custom.IntClamp(8 - (int)(Mathf.Abs(num2 / 180f) * 9f), 0, 8);
        num4 = (float)(8 - num3) * Mathf.Sign(num2) * 22.5f;

        sLeaser.sprites[this.HeadSprite].x        = Vector2.Lerp(this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].lastPos, this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].pos, timeStacker).x - camPos.x;
        sLeaser.sprites[this.HeadSprite].y        = Vector2.Lerp(this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].lastPos, this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].pos, timeStacker).y - camPos.y;
        sLeaser.sprites[this.HeadSprite].element  = Futile.atlasManager.GetElementWithName("SeaDrakeHead" + num3);
        sLeaser.sprites[this.HeadSprite].rotation = num2 - num4;
        sLeaser.sprites[this.HeadSprite].scaleX   = ((num2 <= 0f) ? 0.6f : -0.6f);

        num2 = Custom.VecToDeg(-vector);
        num3 = Custom.IntClamp(8 - (int)(Mathf.Abs(num2 / 180f) * 9f), 0, 8);
        num4 = (float)(8 - num3) * Mathf.Sign(num2) * 22.5f;

        sLeaser.sprites[this.JawSprite].x        = Vector2.Lerp(this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].lastPos, this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].pos, timeStacker).x - camPos.x + Custom.DegToVec(num2).x * 10f;
        sLeaser.sprites[this.JawSprite].y        = Vector2.Lerp(this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].lastPos, this.fish.neck.tChunks[this.fish.neck.tChunks.Length - 2].pos, timeStacker).y - camPos.y + Custom.DegToVec(num2).y * 10f;
        sLeaser.sprites[this.JawSprite].element  = Futile.atlasManager.GetElementWithName("SeaDrakeJaw" + num3);
        sLeaser.sprites[this.JawSprite].rotation = num2 - num4;
        sLeaser.sprites[this.JawSprite].scaleX   = ((num2 <= 0f) ? 0.7f : -0.7f);

        vector     = Vector3.Slerp(this.lastZRotation, this.zRotation, timeStacker);
        vector2    = Vector2.Lerp(Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker), Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker), 0.3f);
        normalized = (Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker) - Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker)).normalized;
        a          = Custom.PerpendicularVector(-normalized);
        num        = Custom.AimFromOneVectorToAnother(normalized, -normalized);
        num2       = Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), vector);
        num3       = Custom.IntClamp(8 - (int)(Mathf.Abs(num2 / 180f) * 9f), 0, 8);
        num4       = (float)(8 - num3) * Mathf.Sign(num2) * 22.5f;

        Vector2 vector33 = Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker);
        float   num55    = this.fish.bodyChunks[1].rad / 2f;

        for (int j = 0; j < this.tail.Length; j++)
        {
            Vector2 vector4     = Vector2.Lerp(this.tail[j].lastPos, this.tail[j].pos, timeStacker);
            Vector2 normalized2 = (vector4 - vector33).normalized;
            Vector2 a3          = Custom.PerpendicularVector(normalized2);
            float   d           = Vector2.Distance(vector4, vector33) / 5f;
            (sLeaser.sprites[this.TentacleSprite()] as TriangleMesh).MoveVertice(j * 4, vector33 - a3 * 2f * (num55 + this.tail[j].StretchedRad) * 0.5f + normalized2 * d - camPos);
            (sLeaser.sprites[this.TentacleSprite()] as TriangleMesh).MoveVertice(j * 4 + 1, vector33 + a3 * 2f * (num55 + this.tail[j].StretchedRad) * 0.5f + normalized2 * d - camPos);
            if (j < this.tail.Length - 1)
            {
                (sLeaser.sprites[this.TentacleSprite()] as TriangleMesh).MoveVertice(j * 4 + 2, vector4 - a3 * 2f * this.tail[j].StretchedRad - normalized2 * d - camPos);
                (sLeaser.sprites[this.TentacleSprite()] as TriangleMesh).MoveVertice(j * 4 + 3, vector4 + a3 * 2f * this.tail[j].StretchedRad - normalized2 * d - camPos);
            }
            else
            {
                (sLeaser.sprites[this.TentacleSprite()] as TriangleMesh).MoveVertice(j * 4 + 2, vector4 - camPos);
            }
            num55    = this.tail[j].StretchedRad;
            vector33 = vector4;
        }

        float wingLength = Mathf.Abs(Mathf.Clamp(8f - (Mathf.Abs(Custom.AimFromOneVectorToAnother(new Vector2(0f, 0f), this.zRotation) / 180f) * 9f), 0f, 8f) - 4f) / 4f;

        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < this.wings.GetLength(1); j++)
            {
                vector33 = Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker);
                num55    = this.fish.bodyChunks[0].rad;
                Vector2 vector4     = Vector2.Lerp(this.wings[i, j].lastPos, this.wings[i, j].pos, timeStacker);
                Vector2 normalized2 = (vector4 - vector33).normalized;
                Vector2 a3          = Custom.PerpendicularVector(normalized2);
                float   d           = Vector2.Distance(vector4, vector33) / 5f;
                (sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4, vector33 - a3 * (num55 + this.wings[i, j].StretchedRad) * 0.5f + normalized2 * d - camPos);
                (sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4 + 1, vector33 + a3 * (num55 + this.wings[i, j].StretchedRad) * 0.5f + normalized2 * d - camPos);
                //(sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4 + 1, Vector2.Lerp(this.fish.bodyChunks[0].lastPos, this.fish.bodyChunks[0].pos, timeStacker) - camPos);
                if (j < this.wings.GetLength(1) - 1)
                {
                    (sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4 + 2, vector4 - a3 * this.wings[i, j].StretchedRad - normalized2 * d - camPos);
                    (sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4 + 3, vector4 + a3 * this.wings[i, j].StretchedRad - normalized2 * d - camPos);
                    //(sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4 + 3, Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker) - camPos);
                }
                else
                {
                    (sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).MoveVertice(j * 4 + 2, vector4 - camPos);
                }
                //(sLeaser.sprites[this.WingSprite(i)] as TriangleMesh).scale = wingLength;
                num55    = this.wings[i, j].StretchedRad;
                vector33 = vector4;
            }
        }

        for (int i = 0; i < 2; i++)
        {
            //Vector2 a2 = vector2 + normalized * 13f + a * Mathf.Cos(num2 / 360f * 3.14159274f * 2f) * Mathf.Lerp(7.5f, 5f, this.airEyes) * ((i == 0 != num2 > 0f) ? 1f : -1f);
            sLeaser.sprites[this.FlipperSprite(i)].x        = Mathf.Lerp(this.flippers[i].lastPos.x, this.flippers[i].pos.x, timeStacker) - camPos.x;
            sLeaser.sprites[this.FlipperSprite(i)].y        = Mathf.Lerp(this.flippers[i].lastPos.y, this.flippers[i].pos.y, timeStacker) - camPos.y;
            sLeaser.sprites[this.FlipperSprite(i)].rotation = Custom.AimFromOneVectorToAnother(Vector2.Lerp(this.flippers[i].lastPos, this.flippers[i].pos, timeStacker), vector2) - 90f;
            sLeaser.sprites[this.FlipperSprite(i)].scaleY   = Mathf.Sign(Custom.DistanceToLine(Vector2.Lerp(this.flippers[i].lastPos, this.flippers[i].pos, timeStacker), vector2 - normalized, vector2 + normalized)) * this.fish.iVars.flipperSize;
            sLeaser.sprites[this.FlipperSprite(i)].scaleX   = Mathf.Lerp(Vector2.Distance(Vector2.Lerp(this.flippers[i].lastPos, this.flippers[i].pos, timeStacker), vector2) / this.flipperGraphWidth, this.fish.iVars.flipperSize, 0.5f);
            Vector2 vector3 = Vector2.Lerp(this.fish.bodyChunks[1].lastPos, this.fish.bodyChunks[1].pos, timeStacker);
            float   num5    = this.fish.bodyChunks[1].rad;
            for (int k = 0; k < this.fish.iVars.whiskers; k++)
            {
                for (int l = 0; l < 2; l++)
                {
                    Vector2 vector5 = Vector2.Lerp(this.whiskers[l, k].lastPos, this.whiskers[l, k].pos, timeStacker);
                    Vector2 a4      = this.whiskerDir(l, k, vector, normalized);
                    Vector2 vector6 = Vector2.Lerp(this.fish.bodyChunks[2].lastPos, this.fish.bodyChunks[2].pos, timeStacker) + normalized * Mathf.Lerp(10f, 5f, this.whiskerProps[k, 3]) + a4 * 5f * this.whiskerProps[k, 3];
                    a4      = (a4 + normalized).normalized;
                    vector3 = vector6;
                    num5    = this.whiskerProps[k, 4];
                    float num6 = 1f;
                    for (int m = 0; m < 4; m++)
                    {
                        Vector2 vector7;
                        if (m < 3)
                        {
                            vector7  = Vector2.Lerp(vector6, vector5, (float)(m + 1) / 4f);
                            vector7 += a4 * num6 * this.whiskerProps[k, 0] * 0.2f;
                        }
                        else
                        {
                            vector7 = vector5;
                        }
                        num6 *= 0.7f;
                        Vector2 normalized3 = (vector7 - vector3).normalized;
                        Vector2 a5          = Custom.PerpendicularVector(normalized3);
                        float   d2          = Vector2.Distance(vector7, vector3) / ((m != 0) ? 5f : 1f);
                        float   num7        = Custom.LerpMap((float)m, 0f, 3f, this.whiskerProps[k, 4], 0.5f);
                        (sLeaser.sprites[this.WhiskerSprite(l, k)] as TriangleMesh).MoveVertice(m * 4, vector3 - a5 * (num7 + num5) * 0.5f + normalized3 * d2 - camPos);
                        (sLeaser.sprites[this.WhiskerSprite(l, k)] as TriangleMesh).MoveVertice(m * 4 + 1, vector3 + a5 * (num7 + num5) * 0.5f + normalized3 * d2 - camPos);
                        if (m < 3)
                        {
                            (sLeaser.sprites[this.WhiskerSprite(l, k)] as TriangleMesh).MoveVertice(m * 4 + 2, vector7 - a5 * num7 - normalized3 * d2 - camPos);
                            (sLeaser.sprites[this.WhiskerSprite(l, k)] as TriangleMesh).MoveVertice(m * 4 + 3, vector7 + a5 * num7 - normalized3 * d2 - camPos);
                        }
                        else
                        {
                            (sLeaser.sprites[this.WhiskerSprite(l, k)] as TriangleMesh).MoveVertice(m * 4 + 2, vector7 + normalized3 * 2.1f - camPos);
                        }
                        num5    = num7;
                        vector3 = vector7;
                    }
                }
            }
        }
    }
    public override void Update()
    {
        base.Update();
        if (this.culled)
        {
            return;
        }
        for (int i = 0; i < this.danglers.Length; i++)
        {
            this.danglers[i].Update();
        }
        if (this.fish.Consious)
        {
            this.swim -= Custom.LerpMap(this.fish.swimSpeed, 1.6f, 5f, 0.0333333351f, 0.06666667f);
        }
        this.tail[0].connectedPoint     = new Vector2?(this.fish.bodyChunks[1].pos);
        this.wings[0, 0].connectedPoint = new Vector2?(this.fish.bodyChunks[0].pos);
        this.wings[1, 0].connectedPoint = new Vector2?(this.fish.bodyChunks[0].pos);
        Vector2 vector = Custom.DirVec(this.fish.bodyChunks[1].pos, this.fish.bodyChunks[0].pos);
        Vector2 a      = Custom.PerpendicularVector(vector);

        this.lastZRotation = this.zRotation;
        if (Mathf.Abs(vector.x) > 0.5f && this.fish.Consious)
        {
            this.zRotation = Vector2.Lerp(this.zRotation, new Vector2((vector.x <= 0f) ? 1f : -1f, 0f), 0.2f);
        }
        else
        {
            this.zRotation = Vector2.Lerp(this.zRotation, -vector, 0.5f);
        }
        this.zRotation = this.zRotation.normalized;
        if (this.fish.Consious)
        {
            float num = 1f - this.fish.bodyChunks[1].submersion;
            if (this.airEyes < num)
            {
                this.airEyes = Mathf.Min(this.airEyes + 0.1f, num);
            }
            else
            {
                this.airEyes = Mathf.Max(this.airEyes - 0.0333333351f, num);
            }
        }
        for (int i = 0; i < 2; i++)
        {
            this.flippers[i].Update();
            this.flippers[i].ConnectToPoint(this.fish.bodyChunks[1].pos, (this.flipperGraphWidth + 7f) * this.fish.iVars.flipperSize, false, 0f, this.fish.bodyChunks[1].vel, 0.3f, 0f);
            Vector2 vector2 = a * this.zRotation.y * ((i != 0) ? 1f : -1f);
            vector2 += new Vector2(0f, -0.5f) * Mathf.Abs(this.zRotation.x);
            vector2 += vector * this.fish.iVars.flipperOrientation * 1.5f;
            if (this.fish.Consious)
            {
                if (i == 0 == this.zRotation.x < 0f)
                {
                    vector2 += vector * Mathf.Sin(this.swim * 3.14159274f * 2f) * 0.3f * (1f - this.fish.jetActive);
                }
                else
                {
                    vector2 += vector * Mathf.Cos(this.swim * 3.14159274f * 2f) * 0.3f * (1f - this.fish.jetActive);
                }
                vector2 = Vector2.Lerp(vector2, -vector, this.fish.jetActive * this.fish.jetWater);
            }
            this.flippers[i].vel += (this.fish.bodyChunks[1].pos + vector2 * (this.flipperGraphWidth + 7f) * this.fish.iVars.flipperSize - this.flippers[i].pos) / ((!this.fish.Consious) ? 16f : 8f);
            if (this.fish.room.PointSubmerged(this.flippers[i].pos))
            {
                this.flippers[i].vel *= 0.9f;
            }
            else
            {
                GenericBodyPart genericBodyPart = this.flippers[i];
                genericBodyPart.vel.y = genericBodyPart.vel.y - 0.6f;
            }
            if (this.fish.iVars.whiskers > 0)
            {
                for (int j = 0; j < this.fish.iVars.whiskers; j++)
                {
                    this.whiskers[i, j].vel += this.whiskerDir(i, j, this.zRotation, vector) * this.whiskerProps[j, 2];
                    if (this.fish.room.PointSubmerged(this.whiskers[i, j].pos))
                    {
                        this.whiskers[i, j].vel *= 0.8f;
                    }
                    else
                    {
                        GenericBodyPart genericBodyPart2 = this.whiskers[i, j];
                        genericBodyPart2.vel.y = genericBodyPart2.vel.y - 0.6f;
                    }
                    this.whiskers[i, j].Update();
                    this.whiskers[i, j].ConnectToPoint(this.fish.bodyChunks[2].pos - vector * 5f + this.whiskerDir(i, j, this.zRotation, vector) * 5f, this.whiskerProps[j, 0], false, 0f, this.fish.bodyChunks[2].vel, 0f, 0f);
                }
            }

            for (int x = 0; x < 2; x++)
            {
                for (int k = 0; k < this.wings.GetLength(1); k++)
                {
                    Vector2 look = Custom.PerpendicularVector(Custom.DirVec(this.fish.bodyChunks[1].pos, this.fish.bodyChunks[0].pos));
                    if (x == 0)
                    {
                        look = -look;
                    }
                    float push = Custom.AimFromOneVectorToAnother(this.fish.bodyChunks[0].pos + look, this.fish.bodyChunks[0].pos);
                    this.wings[x, k].Update();
                    float num2 = Mathf.InverseLerp(0f, (float)(this.wings.GetLength(1) - 1), (float)k);
                    if (!Custom.DistLess(this.wings[x, k].pos, this.fish.bodyChunks[1].pos, 15f * (float)(k + 1)))
                    {
                        this.wings[x, k].pos = this.fish.bodyChunks[1].pos + Custom.DirVec(this.fish.bodyChunks[1].pos, this.wings[x, k].pos) * 15f * (float)(k + 1);
                    }
                    float num3 = this.fish.jetActive;
                    if (this.fish.room.PointSubmerged(this.wings[x, k].pos))
                    {
                        this.wings[x, k].vel *= 0.7f;
                        num3 = Mathf.Lerp(num3, 0f, 0.5f);
                    }
                    else
                    {
                        TailSegment wingSegment = this.wings[x, k];
                        wingSegment.vel.y = wingSegment.vel.y - 0.9f * Mathf.Pow((float)k / (float)(this.wings.GetLength(1) - 1), 3f);
                    }
                    this.wings[x, k].vel += a * Mathf.Sin((this.swim + (float)k / 5f) * 3.14159274f * 2f) * ((i != 0) ? -1f : 1f) * Mathf.Pow(1f - num2, 2f) * Custom.LerpMap(this.fish.swimSpeed, 1.6f, 5f, 8f, 16f) * (1f - num3);
                    this.wings[x, k].vel -= look * (0.2f * (1f - num3) + Mathf.Pow(Mathf.InverseLerp(0.5f, 0f, num2), 2f) * Mathf.Lerp(27f, 11f, num3));
                    float num4 = 30f + Mathf.Sin(Mathf.Pow(num2, 1f) * 3.14159274f * -2f) * -100f;
                    this.wings[x, k].vel          -= Custom.DegToVec(push + num4 * ((i != 0) ? -1f : 1f)) * Mathf.Lerp(12f, 6f, num2) * num3;
                    this.wings[x, k].connectionRad = Mathf.Lerp(10f, 0.5f, Mathf.Lerp(0f, num3, Mathf.Pow(num2, 0.2f))) * Mathf.Lerp(0.5f, 1.5f, this.fish.iVars.tentacleLength);
                    this.wings[x, k].rad           = Mathf.Lerp(this.TentacleContour(num2, k), Mathf.Lerp(8f, 2f, num2) * (0.5f + 0.5f * this.fish.jetWater), num3) * Mathf.Lerp(0.7f, 1.2f, this.fish.iVars.tentacleFatness);
                }
            }
            for (int k = 0; k < this.tail.Length; k++)
            {
                this.tail[k].Update();
                float num2 = Mathf.InverseLerp(0f, (float)(this.tail.Length - 1), (float)k);
                if (!Custom.DistLess(this.tail[k].pos, this.fish.bodyChunks[1].pos, 15f * (float)(k + 1)))
                {
                    this.tail[k].pos = this.fish.bodyChunks[1].pos + Custom.DirVec(this.fish.bodyChunks[1].pos, this.tail[k].pos) * 15f * (float)(k + 1);
                }
                float num3 = this.fish.jetActive;
                if (this.fish.room.PointSubmerged(this.tail[k].pos))
                {
                    this.tail[k].vel *= 0.7f;
                    num3              = Mathf.Lerp(num3, 0f, 0.5f);
                }
                else
                {
                    TailSegment tailSegment = this.tail[k];
                    tailSegment.vel.y = tailSegment.vel.y - 0.9f * Mathf.Pow((float)k / (float)(this.tail.Length - 1), 3f);
                }
                this.tail[k].vel += a * Mathf.Sin((this.swim + (float)k / 5f) * 3.14159274f * 2f) * ((i != 0) ? -1f : 1f) * Mathf.Pow(1f - num2, 2f) * Custom.LerpMap(this.fish.swimSpeed, 1.6f, 5f, 8f, 16f) * (1f - num3);
                this.tail[k].vel -= vector * (0.2f * (1f - num3) + Mathf.Pow(Mathf.InverseLerp(0.5f, 0f, num2), 2f) * Mathf.Lerp(27f, 11f, num3));
                float num4 = 30f + Mathf.Sin(Mathf.Pow(num2, 1f) * 3.14159274f * -2f) * -100f;
                this.tail[k].vel          -= Custom.DegToVec(Custom.AimFromOneVectorToAnother(this.fish.bodyChunks[1].pos, this.fish.bodyChunks[0].pos) + num4 * ((i != 0) ? -1f : 1f)) * Mathf.Lerp(12f, 6f, num2) * num3;
                this.tail[k].connectionRad = Mathf.Lerp(10f, 0.5f, Mathf.Lerp(0f, num3, Mathf.Pow(num2, 0.2f))) * Mathf.Lerp(0.5f, 1.5f, this.fish.iVars.tentacleLength);
                this.tail[k].rad           = Mathf.Lerp(this.TentacleContour(num2, k), Mathf.Lerp(8f, 2f, num2) * (0.5f + 0.5f * this.fish.jetWater), num3) * Mathf.Lerp(0.7f, 1.2f, this.fish.iVars.tentacleFatness);
            }
        }
    }
Пример #12
0
        public override void Update(bool eu)
        {
            base.Update(eu);
            soundLoop.sound = SoundID.None;
            if (base.firstChunk.vel.magnitude > 5f)
            {
                if (base.mode == Mode.Thrown)
                {
                    soundLoop.sound = SoundID.Spear_Thrown_Through_Air_LOOP;
                }
                else if (base.mode == Mode.Free)
                {
                    soundLoop.sound = SoundID.Spear_Spinning_Through_Air_LOOP;
                }
                soundLoop.Volume = Mathf.InverseLerp(5f, 15f, base.firstChunk.vel.magnitude);
            }
            soundLoop.Update();

            lastPivotAtTip = pivotAtTip;
            pivotAtTip     = base.mode == Mode.Thrown || base.mode == Mode.StuckInCreature;



            if (addPoles && room.readyForAI)
            {
                if (abstractArrow.stuckInWallCycles >= 0)
                {
                    room.GetTile(stuckInWall.Value).horizontalBeam = true;
                    for (int i = -1; i < 2; i += 2)
                    {
                        if (!room.GetTile(stuckInWall.Value + new Vector2(20f * (float)i, 0f)).Solid)
                        {
                            room.GetTile(stuckInWall.Value + new Vector2(20f * (float)i, 0f)).horizontalBeam = true;
                        }
                    }
                }
                else
                {
                    room.GetTile(stuckInWall.Value).verticalBeam = true;
                    for (int j = -1; j < 2; j += 2)
                    {
                        if (!room.GetTile(stuckInWall.Value + new Vector2(0f, 20f * (float)j)).Solid)
                        {
                            room.GetTile(stuckInWall.Value + new Vector2(0f, 20f * (float)j)).verticalBeam = true;
                        }
                    }
                }
                addPoles = false;
            }

            switch (base.mode)
            {
            case Mode.Free:
                if (spinning)
                {
                    if (Custom.DistLess(base.firstChunk.pos, base.firstChunk.lastPos, 4f * room.gravity))
                    {
                        stillCounter++;
                    }
                    else
                    {
                        stillCounter = 0;
                    }
                    if (base.firstChunk.ContactPoint.y < 0 || stillCounter > 20)
                    {
                        spinning             = false;
                        rotationSpeed        = 0f;
                        rotation             = Custom.DegToVec(Mathf.Lerp(-45, 45f, Random.value) + 180f);
                        base.firstChunk.vel *= 0f;
                        room.PlaySound(SoundID.Spear_Stick_In_Ground, base.firstChunk);
                    }
                }
                else if (!Custom.DistLess(base.firstChunk.lastPos, base.firstChunk.pos, 6f))
                {
                    SetRandomSpin();
                }
                break;

            case Mode.Thrown:
            {
                base.rotation = firstChunk.vel.normalized;
                if (!Custom.DistLess(thrownPos, base.firstChunk.pos, 560f * Mathf.Max(1f, arrowDamageBonus)) || !(base.firstChunk.ContactPoint == throwDir) || room.GetTile(base.firstChunk.pos).Terrain != 0 || room.GetTile(base.firstChunk.pos + throwDir.ToVector2() * 20f).Terrain != Room.Tile.TerrainType.Solid || ((!Custom.DistLess(thrownPos, base.firstChunk.pos, 140f) && !alwaysStickInWalls)))
                {
                    break;
                }

                bool willStickIntoWall = true;

                foreach (AbstractWorldEntity entity in room.abstractRoom.entities)
                {
                    if (entity is AbstractArrow && (entity as AbstractArrow).realizedObject != null && ((entity as AbstractArrow).realizedObject as Weapon).mode == Mode.StuckInWall && entity.pos.Tile == abstractPhysicalObject.pos.Tile)
                    {
                        willStickIntoWall = false;
                        break;
                    }
                }

                if (willStickIntoWall)
                {
                    for (int k = 0; k < room.roomSettings.placedObjects.Count; k++)
                    {
                        if (room.roomSettings.placedObjects[k].type == PlacedObject.Type.NoSpearStickZone && Custom.DistLess(room.MiddleOfTile(base.firstChunk.pos), room.roomSettings.placedObjects[k].pos, (room.roomSettings.placedObjects[k].data as PlacedObject.ResizableObjectData).Rad))
                        {
                            willStickIntoWall = false;
                            break;
                        }
                    }
                }

                if (willStickIntoWall)
                {
                    stuckInWall = room.MiddleOfTile(base.firstChunk.pos);
                    vibrate     = 10;
                    rotation    = lastRotation;
                    ChangeMode(Mode.StuckInWall);
                    room.PlaySound(SoundID.Spear_Stick_In_Wall, base.firstChunk);
                    base.firstChunk.collideWithTerrain = false;
                }
                break;
            }

            case Mode.StuckInCreature:
                if (!stuckInWall.HasValue)
                {
                    if (stuckInAppendage != null)
                    {
                        setRotation         = Custom.DegToVec(stuckRotation + Custom.VecToDeg(stuckInAppendage.appendage.OnAppendageDirection(stuckInAppendage)));
                        base.firstChunk.pos = stuckInAppendage.appendage.OnAppendagePosition(stuckInAppendage);
                    }
                    else
                    {
                        base.firstChunk.vel = stuckInChunk.vel;
                        if (stuckBodyPart == -1 || !room.BeingViewed || (stuckInChunk.owner as Creature).BodyPartByIndex(stuckBodyPart) == null)
                        {
                            setRotation = Custom.DegToVec(stuckRotation + Custom.VecToDeg(stuckInChunk.Rotation));
                            base.firstChunk.MoveWithOtherObject(eu, stuckInChunk, new Vector2(0f, 0f));
                        }
                        else
                        {
                            setRotation = Custom.DegToVec(stuckRotation + Custom.AimFromOneVectorToAnother(stuckInChunk.pos, (stuckInChunk.owner as Creature).BodyPartByIndex(stuckBodyPart).pos));
                            base.firstChunk.MoveWithOtherObject(eu, stuckInChunk, Vector2.Lerp(stuckInChunk.pos, (stuckInChunk.owner as Creature).BodyPartByIndex(stuckBodyPart).pos, 0.5f) - stuckInChunk.pos);
                        }
                    }
                }
                else
                {
                    if (pinToWallCounter > 0)
                    {
                        pinToWallCounter--;
                    }
                    if (stuckInChunk.vel.magnitude * stuckInChunk.mass > Custom.LerpMap(pinToWallCounter, 160f, 0f, 7f, 2f))
                    {
                        setRotation = (Custom.DegToVec(stuckRotation) + Vector2.ClampMagnitude(stuckInChunk.vel * stuckInChunk.mass * 0.005f, 0.1f)).normalized;
                    }
                    else
                    {
                        setRotation = Custom.DegToVec(stuckRotation);
                    }
                    base.firstChunk.vel *= 0f;
                    base.firstChunk.pos  = stuckInWall.Value;
                    if ((stuckInChunk.owner is Creature && (stuckInChunk.owner as Creature).enteringShortCut.HasValue) || (pinToWallCounter < 160 && Random.value < 0.025f && stuckInChunk.vel.magnitude > Custom.LerpMap(pinToWallCounter, 160f, 0f, 140f, 30f / (1f + stuckInChunk.owner.TotalMass * 0.2f))))
                    {
                        stuckRotation = Custom.Angle(setRotation.Value, stuckInChunk.Rotation);
                        stuckInWall   = null;
                    }
                    else
                    {
                        stuckInChunk.MoveFromOutsideMyUpdate(eu, stuckInWall.Value);
                        stuckInChunk.vel *= 0f;
                    }
                }
                if (stuckInChunk.owner.slatedForDeletetion)
                {
                    ChangeMode(Mode.Free);
                }
                break;

            case Mode.StuckInWall:
                base.firstChunk.pos  = stuckInWall.Value;
                base.firstChunk.vel *= 0f;
                break;
            }

            for (int i = abstractPhysicalObject.stuckObjects.Count - 1; i >= 0; i--)
            {
                if (abstractPhysicalObject.stuckObjects[i] is AbstractPhysicalObject.ImpaledOnSpearStick)
                {
                    if (abstractPhysicalObject.stuckObjects[i].B.realizedObject != null && (abstractPhysicalObject.stuckObjects[i].B.realizedObject.slatedForDeletetion || abstractPhysicalObject.stuckObjects[i].B.realizedObject.grabbedBy.Count > 0))
                    {
                        abstractPhysicalObject.stuckObjects[i].Deactivate();
                    }
                    else if (abstractPhysicalObject.stuckObjects[i].B.realizedObject != null && abstractPhysicalObject.stuckObjects[i].B.realizedObject.room == room)
                    {
                        abstractPhysicalObject.stuckObjects[i].B.realizedObject.firstChunk.MoveFromOutsideMyUpdate(eu, base.firstChunk.pos + rotation * Custom.LerpMap((abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.ImpaledOnSpearStick).onSpearPosition, 0f, 4f, 15f, -15f));
                        abstractPhysicalObject.stuckObjects[i].B.realizedObject.firstChunk.vel *= 0f;
                    }
                }
            }
        }
Пример #13
0
    private static void PlayerGraphics_Update(On.PlayerGraphics.orig_Update orig, PlayerGraphics self)
    {
        //Super.Update()
        self.lastCulled = self.culled;
        self.culled     = self.ShouldBeCulled;
        if (!self.culled && self.lastCulled)
        {
            self.Reset();
        }

        //Update()
        self.lastMarkAlpha = self.markAlpha;
        if (!self.player.dead && self.player.room.game.session is StoryGameSession && (self.player.room.game.session as StoryGameSession).saveState.deathPersistentSaveData.theMark)
        {
            self.markAlpha = Custom.LerpAndTick(self.markAlpha, Mathf.Clamp(Mathf.InverseLerp(30f, 80f, (float)self.player.touchedNoInputCounter) - Random.value * Mathf.InverseLerp(80f, 30f, (float)self.player.touchedNoInputCounter), 0f, 1f) * self.markBaseAlpha, 0.1f, 0.033333335f);
        }
        else
        {
            self.markAlpha = 0f;
        }
        if (self.player.input[1].x != self.player.input[0].x || self.player.input[1].y != self.player.input[0].y)
        {
            self.flail = Mathf.Min(1f, self.flail + 0.33333334f);
        }
        else
        {
            self.flail = Mathf.Max(0f, self.flail - 0.0125f);
        }
        self.lastBreath = self.breath;
        if (!self.player.dead)
        {
            if (self.player.Sleeping)
            {
                self.breath += 0.0125f;
            }
            else
            {
                self.breath += 1f / Mathf.Lerp(60f, 15f, Mathf.Pow(self.player.aerobicLevel, 1.5f));
            }
        }
        if (self.lightSource != null)
        {
            self.lightSource.stayAlive = true;
            self.lightSource.setPos    = new Vector2?(self.player.mainBodyChunk.pos);
            if (self.lightSource.slatedForDeletetion || self.player.room.Darkness(self.player.mainBodyChunk.pos) == 0f)
            {
                self.lightSource = null;
            }
        }
        else if (self.player.room.Darkness(self.player.mainBodyChunk.pos) > 0f && self.player.glowing)
        {
            self.lightSource = new LightSource(self.player.mainBodyChunk.pos, false, Color.Lerp(new Color(1f, 1f, 1f), PlayerGraphics.SlugcatColor(self.player.playerState.slugcatCharacter), 0.5f), self.player);
            self.lightSource.requireUpKeep = true;
            self.lightSource.setRad        = new float?(300f);
            self.lightSource.setAlpha      = new float?(1f);
            self.player.room.AddObject(self.lightSource);
        }
        if (self.malnourished > 0f && !self.player.Malnourished)
        {
            self.malnourished = Mathf.Max(0f, self.malnourished - 0.005f);
        }
        if (self.player.bodyMode == Player.BodyModeIndex.Stand && self.player.input[0].x != 0)
        {
            self.spearDir = Mathf.Clamp(self.spearDir + (float)self.player.input[0].x * 0.1f, -1f, 1f);
        }
        else if (self.spearDir < 0f)
        {
            self.spearDir = Mathf.Min(self.spearDir + 0.05f, 0f);
        }
        else if (self.spearDir > 0f)
        {
            self.spearDir = Mathf.Max(self.spearDir - 0.05f, 0f);
        }
        if (self.player.room.world.rainCycle.RainApproaching < 1f && Random.value > self.player.room.world.rainCycle.RainApproaching && Random.value < 0.009803922f && (self.player.room.roomSettings.DangerType == RoomRain.DangerType.Rain || self.player.room.roomSettings.DangerType == RoomRain.DangerType.FloodAndRain))
        {
            self.objectLooker.LookAtPoint(new Vector2(self.player.room.PixelWidth * Random.value, self.player.room.PixelHeight + 100f), (1f - self.player.room.world.rainCycle.RainApproaching) * 0.6f);
        }
        float num = 0f;

        if (self.player.Consious && self.objectLooker.currentMostInteresting != null && self.objectLooker.currentMostInteresting is Creature)
        {
            CreatureTemplate.Relationship relationship = self.player.abstractCreature.creatureTemplate.CreatureRelationship((self.objectLooker.currentMostInteresting as Creature).abstractCreature.creatureTemplate);
            if (relationship.type == CreatureTemplate.Relationship.Type.Afraid && !(self.objectLooker.currentMostInteresting as Creature).dead)
            {
                float from = Mathf.Lerp(40f, 250f, relationship.intensity);
                num = Mathf.InverseLerp(from, 10f, Vector2.Distance(self.player.mainBodyChunk.pos, self.objectLooker.mostInterestingLookPoint) * ((!self.player.room.VisualContact(self.player.mainBodyChunk.pos, self.objectLooker.mostInterestingLookPoint)) ? 1.5f : 1f));
                if ((self.objectLooker.currentMostInteresting as Creature).abstractCreature.abstractAI != null && (self.objectLooker.currentMostInteresting as Creature).abstractCreature.abstractAI.RealAI != null)
                {
                    num *= (self.objectLooker.currentMostInteresting as Creature).abstractCreature.abstractAI.RealAI.CurrentPlayerAggression(self.player.abstractCreature);
                }
            }
        }
        if (!self.player.Consious)
        {
            self.objectLooker.LookAtNothing();
            self.blink = 10;
        }
        if (self.DEBUGLABELS != null)
        {
            self.DEBUGLABELS[0].label.text = self.player.bodyMode.ToString() + " " + self.player.animation.ToString();
            self.DEBUGLABELS[1].label.text = string.Concat(new object[]
            {
                "XPOS: ",
                self.player.mainBodyChunk.pos.x,
                " YPOS: ",
                self.player.mainBodyChunk.pos.y
            });
            self.DEBUGLABELS[2].label.text = string.Concat(new object[]
            {
                "XPOS: ",
                self.player.bodyChunks[1].pos.x,
                " YPOS: ",
                self.player.bodyChunks[1].pos.y
            });
        }
        for (int i = 0; i < self.owner.bodyChunks.Length; i++)
        {
            self.drawPositions[i, 1] = self.drawPositions[i, 0];
        }
        self.drawPositions[0, 0] = self.owner.bodyChunks[0].pos;
        self.drawPositions[1, 0] = self.owner.bodyChunks[1].pos;
        int   num2 = 0;
        bool  flag = false;
        float num3 = 1f;

        switch (self.player.bodyMode)
        {
        case Player.BodyModeIndex.Default:
            if (self.player.animation == Player.AnimationIndex.AntlerClimb)
            {
                num2 = 2;
            }
            else if (self.player.animation == Player.AnimationIndex.LedgeGrab)
            {
                self.legsDirection.y        = self.legsDirection.y - 1f;
                self.drawPositions[0, 0].x -= (float)self.player.flipDirection * 5f;
            }
            else
            {
                num3 = 0f;
            }
            break;

        case Player.BodyModeIndex.Crawl:
        {
            num2 = 1;
            float num4 = Mathf.Sin((float)self.player.animationFrame / 21f * 2f * 3.1415927f);
            float num5 = Mathf.Cos((float)self.player.animationFrame / 14f * 2f * 3.1415927f);
            float num6 = (self.player.superLaunchJump <= 19) ? 1f : 0f;
            self.drawPositions[0, 0].x += num5 * (float)self.player.flipDirection * 2f;
            self.drawPositions[0, 0].y -= num4 * -1.5f - 3f;
            GenericBodyPart genericBodyPart = self.head;
            genericBodyPart.vel.y = genericBodyPart.vel.y - (num4 * -0.5f - 0.5f);
            GenericBodyPart genericBodyPart2 = self.head;
            genericBodyPart2.vel.x      = genericBodyPart2.vel.x + ((self.owner.bodyChunks[0].pos.x >= self.owner.bodyChunks[1].pos.x) ? 1f : -1f);
            self.drawPositions[1, 0].x += -3f * num4 * (float)self.player.flipDirection;
            self.drawPositions[1, 0].y -= num5 * 1.5f - 7f + 3f * num6;
            break;
        }

        case Player.BodyModeIndex.Stand:
            self.drawPositions[0, 0].x += (float)self.player.flipDirection * 6f * Mathf.Clamp(Mathf.Abs(self.owner.bodyChunks[1].vel.x) - 0.2f, 0f, 1f);
            self.drawPositions[0, 0].y += Mathf.Cos((float)self.player.animationFrame / 6f * 2f * 3.1415927f) * 2f;
            self.drawPositions[1, 0].x -= (float)self.player.flipDirection * (1.5f - (float)self.player.animationFrame / 6f);
            self.drawPositions[1, 0].y += 2f + Mathf.Sin((float)self.player.animationFrame / 6f * 2f * 3.1415927f) * 4f;
            flag = (Mathf.Abs(self.owner.bodyChunks[0].vel.x) > 2f && Mathf.Abs(self.owner.bodyChunks[1].vel.x) > 2f);
            num3 = 1f - Mathf.Clamp((Mathf.Abs(self.owner.bodyChunks[1].vel.x) - 1f) * 0.5f, 0f, 1f);
            break;

        case Player.BodyModeIndex.WallClimb:
        {
            num2 = 1;
            self.legsDirection.y        = self.legsDirection.y - 1f;
            self.drawPositions[0, 0].y += 2f;
            self.drawPositions[0, 0].x -= (float)self.player.flipDirection * ((self.owner.bodyChunks[1].ContactPoint.y >= 0) ? 5f : 3f);
            GenericBodyPart genericBodyPart3 = self.head;
            genericBodyPart3.vel.y = genericBodyPart3.vel.y - (float)self.player.flipDirection * 5f;
            break;
        }

        case Player.BodyModeIndex.ClimbingOnBeam:
            num2 = 2;
            switch (self.player.animation)
            {
            case Player.AnimationIndex.GetUpOnBeam:
                self.disbalanceAmount = 70f;
                break;

            case Player.AnimationIndex.StandOnBeam:
                num2 = 0;
                self.drawPositions[1, 0].y += 3f;
                flag = (Mathf.Abs(self.owner.bodyChunks[0].vel.x) > 2f && Mathf.Abs(self.owner.bodyChunks[1].vel.x) > 2f);
                num3 = 1f - Mathf.Clamp((Mathf.Abs(self.owner.bodyChunks[1].vel.x) - 1f) * 0.3f, 0f, 1f);
                if (flag)
                {
                    TailSegment tailSegment = self.tail[0];
                    tailSegment.vel.x = tailSegment.vel.x - self.owner.bodyChunks[0].vel.x * 2f;
                    TailSegment tailSegment2 = self.tail[0];
                    tailSegment2.vel.y = tailSegment2.vel.y + 1.5f;
                    TailSegment tailSegment3 = self.tail[1];
                    tailSegment3.vel.x = tailSegment3.vel.x - self.owner.bodyChunks[0].vel.x * 0.2f;
                    TailSegment tailSegment4 = self.tail[1];
                    tailSegment4.vel.y = tailSegment4.vel.y + 0.5f;
                }
                break;

            case Player.AnimationIndex.ClimbOnBeam:
                self.drawPositions[0, 0].x += (float)self.player.flipDirection * 2.5f + (float)self.player.flipDirection * 0.5f * Mathf.Sin((float)self.player.animationFrame / 20f * 3.1415927f * 2f);
                self.drawPositions[1, 0].x += (float)self.player.flipDirection * 2.5f * Mathf.Cos((float)self.player.animationFrame / 20f * 3.1415927f * 2f);
                break;

            case Player.AnimationIndex.GetUpToBeamTip:
                self.disbalanceAmount = 120f;
                break;
            }
            break;

        case Player.BodyModeIndex.Swimming:
            if (self.player.animation == Player.AnimationIndex.DeepSwim || self.player.input[0].x != 0)
            {
                self.drawPositions[1, 0] += Custom.PerpendicularVector(Custom.DirVec(self.player.bodyChunks[0].pos, self.player.bodyChunks[1].pos)) * Mathf.Sin(self.player.swimCycle * 2f * 3.1415927f) * 5f;
            }
            break;

        case Player.BodyModeIndex.ZeroG:
            self.disbalanceAmount = Mathf.Max(self.disbalanceAmount, 70f * Mathf.InverseLerp(0.8f, 1f, self.flail));
            break;
        }
        switch (self.player.animation)
        {
        case Player.AnimationIndex.CorridorTurn:
            self.drawPositions[0, 0] += Custom.DegToVec(Random.value * 360f) * 3f * Random.value;
            self.drawPositions[1, 0] += Custom.DegToVec(Random.value * 360f) * 2f * Random.value;
            self.blink = 5;
            break;

        case Player.AnimationIndex.Roll:
        case Player.AnimationIndex.Flip:
        {
            float   num7 = 6f;
            Vector2 a    = Custom.DirVec(self.player.bodyChunks[0].pos, self.player.bodyChunks[1].pos);
            for (int j = 0; j < self.tail.Length; j++)
            {
                self.tail[j].vel += a * num7;
                num7             /= 1.7f;
            }
            break;
        }
        }
        if (self.player.bodyMode == Player.BodyModeIndex.Default && self.player.animation == Player.AnimationIndex.None && self.owner.bodyChunks[0].ContactPoint.x == 0 && self.owner.bodyChunks[0].ContactPoint.y == 0 && self.owner.bodyChunks[1].ContactPoint.x == 0 && self.owner.bodyChunks[1].ContactPoint.y == 0)
        {
            self.airborneCounter += self.owner.bodyChunks[0].vel.magnitude;
        }
        else
        {
            self.airborneCounter = 0f;
        }
        if (self.player.bodyMode == Player.BodyModeIndex.ClimbingOnBeam && (self.player.animation == Player.AnimationIndex.BeamTip || self.player.animation == Player.AnimationIndex.StandOnBeam))
        {
            if (Mathf.Abs(self.owner.bodyChunks[0].vel.x) > 2f)
            {
                self.disbalanceAmount += ((self.player.animation != Player.AnimationIndex.BeamTip) ? 3f : 17f);
            }
            else
            {
                self.disbalanceAmount -= 1f;
            }
            self.disbalanceAmount = Mathf.Clamp(self.disbalanceAmount, 0f, 120f);
            self.balanceCounter  += 1f + self.disbalanceAmount / 40f * (1f + Random.value);
            if (self.balanceCounter > 300f)
            {
                self.balanceCounter -= 300f;
            }
            float num8 = Mathf.Sin(self.balanceCounter / 300f * 3.1415927f * 2f) / (Mathf.Abs(self.owner.bodyChunks[1].vel.x) + 1f);
            self.drawPositions[0, 0].x += num8 * (self.disbalanceAmount + 20f) * 0.08f;
            self.drawPositions[0, 0].y += num8 * self.disbalanceAmount * 0.02f;
            TailSegment tailSegment5 = self.tail[0];
            tailSegment5.vel.x = tailSegment5.vel.x + num8 * (self.disbalanceAmount + 20f) * 0.1f;
            TailSegment tailSegment6 = self.tail[1];
            tailSegment6.vel.x = tailSegment6.vel.x + num8 * (self.disbalanceAmount + 20f) * 0.04f;
        }
        if (self.player.bodyMode == Player.BodyModeIndex.ZeroG)
        {
            self.disbalanceAmount -= 1f;
            self.disbalanceAmount  = Mathf.Clamp(self.disbalanceAmount, 0f, 120f);
            self.balanceCounter   += 1f + self.disbalanceAmount / 40f * (1f + Random.value);
            if (self.balanceCounter > 300f)
            {
                self.balanceCounter -= 300f;
            }
            float   d      = Mathf.Sin(self.balanceCounter / 300f * 3.1415927f * 2f);
            Vector2 vector = Custom.DirVec(self.player.bodyChunks[1].pos, self.player.mainBodyChunk.pos);
            Vector2 a2     = Custom.PerpendicularVector(vector);
            self.drawPositions[0, 0] += a2 * d * (self.disbalanceAmount + 20f) * 0.08f;
            self.tail[0].vel         -= a2 * d * (self.disbalanceAmount + 20f) * 0.1f + vector * self.disbalanceAmount * 0.1f;
            self.tail[1].vel         -= a2 * d * (self.disbalanceAmount + 20f) * 0.04f + vector * self.disbalanceAmount * 0.04f;
        }
        if (self.player.Consious && self.player.standing && num > 0.5f)
        {
            self.drawPositions[0, 0] += Custom.DirVec(self.objectLooker.mostInterestingLookPoint, self.player.bodyChunks[0].pos) * 3.4f * Mathf.InverseLerp(0.5f, 1f, num);
            self.head.vel            += Custom.DirVec(self.objectLooker.mostInterestingLookPoint, self.head.pos) * 1.4f * Mathf.InverseLerp(0.5f, 1f, num);
        }
        if (num > 0f)
        {
            self.tail[0].vel        += Custom.DirVec(self.objectLooker.mostInterestingLookPoint, self.drawPositions[1, 0]) * 5f * num;
            self.tail[1].vel        += Custom.DirVec(self.objectLooker.mostInterestingLookPoint, self.drawPositions[1, 0]) * 3f * num;
            self.player.aerobicLevel = Mathf.Max(self.player.aerobicLevel, Mathf.InverseLerp(0.5f, 1f, num) * 0.9f);
        }
        Vector2 vector2 = self.owner.bodyChunks[0].pos;

        if (flag)
        {
            vector2    = self.owner.bodyChunks[1].pos;
            vector2.y -= 4f;
            vector2.x += (float)self.player.flipDirection * 16f * Mathf.Clamp(Mathf.Abs(self.owner.bodyChunks[1].vel.x) - 0.2f, 0f, 1f);
        }
        Vector2 pos  = self.owner.bodyChunks[1].pos;
        float   num9 = 28f;

        self.tail[0].connectedPoint = new Vector2?(self.drawPositions[1, 0]);
        for (int k = 0; k < self.tail.Length; k++)
        {
            self.tail[k].Update();
            self.tail[k].vel *= Mathf.Lerp(0.75f, 0.95f, num3 * (1f - self.owner.bodyChunks[1].submersion));
            TailSegment tailSegment7 = self.tail[k];
            tailSegment7.vel.y = tailSegment7.vel.y - Mathf.Lerp(0.1f, 0.5f, num3) * (1f - self.owner.bodyChunks[1].submersion) * self.owner.room.gravity;
            num3 = (num3 * 10f + 1f) / 11f;
            if (!Custom.DistLess(self.tail[k].pos, self.owner.bodyChunks[1].pos, 9f * (float)(k + 1)))
            {
                self.tail[k].pos = self.owner.bodyChunks[1].pos + Custom.DirVec(self.owner.bodyChunks[1].pos, self.tail[k].pos) * 9f * (float)(k + 1);
            }
            self.tail[k].vel += Custom.DirVec(vector2, self.tail[k].pos) * num9 / Vector2.Distance(vector2, self.tail[k].pos);
            num9             *= 0.5f;
            vector2           = pos;
            pos = self.tail[k].pos;
        }
        if (self.player.swallowAndRegurgitateCounter > 15 && self.player.swallowAndRegurgitateCounter % 10 == 0)
        {
            self.blink = Math.Max(self.blink, Random.Range(-5, 8));
        }
        if (self.swallowing > 0)
        {
            self.swallowing--;
            self.blink = 5;
            self.drawPositions[0, 0] = Vector2.Lerp(self.drawPositions[0, 0], self.drawPositions[1, 0], 0.4f * Mathf.Sin((float)self.swallowing / 12f * 3.1415927f));
        }
        else if ((self.player.objectInStomach != null || KarmaAppetite_ExtraInventory.HasSomethingInInventory(self.player)) && self.player.swallowAndRegurgitateCounter > 0)         //Head movement on spit
        {
            if (self.player.swallowAndRegurgitateCounter > 30)
            {
                self.blink = 5;
            }
            float num10 = Mathf.InverseLerp(0f, 110f, (float)self.player.swallowAndRegurgitateCounter);
            float num11 = (float)self.player.swallowAndRegurgitateCounter / Mathf.Lerp(30f, 15f, num10);
            if (self.player.standing)
            {
                self.drawPositions[0, 0].y += Mathf.Sin(num11 * 3.1415927f * 2f) * num10 * 2f;
                self.drawPositions[1, 0].y += -Mathf.Sin((num11 + 0.2f) * 3.1415927f * 2f) * num10 * 3f;
            }
            else
            {
                self.drawPositions[0, 0].y += Mathf.Sin(num11 * 3.1415927f * 2f) * num10 * 3f;
                self.drawPositions[0, 0].x += Mathf.Cos(num11 * 3.1415927f * 2f) * num10 * 1f;
                self.drawPositions[1, 0].y += Mathf.Sin((num11 + 0.2f) * 3.1415927f * 2f) * num10 * 2f;
                self.drawPositions[1, 0].x += -Mathf.Cos(num11 * 3.1415927f * 2f) * num10 * 3f;
            }
        }
        self.blink--;
        if (self.blink < -Random.Range(2, 1800))
        {
            self.blink = Random.Range(3, Random.Range(3, 10));
        }
        if (!self.player.dead)
        {
            if (self.player.exhausted)
            {
                if (self.player.aerobicLevel > 0.8f)
                {
                    self.blink = Math.Max(self.blink, 1);
                }
                else if (Random.value < 0.02f)
                {
                    self.blink = Math.Max(self.blink, Random.Range(10, 20));
                }
            }
            if (self.player.lungsExhausted || self.player.exhausted)
            {
                self.objectLooker.LookAtNothing();
                GenericBodyPart genericBodyPart4 = self.head;
                genericBodyPart4.vel.y      = genericBodyPart4.vel.y + Mathf.Sin(self.player.swimCycle * 3.1415927f * 2f) * ((!self.player.lungsExhausted) ? 0.25f : 1f);
                self.drawPositions[0, 0].y += Mathf.Sin(self.player.swimCycle * 3.1415927f * 2f) * ((!self.player.lungsExhausted) ? 0.75f : 2.5f);
                self.blink = 1;
            }
        }
        if (Random.value < 0.1f)
        {
            self.objectLooker.Update();
        }
        if (Random.value < 0.0025f)
        {
            self.objectLooker.LookAtNothing();
        }
        self.lastLookDir = self.lookDirection;
        if (self.player.Consious && self.objectLooker.looking)
        {
            self.lookDirection = Custom.DirVec(self.head.pos, self.objectLooker.mostInterestingLookPoint);
        }
        else
        {
            self.lookDirection *= 0f;
        }
        if (num > 0.86f)
        {
            self.blink          = 5;
            self.lookDirection *= -1f;
        }
        if (self.player.grasps[0] != null && self.player.grasps[0].grabbed is JokeRifle)
        {
            self.lookDirection = (self.player.grasps[0].grabbed as JokeRifle).aimDir;
        }
        if (self.player.standing)
        {
            if (self.player.input[0].x == 0)
            {
                self.head.vel -= self.lookDirection * 0.5f;
            }
            self.drawPositions[0, 0] -= self.lookDirection * 2f;
        }
        else
        {
            self.head.vel += self.lookDirection;
        }
        Vector2 b = Custom.DirVec(self.drawPositions[1, 0], self.drawPositions[0, 0]) * 3f;

        if (self.player.bodyMode == Player.BodyModeIndex.Crawl)
        {
            b.x *= 2.5f;
        }
        else if (self.player.bodyMode == Player.BodyModeIndex.CorridorClimb && b.y < 0f)
        {
            b.y *= 2f;
        }
        self.head.Update();
        self.head.ConnectToPoint(Vector2.Lerp(self.drawPositions[0, 0], self.drawPositions[1, 0], 0.2f) + b, (self.player.animation != Player.AnimationIndex.HangFromBeam) ? 3f : 0f, false, 0.2f, self.owner.bodyChunks[0].vel, 0.7f, 0.1f);
        self.legs.Update();
        if (self.player.bodyMode == Player.BodyModeIndex.CorridorClimb)
        {
            self.legs.ConnectToPoint(self.owner.bodyChunks[1].pos + Custom.DirVec(self.owner.bodyChunks[0].pos, self.owner.bodyChunks[1].pos) * 4f, 2f, false, 0.25f, self.owner.bodyChunks[1].vel, 0.5f, 0.1f);
            int num12 = Mathf.RoundToInt((270f - Custom.AimFromOneVectorToAnother(self.owner.bodyChunks[1].pos, self.owner.bodyChunks[0].pos)) / 45f);
            int num13 = 10;
            int num14 = 0;
            for (int l = 0; l < 4; l++)
            {
                if (self.owner.room.GetTile(self.owner.room.GetTilePosition(self.owner.bodyChunks[1].pos) + Custom.eightDirections[(l + num12 + 10) % 8]).Terrain == Room.Tile.TerrainType.Solid && self.owner.room.GetTile(self.owner.room.GetTilePosition(self.owner.bodyChunks[1].pos) + Custom.eightDirections[(l + num12 + 14) % 8]).Terrain == Room.Tile.TerrainType.Solid)
                {
                    int num15 = 0;
                    if (l == 1)
                    {
                        num15 = ((self.player.flipDirection != -1) ? 2 : 1);
                    }
                    else if (l == 3)
                    {
                        num15 = ((self.player.flipDirection != 1) ? 2 : 1);
                    }
                    else if (l == 2)
                    {
                        num15 = 3;
                    }
                    if (num15 < num13)
                    {
                        num13 = num15;
                        switch (l)
                        {
                        case 0:
                            num14 = 0;
                            break;

                        case 1:
                            num14 = 45;
                            break;

                        case 2:
                            num14 = ((self.player.flipDirection != -1) ? 90 : -90);
                            break;

                        case 3:
                            num14 = -45;
                            break;
                        }
                    }
                }
            }
            self.legsDirection += Custom.DegToVec(Custom.AimFromOneVectorToAnother(self.owner.bodyChunks[0].pos, self.owner.bodyChunks[1].pos) + (float)num14);
        }
        else if (self.owner.bodyChunks[1].ContactPoint.y == -1 || self.player.animation == Player.AnimationIndex.StandOnBeam)
        {
            self.legs.ConnectToPoint(self.owner.bodyChunks[1].pos + new Vector2(self.legsDirection.x * 8f, 1f), 5f, false, 0.25f, new Vector2(self.owner.bodyChunks[1].vel.x, -10f), 0.5f, 0.1f);
            self.legsDirection.x = self.legsDirection.x - (float)self.owner.bodyChunks[1].onSlope;
            self.legsDirection.y = self.legsDirection.y - 1f;
        }
        else if (self.player.animation == Player.AnimationIndex.BeamTip)
        {
            self.legs.ConnectToPoint(self.owner.bodyChunks[1].pos + new Vector2(0f, -8f), 0f, false, 0.25f, new Vector2(0f, -10f), 0.5f, 0.1f);
            self.legsDirection += Custom.DirVec(self.drawPositions[0, 0], self.owner.room.MiddleOfTile(self.owner.bodyChunks[1].pos) + new Vector2(0f, -10f));
        }
        else if (self.player.animation == Player.AnimationIndex.ClimbOnBeam)
        {
            Vector2 b2 = new Vector2((float)(-(float)self.player.flipDirection) * (5f - Mathf.Sin((float)self.player.animationFrame / 20f * 3.1415927f * 2f)), -16f - 5f * Mathf.Cos((float)self.player.animationFrame / 20f * 3.1415927f * 2f));
            self.legs.ConnectToPoint(self.owner.bodyChunks[0].pos + b2, 0f, false, 0.25f, new Vector2(0f, 0f), 0.5f, 0.1f);
            self.legsDirection.y = self.legsDirection.y - 1f;
        }
        else if (self.player.animation == Player.AnimationIndex.ZeroGSwim || self.player.animation == Player.AnimationIndex.ZeroGPoleGrab)
        {
            self.legs.ConnectToPoint(self.owner.bodyChunks[1].pos + Custom.DirVec(self.owner.bodyChunks[0].pos, self.owner.bodyChunks[1].pos) * 4f, 4f, false, 0f, self.owner.bodyChunks[1].vel, 0.2f, 0f);
            self.legsDirection = Custom.DirVec(self.owner.bodyChunks[0].pos, self.owner.bodyChunks[1].pos);
            self.legs.vel     += self.legsDirection * 0.2f;
        }
        else
        {
            self.legs.ConnectToPoint(self.owner.bodyChunks[1].pos + new Vector2(self.legsDirection.x * 8f, (self.player.animation != Player.AnimationIndex.HangFromBeam) ? -2f : -5f), 4f, false, 0.25f, new Vector2(self.owner.bodyChunks[1].vel.x, -10f), 0.5f, 0.1f);
            self.legsDirection  += self.owner.bodyChunks[1].vel * 0.01f;
            self.legsDirection.y = self.legsDirection.y - 0.05f;
        }
        self.legsDirection.Normalize();
        if (self.player.Consious)
        {
            if (self.throwCounter > 0 && self.thrownObject != null)
            {
                self.hands[self.handEngagedInThrowing].reachingForObject = true;
                self.hands[self.handEngagedInThrowing].absoluteHuntPos   = self.thrownObject.firstChunk.pos;
                if (Custom.DistLess(self.hands[self.handEngagedInThrowing].pos, self.thrownObject.firstChunk.pos, 40f))
                {
                    self.hands[self.handEngagedInThrowing].pos = self.thrownObject.firstChunk.pos;
                }
                else
                {
                    self.hands[self.handEngagedInThrowing].vel += Custom.DirVec(self.hands[self.handEngagedInThrowing].pos, self.thrownObject.firstChunk.pos) * 6f;
                }
                self.hands[1 - self.handEngagedInThrowing].vel -= Custom.DirVec(self.hands[self.handEngagedInThrowing].pos, self.thrownObject.firstChunk.pos) * 3f;
                self.throwCounter--;
            }
            else if (self.player.handOnExternalFoodSource != null)
            {
                int num16 = (self.player.handOnExternalFoodSource.Value.x >= self.player.mainBodyChunk.pos.x) ? 1 : 0;
                self.hands[num16].reachingForObject = true;
                if (self.player.eatExternalFoodSourceCounter < 3)
                {
                    self.hands[num16].absoluteHuntPos = self.head.pos;
                    self.blink = Math.Max(self.blink, 3);
                }
                else
                {
                    self.hands[num16].absoluteHuntPos = self.player.handOnExternalFoodSource.Value;
                }
                self.drawPositions[0, 0] += Custom.DirVec(self.drawPositions[0, 0], self.player.handOnExternalFoodSource.Value) * 5f;
                self.head.vel            += Custom.DirVec(self.drawPositions[0, 0], self.player.handOnExternalFoodSource.Value) * 2f;
            }
            else if ((self.player.grasps[0] != null && self.player.grasps[0].grabbed is TubeWorm) || (self.player.grasps[1] != null && self.player.grasps[1].grabbed is TubeWorm))
            {
                for (int m = 0; m < self.player.grasps.Length; m++)
                {
                    if (self.player.grasps[m] != null && self.player.grasps[m].grabbed is TubeWorm)
                    {
                        self.hands[m].mode            = Limb.Mode.HuntRelativePosition;
                        self.hands[m].relativeHuntPos = new Vector2(5f * ((m != 0) ? 1f : -1f), -10f);
                    }
                }
            }
            else if (self.player.spearOnBack != null && self.player.spearOnBack.counter > 5)
            {
                int num17 = -1;
                int num18 = 0;
                while (num18 < 2 && num17 == -1)
                {
                    if ((self.player.spearOnBack.HasASpear && self.player.grasps[num18] == null) || (!self.player.spearOnBack.HasASpear && self.player.grasps[num18] != null && self.player.grasps[num18].grabbed is Spear))
                    {
                        num17 = num18;
                    }
                    num18++;
                }
                if (num17 > -1)
                {
                    if (self.player.grasps[num17] != null && self.player.grasps[num17].grabbed is Weapon)
                    {
                        (self.player.grasps[num17].grabbed as Weapon).ChangeOverlap(false);
                    }
                    self.hands[num17].reachingForObject = true;
                    self.hands[num17].mode = Limb.Mode.HuntRelativePosition;
                    if (self.player.spearOnBack.HasASpear)
                    {
                        self.hands[num17].relativeHuntPos = Vector3.Slerp(new Vector2(((num17 != 0) ? 1f : -1f) * 20f, -30f) * Mathf.Sin(Mathf.InverseLerp(9f, 20f, (float)self.player.spearOnBack.counter) * 3.1415927f), new Vector2(0f, 1f), Mathf.InverseLerp(9f, 20f, (float)self.player.spearOnBack.counter));
                    }
                    else
                    {
                        self.hands[num17].relativeHuntPos = Vector3.Slerp(new Vector2(((num17 != 0) ? 1f : -1f) * 30f, -20f) * Mathf.Lerp(1f, 0.2f, Mathf.Abs(self.player.spearOnBack.flip)), new Vector2(1f, 1f), Mathf.InverseLerp(14f, 20f, (float)self.player.spearOnBack.counter));
                    }
                    self.drawPositions[0, 0] += Custom.DirVec(self.hands[num17].absoluteHuntPos, self.drawPositions[0, 0]) * 0.7f;
                    self.head.vel            += Custom.DirVec(self.hands[num17].absoluteHuntPos, self.head.pos) * 1.5f;
                }
            }
            else if (self.player.FoodInStomach < self.player.MaxFoodInStomach && self.objectLooker.currentMostInteresting != null && num2 < 2 && ((self.objectLooker.currentMostInteresting is Fly && (self.objectLooker.currentMostInteresting as Fly).PlayerAutoGrabable) || num > 0.8f) && Custom.DistLess(self.player.mainBodyChunk.pos, self.objectLooker.mostInterestingLookPoint, 80f) && self.player.room.VisualContact(self.player.mainBodyChunk.pos, self.objectLooker.mostInterestingLookPoint))
            {
                int num19 = -1;
                for (int n = 0; n < 2; n++)
                {
                    if (self.player.grasps[n] == null && self.hands[1 - n].reachedSnapPosition)
                    {
                        num19 = n;
                    }
                }
                if (self.objectLooker.currentMostInteresting is Fly && (self.objectLooker.currentMostInteresting as Fly).PlayerAutoGrabable && self.player.input[0].x != 0 && self.objectLooker.currentMostInteresting.bodyChunks[0].pos.x < self.player.mainBodyChunk.pos.x == self.player.input[0].x > 0)
                {
                    num19 = -1;
                }
                if (num19 > -1)
                {
                    self.hands[num19].reachingForObject = true;
                    self.hands[num19].absoluteHuntPos   = self.objectLooker.mostInterestingLookPoint;
                    if (num == 0f)
                    {
                        self.drawPositions[0, 0] += Custom.DirVec(self.drawPositions[0, 0], self.objectLooker.mostInterestingLookPoint) * 5f;
                        self.head.vel            += Custom.DirVec(self.drawPositions[0, 0], self.objectLooker.mostInterestingLookPoint) * 2f;
                    }
                }
            }
        }
        for (int num20 = 0; num20 < 2; num20++)
        {
            self.hands[num20].Update();
        }
        if (self.player.sleepCurlUp > 0f)
        {
            float   num21   = Mathf.Sign(self.player.bodyChunks[0].pos.x - self.player.bodyChunks[1].pos.x);
            Vector2 vector3 = (self.player.bodyChunks[0].pos + self.player.bodyChunks[1].pos) / 2f;
            self.drawPositions[0, 0]    = Vector2.Lerp(self.drawPositions[0, 0], vector3, self.player.sleepCurlUp * 0.2f);
            self.drawPositions[1, 0]    = Vector2.Lerp(self.drawPositions[1, 0], vector3, self.player.sleepCurlUp * 0.2f);
            self.drawPositions[0, 0].y += 2f * self.player.sleepCurlUp;
            self.drawPositions[1, 0].y += 2f * self.player.sleepCurlUp;
            self.drawPositions[1, 0].x -= 3f * num21 * self.player.sleepCurlUp;
            for (int num22 = 0; num22 < self.tail.Length; num22++)
            {
                float num23 = (float)num22 / (float)(self.tail.Length - 1);
                self.tail[num22].vel *= 1f - 0.2f * self.player.sleepCurlUp;
                self.tail[num22].pos  = Vector2.Lerp(self.tail[num22].pos, self.drawPositions[1, 0] + new Vector2((Mathf.Sin(num23 * 3.1415927f) * 25f - num23 * 10f) * -num21, Mathf.Lerp(5f, -15f, num23)), 0.1f * self.player.sleepCurlUp);
            }
            self.head.vel *= 1f - 0.4f * self.player.sleepCurlUp;
            self.head.pos  = Vector2.Lerp(self.head.pos, vector3 + new Vector2(num21 * 5f, -3f), 0.5f * self.player.sleepCurlUp);
            if (self.player.sleepCurlUp == 1f || Random.value < 0.033333335f)
            {
                self.blink = Math.Max(2, self.blink);
            }
            for (int num24 = 0; num24 < 2; num24++)
            {
                self.hands[num24].absoluteHuntPos = vector3 + new Vector2(num21 * 10f, -20f);
            }
        }
        if (self.player.Adrenaline > 0f)
        {
            float d2 = Mathf.Pow(self.player.Adrenaline, 0.2f);
            self.drawPositions[0, 0] += Custom.RNV() * Random.value * d2 * 2f;
            self.drawPositions[0, 1] += Custom.RNV() * Random.value * d2 * 2f;
            self.head.pos            += Custom.RNV() * Random.value * d2 * 1f;
            if (Random.value < 0.05f)
            {
                self.blink = Math.Max(self.blink, 3);
            }
        }
    }
    private static void SlugcatHand_Update(On.SlugcatHand.orig_Update orig, SlugcatHand self)
    {
        //Super.Update()
        self.lastPos = self.pos;
        if (self.retract && self.mode != Limb.Mode.Retracted)
        {
            self.mode            = Limb.Mode.HuntAbsolutePosition;
            self.absoluteHuntPos = self.connection.pos;
            if (Custom.DistLess(self.absoluteHuntPos, self.pos, self.huntSpeed))
            {
                self.mode = Limb.Mode.Retracted;
            }
        }
        if (self.mode == Limb.Mode.HuntRelativePosition)
        {
            self.absoluteHuntPos = self.connection.pos + Custom.RotateAroundOrigo(self.relativeHuntPos, Custom.AimFromOneVectorToAnother(self.connection.rotationChunk.pos, self.connection.pos));
        }
        switch (self.mode)
        {
        case Limb.Mode.HuntRelativePosition:
        case Limb.Mode.HuntAbsolutePosition:
            if (Custom.DistLess(self.absoluteHuntPos, self.pos, self.huntSpeed))
            {
                self.vel = self.absoluteHuntPos - self.pos;
                self.reachedSnapPosition = true;
            }
            else
            {
                self.vel = Vector2.Lerp(self.vel, Custom.DirVec(self.pos, self.absoluteHuntPos) * self.huntSpeed, self.quickness);
                self.reachedSnapPosition = false;
            }
            break;

        case Limb.Mode.Retracted:
            self.vel = self.connection.vel;
            self.pos = self.connection.pos;
            self.reachedSnapPosition = true;
            break;

        case Limb.Mode.Dangle:
            self.reachedSnapPosition = false;
            break;
        }
        self.quickness = self.defaultQuickness;
        self.huntSpeed = self.defaultHuntSpeed;
        if (self.mode != Limb.Mode.Retracted)
        {
            self.pos += self.vel;
            if (self.mode == Limb.Mode.HuntRelativePosition)
            {
                self.pos += self.connection.vel;
            }
            self.vel *= self.airFriction;
            if (self.pushOutOfTerrain)
            {
                self.PushOutOfTerrain(self.owner.owner.room, self.connection.pos);
            }
        }

        //Update()
        self.ConnectToPoint(self.connection.pos, 20f, false, 0f, self.connection.vel, 0f, 0f);
        bool flag;

        if (self.reachingForObject)
        {
            self.mode = Limb.Mode.HuntAbsolutePosition;
            flag      = false;
            self.reachingForObject = false;
        }
        else
        {
            flag = self.EngageInMovement();
        }
        if (self.limbNumber == 0 && (self.owner.owner as Player).grasps[0] != null && (self.owner.owner as Player).HeavyCarry((self.owner.owner as Player).grasps[0].grabbed))
        {
            flag = true;
        }
        if (flag)
        {
            if ((self.owner.owner as Player).grasps[0] != null && (self.owner.owner as Player).HeavyCarry((self.owner.owner as Player).grasps[0].grabbed))
            {
                self.mode = Limb.Mode.HuntAbsolutePosition;
                BodyChunk grabbedChunk = (self.owner.owner as Player).grasps[0].grabbedChunk;
                self.absoluteHuntPos = grabbedChunk.pos + Custom.PerpendicularVector((self.connection.pos - grabbedChunk.pos).normalized) * grabbedChunk.rad * 0.8f * ((self.limbNumber != 0) ? 1f : -1f);
                self.huntSpeed       = 20f;
                self.quickness       = 1f;
                flag = false;
            }
            else if ((self.owner.owner as Player).grasps[self.limbNumber] != null)
            {
                self.mode = Limb.Mode.HuntRelativePosition;
                self.relativeHuntPos.x = -20f + 40f * (float)self.limbNumber;
                self.relativeHuntPos.y = -12f;
                if ((self.owner.owner as Player).eatCounter < 40)
                {
                    int num  = -1;
                    int num2 = 0;
                    while (num < 0 && num2 < 2)
                    {
                        if ((self.owner.owner as Player).grasps[num2] != null && (self.owner.owner as Player).grasps[num2].grabbed is IPlayerEdible && ((self.owner.owner as Player).grasps[num2].grabbed as IPlayerEdible).Edible)
                        {
                            num = num2;
                        }
                        num2++;
                    }
                    if (num == self.limbNumber)
                    {
                        self.relativeHuntPos  *= Custom.LerpMap((float)(self.owner.owner as Player).eatCounter, 40f, 20f, 0.9f, 0.7f);
                        self.relativeHuntPos.y = self.relativeHuntPos.y + Custom.LerpMap((float)(self.owner.owner as Player).eatCounter, 40f, 20f, 2f, 4f);
                        self.relativeHuntPos.x = self.relativeHuntPos.x * Custom.LerpMap((float)(self.owner.owner as Player).eatCounter, 40f, 20f, 1f, 1.2f);
                    }
                }
                //Hand Towards Mouth
                if ((self.owner.owner as Player).swallowAndRegurgitateCounter > 10)
                {
                    int num3 = -1;
                    int num4 = 0;
                    while (num3 < 0 && num4 < 2)
                    {
                        if ((self.owner.owner as Player).grasps[num4] != null && (self.owner.owner as Player).CanBeSwallowed((self.owner.owner as Player).grasps[num4].grabbed))
                        {
                            num3 = num4;
                        }
                        num4++;
                    }
                    if (num3 == self.limbNumber)
                    {
                        float num5 = Mathf.InverseLerp(10f, 90f, (float)(self.owner.owner as Player).swallowAndRegurgitateCounter);
                        if (num5 < 0.5f)
                        {
                            self.relativeHuntPos  *= Mathf.Lerp(0.9f, 0.7f, num5 * 2f);
                            self.relativeHuntPos.y = self.relativeHuntPos.y + Mathf.Lerp(2f, 4f, num5 * 2f);
                            self.relativeHuntPos.x = self.relativeHuntPos.x * Mathf.Lerp(1f, 1.2f, num5 * 2f);
                        }
                        else
                        {
                            if ((self.owner.owner as Player).grasps[0] != null && ((self.owner.owner as Player).objectInStomach == null || KarmaAppetite_ExtraInventory.HasSpace(self.owner.owner as Player)))
                            {
                                self.relativeHuntPos = new Vector2(0f, -4f) + Custom.RNV() * 2f * Random.value * Mathf.InverseLerp(0.5f, 1f, num5);
                            }
                            (self.owner as PlayerGraphics).blink     = 5;
                            (self.owner as PlayerGraphics).head.vel += Custom.RNV() * 2f * Random.value * Mathf.InverseLerp(0.5f, 1f, num5);
                            self.owner.owner.bodyChunks[0].vel      += Custom.RNV() * 0.2f * Random.value * Mathf.InverseLerp(0.5f, 1f, num5);
                        }
                    }
                }
                self.relativeHuntPos.x = self.relativeHuntPos.x * (1f - Mathf.Sin((self.owner.owner as Player).switchHandsProcess * 3.1415927f));
                if ((self.owner as PlayerGraphics).spearDir != 0f && (self.owner.owner as Player).bodyMode == Player.BodyModeIndex.Stand)
                {
                    Vector2 to = Custom.DegToVec(180f + ((self.limbNumber != 0) ? 1f : -1f) * 8f + (float)(self.owner.owner as Player).input[0].x * 4f) * 12f;
                    to.y += Mathf.Sin((float)(self.owner.owner as Player).animationFrame / 6f * 2f * 3.1415927f) * 2f;
                    to.x -= Mathf.Cos((float)((self.owner.owner as Player).animationFrame + ((!(self.owner.owner as Player).leftFoot) ? 6 : 0)) / 12f * 2f * 3.1415927f) * 4f * (float)(self.owner.owner as Player).input[0].x;
                    to.x += (float)(self.owner.owner as Player).input[0].x * 2f;
                    self.relativeHuntPos = Vector2.Lerp(self.relativeHuntPos, to, Mathf.Abs((self.owner as PlayerGraphics).spearDir));
                    if ((self.owner.owner as Player).grasps[self.limbNumber].grabbed is Weapon)
                    {
                        ((self.owner.owner as Player).grasps[self.limbNumber].grabbed as Weapon).ChangeOverlap(((self.owner as PlayerGraphics).spearDir > -0.4f && self.limbNumber == 0) || ((self.owner as PlayerGraphics).spearDir < 0.4f && self.limbNumber == 1));
                    }
                }
                flag = false;
                if ((self.owner.owner as Creature).grasps[self.limbNumber].grabbed is Fly && !((self.owner.owner as Creature).grasps[self.limbNumber].grabbed as Fly).dead)
                {
                    self.huntSpeed = Random.value * 5f;
                    self.quickness = Random.value * 0.3f;
                    self.vel      += Custom.DegToVec(Random.value * 360f) * Random.value * Random.value * ((!Custom.DistLess(self.absoluteHuntPos, self.pos, 7f)) ? 1.5f : 4f);
                    self.pos      += Custom.DegToVec(Random.value * 360f) * Random.value * 4f;
                    (self.owner as PlayerGraphics).NudgeDrawPosition(0, Custom.DirVec((self.owner.owner as Creature).mainBodyChunk.pos, self.pos) * 3f * Random.value);
                    (self.owner as PlayerGraphics).head.vel += Custom.DirVec((self.owner.owner as Creature).mainBodyChunk.pos, self.pos) * 2f * Random.value;
                }
                else if ((self.owner.owner as Creature).grasps[self.limbNumber].grabbed is VultureMask)
                {
                    self.relativeHuntPos *= 1f - ((self.owner.owner as Creature).grasps[self.limbNumber].grabbed as VultureMask).donned;
                }
            }
        }
        if (flag && self.mode != Limb.Mode.Retracted)
        {
            self.retractCounter++;
            if ((float)self.retractCounter > 5f)
            {
                self.mode = Limb.Mode.HuntAbsolutePosition;
                self.pos  = Vector2.Lerp(self.pos, self.owner.owner.bodyChunks[0].pos, Mathf.Clamp(((float)self.retractCounter - 5f) * 0.05f, 0f, 1f));
                if (Custom.DistLess(self.pos, self.owner.owner.bodyChunks[0].pos, 2f) && self.reachedSnapPosition)
                {
                    self.mode = Limb.Mode.Retracted;
                }
                self.absoluteHuntPos = self.owner.owner.bodyChunks[0].pos;
                self.huntSpeed       = 1f + (float)self.retractCounter * 0.2f;
                self.quickness       = 1f;
            }
        }
        else
        {
            self.retractCounter -= 10;
            if (self.retractCounter < 0)
            {
                self.retractCounter = 0;
            }
        }
    }
Пример #15
0
            public void GraphicsModuleUpdated(bool actuallyViewed, bool eu)
            {
                if (backItem == null)
                {
                    return;
                }
                if (backItem.slatedForDeletetion || backItem.grabbedBy.Count > 0)
                {
                    if (abstractStick != null)
                    {
                        abstractStick.Deactivate();
                    }
                    backItem = null;
                    return;
                }
                Vector2 vector  = owner.mainBodyChunk.pos;
                Vector2 vector2 = owner.bodyChunks[1].pos;

                if (owner.graphicsModule != null)
                {
                    vector  = Vector2.Lerp((owner.graphicsModule as PlayerGraphics).drawPositions[0, 0], (owner.graphicsModule as PlayerGraphics).head.pos, 0.2f);
                    vector2 = (owner.graphicsModule as PlayerGraphics).drawPositions[1, 0];
                }
                Vector2 vector3 = Custom.DirVec(vector2, vector);

                if (owner.Consious && owner.bodyMode != Player.BodyModeIndex.ZeroG && owner.room.gravity > 0f)
                {
                    if (owner.bodyMode == Player.BodyModeIndex.Default && owner.animation == Player.AnimationIndex.None && owner.standing && owner.bodyChunks[1].pos.y < owner.bodyChunks[0].pos.y - 6f)
                    {
                        flip = Custom.LerpAndTick(flip, (float)owner.input[0].x * 0.3f, 0.05f, 0.02f);
                    }
                    else if (owner.bodyMode == Player.BodyModeIndex.Stand && owner.input[0].x != 0)
                    {
                        flip = Custom.LerpAndTick(flip, owner.input[0].x, 0.02f, 0.1f);
                    }
                    else
                    {
                        flip = Custom.LerpAndTick(flip, (float)owner.flipDirection * Mathf.Abs(vector3.x), 0.15f, 355f / (678f * (float)Math.PI));
                    }
                    if (counter > 12 && !interactionLocked && owner.input[0].x != 0 && owner.standing)
                    {
                        float num = 0f;
                        for (int i = 0; i < owner.grasps.Length; i++)
                        {
                            if (owner.grasps[i] == null)
                            {
                                num = ((i != 0) ? 1f : (-1f));
                                break;
                            }
                        }
                        backItem.setRotation = Custom.DegToVec(Custom.AimFromOneVectorToAnother(vector2, vector) + Custom.LerpMap(counter, 12f, 20f, 0f, 360f * num));
                    }
                    else
                    {
                        backItem.setRotation = (vector3 - Custom.PerpendicularVector(vector3) * 0.9f * (1f - Mathf.Abs(flip))).normalized;
                    }
                    backItem.ChangeOverlap(vector3.y < -0.1f && owner.bodyMode != Player.BodyModeIndex.ClimbingOnBeam);
                }
                else
                {
                    flip = Custom.LerpAndTick(flip, 0f, 0.15f, 0.142857149f);
                    backItem.setRotation = vector3 - Custom.PerpendicularVector(vector3) * 0.9f;
                    backItem.ChangeOverlap(newOverlap: false);
                }
                backItem.firstChunk.MoveFromOutsideMyUpdate(eu, Vector2.Lerp(vector2, vector, 0.6f) - Custom.PerpendicularVector(vector2, vector) * 7.5f * flip);
                backItem.firstChunk.vel = owner.mainBodyChunk.vel;
                backItem.rotationSpeed  = 0f;
            }