Exemple #1
0
    // Token: 0x06001C81 RID: 7297 RVA: 0x001847C0 File Offset: 0x001829C0
    private void FindGrabPos()
    {
        if (grabDelay > 0)
        {
            grabDelay--;
            return;
        }
        IntVector2?intVector = null;
        int        num       = 0;

        while (num < 9 && intVector == null)
        {
            intVector = SharedPhysics.RayTraceTilesForTerrainReturnFirstSolid(room, BasePos, room.GetTilePosition(desiredGrabPos) + Custom.eightDirectionsAndZero[num] * 5);
            if (intVector != null && room.GetTile(intVector.Value + new IntVector2(0, 1)).Solid)
            {
                intVector = null;
            }
            num++;
        }
        if (intVector != null)
        {
            if (grabDest == null || GripPointAttractiveness(intVector.Value) > GripPointAttractiveness(grabDest.Value))
            {
                MoveGrabDest(Custom.RestrictInRect(FloatBase + tentacleDir * Vector2.Distance(FloatBase, room.MiddleOfTile(intVector.Value)) * 0.5f, FloatRect.MakeFromVector2(room.MiddleOfTile(intVector.Value) - new Vector2(11f, 11f), room.MiddleOfTile(intVector.Value) + new Vector2(11f, 11f))));
                sureOfFootingCounter = 0;
            }
            else
            {
                sureOfFootingCounter++;
            }
        }
    }
    private void Strike()
    {
        int num = UnityEngine.Random.Range(0, this.room.TileWidth);

        if (this.room.GetTile(num, this.room.TileHeight - 1).Solid)
        {
            return;
        }
        int num2 = this.room.roomRain.rainReach[num];

        if (num2 >= this.room.TileHeight)
        {
            return;
        }
        if (num2 == 0)
        {
            num2 = -10;
        }
        this.pos         = this.room.MiddleOfTile(num, num2) + new Vector2(Mathf.Lerp(-10f, 10f, UnityEngine.Random.value), 10f);
        this.skyPos      = this.room.MiddleOfTile(num, num2 + this.room.TileHeight + 50) + new Vector2(Mathf.Lerp(-30f, 30f, UnityEngine.Random.value) - 30f * this.roomRain.globalRain.rainDirection, 0f);
        this.falling     = 0f;
        this.lastFalling = 0f;
        this.moveTip     = true;
        this.fallSpeed   = 1f / Mathf.Lerp(0.2f, 1.8f, UnityEngine.Random.value);
        this.delay       = UnityEngine.Random.Range(0, 60 - (int)(this.roomRain.globalRain.bulletRainDensity * 60f));
        SharedPhysics.CollisionResult collisionResult = new SharedPhysics.CollisionResult();
        if (roomRain.room.roomSettings.RainIntensity != 0.01086957f)
        {
            collisionResult = SharedPhysics.TraceProjectileAgainstBodyChunks(null, this.room, this.skyPos, ref this.pos, 0.5f, 1, null, false);
        }
        if (this.room.water && this.room.PointSubmerged(this.pos))
        {
            this.pos.y = this.room.FloatWaterLevel(this.pos.x) - 30f;
            this.room.waterObject.WaterfallHitSurface(this.pos.x, this.pos.x, 1f);
            this.room.PlaySound(SoundID.Small_Object_Into_Water_Fast, this.pos);
        }
        else
        {
            this.room.PlaySound(SoundID.Bullet_Drip_Strike, this.pos);
        }

        if (roomRain.room.roomSettings.RainIntensity != 0.01086957f)
        {
            if (collisionResult.chunk != null)
            {
                this.pos = collisionResult.collisionPoint;
                BodyChunk chunk = collisionResult.chunk;
                chunk.vel.y = chunk.vel.y - 2f / collisionResult.chunk.mass;
                if (collisionResult.chunk.owner is Creature)
                {
                    (collisionResult.chunk.owner as Creature).Stun(UnityEngine.Random.Range(0, 4));
                }
            }
        }
    }
Exemple #3
0
    public bool RayTraceSky(Vector2 pos, Vector2 testDir)
    {
        Vector2 corner = Custom.RectCollision(pos, pos + testDir * 100000f, this.room.RoomRect).GetCorner(FloatRect.CornerLabel.D);

        if (SharedPhysics.RayTraceTilesForTerrainReturnFirstSolid(this.room, pos, corner) != null)
        {
            return(false);
        }
        if (corner.y >= this.room.PixelHeight - 5f)
        {
            return(true);
        }
        return(false);
    }
Exemple #4
0
    public override void NewRoom(Room room)
    {
        base.NewRoom(room);
        if (debugViz)
        {
            if (grabGoalSprites != null)
            {
                grabGoalSprites[0].RemoveFromRoom();
                grabGoalSprites[1].RemoveFromRoom();
            }
            grabGoalSprites    = new DebugSprite[2];
            grabGoalSprites[0] = new DebugSprite(new Vector2(0f, 0f), new FSprite("pixel", true), room);
            grabGoalSprites[0].sprite.scale = 10f;
            grabGoalSprites[0].sprite.color = new Color(1f, 0f, 0f);
            room.AddObject(grabGoalSprites[0]);
            grabGoalSprites[1] = new DebugSprite(new Vector2(0f, 0f), new FSprite("pixel", true), room);
            grabGoalSprites[1].sprite.scale = 10f;
            grabGoalSprites[1].sprite.color = new Color(0f, 5f, 0f);
            room.AddObject(grabGoalSprites[1]);
        }
        IntVector2 tilePosition = room.GetTilePosition(FloatBase + new Vector2(0f, -400f) + tentacleDir * 100f);
        IntVector2?intVector    = SharedPhysics.RayTraceTilesForTerrainReturnFirstSolid(room, BasePos, tilePosition);

        if (intVector != null)
        {
            Vector2 newGrabDest = Custom.RestrictInRect(FloatBase, room.TileRect(intVector.Value).Grow(2f));
            segments = SharedPhysics.RayTracedTilesArray(FloatBase, room.MiddleOfTile(intVector.Value));
            if (segments.Count > 2)
            {
                segments.RemoveAt(segments.Count - 1);
            }
            MoveGrabDest(newGrabDest);
            for (int i = 0; i < tChunks.Length; i++)
            {
                tChunks[i].Reset();
            }
            attachedAtTip           = true;
            smoothedFootingSecurity = 1f;
        }
    }
Exemple #5
0
        public override void Update(bool eu)
        {
            base.Update(eu);

            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 < -10.0f || stillCounter > 20)
                    {
                        spinning             = false;
                        rotationSpeed        = 0f;
                        rotation             = Custom.DegToVec(Mathf.Lerp(-90, 90f, 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:
                SetRandomSpin();
                soundLoop.sound  = SoundID.Spear_Spinning_Through_Air_LOOP;
                soundLoop.Volume = Mathf.InverseLerp(5f, 15f, base.firstChunk.vel.magnitude);
                break;
            }
            for (int i = 0; i < strap.GetLength(0); i++)
            {
                float t = (float)i / (float)(strap.GetLength(0) - 1);
                strap[i, 1]  = strap[i, 0];
                strap[i, 0] += strap[i, 2];
                strap[i, 2] -= rotation * Mathf.InverseLerp(1f, 0f, i) * 0.8f;
                strap[i, 4]  = strap[i, 3];
                strap[i, 3]  = (strap[i, 3] + strap[i, 5] * Custom.LerpMap(Vector2.Distance(strap[i, 0], strap[i, 1]), 1f, 18f, 0.05f, 0.3f)).normalized;
                strap[i, 5]  = (strap[i, 5] + Custom.RNV() * UnityEngine.Random.value * Mathf.Pow(Mathf.InverseLerp(1f, 18f, Vector2.Distance(strap[i, 0], strap[i, 1])), 0.3f)).normalized;
                if (room.PointSubmerged(strap[i, 0]))
                {
                    strap[i, 2]   *= Custom.LerpMap(strap[i, 2].magnitude, 1f, 10f, 1f, 0.5f, Mathf.Lerp(1.4f, 0.4f, t));
                    strap[i, 2].y += 0.05f;
                    strap[i, 2]   += Custom.RNV() * 0.1f;
                    continue;
                }
                strap[i, 2]   *= Custom.LerpMap(Vector2.Distance(strap[i, 0], strap[i, 1]), 1f, 6f, 0.999f, 0.7f, Mathf.Lerp(1.5f, 0.5f, t));
                strap[i, 2].y -= room.gravity * Custom.LerpMap(Vector2.Distance(strap[i, 0], strap[i, 1]), 1f, 6f, 0.6f, 0f);
                if (i % 3 == 2 || i == strap.GetLength(0) - 1)
                {
                    SharedPhysics.TerrainCollisionData cd = new SharedPhysics.TerrainCollisionData(strap[i, 0], strap[i, 1], strap[i, 2], 1f, new IntVector2(0, 0), goThroughFloors: false);
                    cd          = SharedPhysics.HorizontalCollision(room, cd);
                    cd          = SharedPhysics.VerticalCollision(room, cd);
                    cd          = SharedPhysics.SlopesVertically(room, cd);
                    strap[i, 0] = cd.pos;
                    strap[i, 2] = cd.vel;
                    if (cd.contactPoint.x != 0)
                    {
                        strap[i, 2].y *= 0.6f;
                    }
                    if (cd.contactPoint.y != 0)
                    {
                        strap[i, 2].x *= 0.6f;
                    }
                }
            }
            for (int j = 0; j < strap.GetLength(0); j++)
            {
                if (j > 0)
                {
                    Vector2 normalized = (strap[j, 0] - strap[j - 1, 0]).normalized;
                    float   num        = Vector2.Distance(strap[j, 0], strap[j - 1, 0]);
                    float   d          = ((!(num > conRad)) ? 0.25f : 0.5f);
                    strap[j, 0]     += normalized * (conRad - num) * d;
                    strap[j, 2]     += normalized * (conRad - num) * d;
                    strap[j - 1, 0] -= normalized * (conRad - num) * d;
                    strap[j - 1, 2] -= normalized * (conRad - num) * d;
                    if (j > 1)
                    {
                        normalized       = (strap[j, 0] - strap[j - 2, 0]).normalized;
                        strap[j, 2]     += normalized * 0.2f;
                        strap[j - 2, 2] -= normalized * 0.2f;
                    }
                    if (j < strap.GetLength(0) - 1)
                    {
                        strap[j, 3] = Vector3.Slerp(strap[j, 3], (strap[j - 1, 3] * 2f + strap[j + 1, 3]) / 3f, 0.1f);
                        strap[j, 5] = Vector3.Slerp(strap[j, 5], (strap[j - 1, 5] * 2f + strap[j + 1, 5]) / 3f, Custom.LerpMap(Vector2.Distance(strap[j, 1], strap[j, 0]), 1f, 8f, 0.05f, 0.5f));
                    }
                }
                else
                {
                    strap[j, 0]  = StrapAttachPos(1f);
                    strap[j, 2] *= 0f;
                }
            }
        }
Exemple #6
0
                public void Update()
                {
                    this.lastPos = this.pos;
                    this.pos    += this.vel;
                    this.vel    *= 0.8f;
                    if ((float)this.index == 0f)
                    {
                        this.pos = this.arm.BasePos(1f);
                    }
                    else if (this.index < this.arm.joints.Length - 1)
                    {
                        if (this.index == 1 && (this.arm.baseMoving || this.arm.oracle.room.GetTile(this.previous.ElbowPos(1f, this.pos)).Solid))
                        {
                            Vector2 vector = Custom.InverseKinematic(this.previous.pos, this.next.pos, this.previous.totalLength, this.totalLength, this.currentInvKinFlip);
                            Vector2 from   = Custom.InverseKinematic(this.previous.pos, this.next.pos, this.previous.totalLength, this.totalLength, -this.currentInvKinFlip);
                            float   num    = (!this.arm.oracle.room.GetTile(vector).Solid) ? 0f : 10f;
                            num += ((!this.arm.oracle.room.GetTile(this.previous.ElbowPos(1f, Vector2.Lerp(vector, this.previous.pos, 0.2f))).Solid) ? 0f : 1f);
                            float num2 = (!this.arm.oracle.room.GetTile(from).Solid) ? 0f : 10f;
                            num2 += ((!this.arm.oracle.room.GetTile(this.previous.ElbowPos(1f, Vector2.Lerp(from, this.previous.pos, 0.2f))).Solid) ? 0f : 1f);
                            if (num > num2)
                            {
                                this.currentInvKinFlip *= -1f;
                                vector = Custom.InverseKinematic(this.previous.pos, this.next.pos, this.previous.totalLength, this.totalLength, this.currentInvKinFlip);
                            }
                            else if (num == 0f)
                            {
                                this.vel += Vector2.ClampMagnitude(vector - this.pos, 100f) / 100f * 1.8f;
                            }
                        }
                        SharedPhysics.TerrainCollisionData terrainCollisionData = new SharedPhysics.TerrainCollisionData(this.pos, this.lastPos, this.vel, 1f, new IntVector2(0, 0), true);
                        terrainCollisionData = SharedPhysics.VerticalCollision(this.arm.oracle.room, terrainCollisionData);
                        terrainCollisionData = SharedPhysics.HorizontalCollision(this.arm.oracle.room, terrainCollisionData);
                        terrainCollisionData = SharedPhysics.SlopesVertically(this.arm.oracle.room, terrainCollisionData);
                        this.pos             = terrainCollisionData.pos;
                        this.vel             = terrainCollisionData.vel;
                    }
                    if (this.next != null)
                    {
                        Vector2 vector2 = Custom.DirVec(this.pos, this.next.pos);
                        float   num3    = Vector2.Distance(this.pos, this.next.pos);
                        float   num4    = 0.5f;
                        if (this.index == 0)
                        {
                            num4 = 0f;
                        }
                        else if (this.index == this.arm.joints.Length - 2)
                        {
                            num4 = 1f;
                        }
                        float num5 = -1f;
                        float num6 = 0.5f;
                        if (this.previous != null)
                        {
                            Vector2 lhs = Custom.DirVec(this.previous.pos, this.pos);
                            num6 = Custom.LerpMap(Vector2.Dot(lhs, vector2), -1f, 1f, 1f, 0.2f);
                        }
                        if (num3 > this.totalLength)
                        {
                            num5 = this.totalLength;
                        }
                        else if (num3 < this.totalLength * num6)
                        {
                            num5 = this.totalLength * num6;
                        }
                        if (num5 > 0f)
                        {
                            this.pos      += vector2 * (num3 - num5) * num4;
                            this.vel      += vector2 * (num3 - num5) * num4;
                            this.next.vel -= vector2 * (num3 - num5) * (1f - num4);
                        }
                    }
                    else
                    {
                        Vector2 a = this.arm.oracle.bodyChunks[1].pos;

                        a -= this.arm.oracle.oracleBehavior.GetToDir * this.totalLength / 2f;

                        a        += Custom.DirVec(this.arm.oracle.bodyChunks[1].pos, this.pos) * this.totalLength / 2f;
                        this.vel += Vector2.ClampMagnitude(a - this.pos, 50f) / 50f * 1.2f;
                        this.pos += Vector2.ClampMagnitude(a - this.pos, 50f) / 50f * 1.2f;
                        Vector2 a2   = Custom.DirVec(this.pos, this.arm.oracle.bodyChunks[0].pos);
                        float   num7 = Vector2.Distance(this.pos, this.arm.oracle.bodyChunks[0].pos);
                        this.pos += a2 * (num7 - this.totalLength);
                        this.vel += a2 * (num7 - this.totalLength);
                    }
                }
 // Token: 0x060021A9 RID: 8617 RVA: 0x001FC424 File Offset: 0x001FA624
 public void Update()
 {
     lastPos = pos;
     pos    += vel;
     vel    *= 0.8f;
     if ((float)index == 0f)
     {
         pos = arm.BasePos(1f);
     }
     else if (index < arm.joints.Length - 1)
     {
         if (index == 1 && (arm.baseMoving || arm.oracle.room.GetTile(previous.ElbowPos(1f, pos)).Solid))
         {
             Vector2 vector = Custom.InverseKinematic(previous.pos, next.pos, previous.totalLength, totalLength, currentInvKinFlip);
             Vector2 from   = Custom.InverseKinematic(previous.pos, next.pos, previous.totalLength, totalLength, -currentInvKinFlip);
             float   num    = (!arm.oracle.room.GetTile(vector).Solid) ? 0f : 10f;
             num += ((!arm.oracle.room.GetTile(previous.ElbowPos(1f, Vector2.Lerp(vector, previous.pos, 0.2f))).Solid) ? 0f : 1f);
             float num2 = (!arm.oracle.room.GetTile(from).Solid) ? 0f : 10f;
             num2 += ((!arm.oracle.room.GetTile(previous.ElbowPos(1f, Vector2.Lerp(from, previous.pos, 0.2f))).Solid) ? 0f : 1f);
             if (num > num2)
             {
                 currentInvKinFlip *= -1f;
                 vector             = Custom.InverseKinematic(previous.pos, next.pos, previous.totalLength, totalLength, currentInvKinFlip);
             }
             else if (num == 0f)
             {
                 vel += Vector2.ClampMagnitude(vector - pos, 100f) / 100f * 1.8f;
             }
         }
         SharedPhysics.TerrainCollisionData terrainCollisionData = new SharedPhysics.TerrainCollisionData(pos, lastPos, vel, 1f, new IntVector2(0, 0), true);
         terrainCollisionData = SharedPhysics.VerticalCollision(arm.oracle.room, terrainCollisionData);
         terrainCollisionData = SharedPhysics.HorizontalCollision(arm.oracle.room, terrainCollisionData);
         terrainCollisionData = SharedPhysics.SlopesVertically(arm.oracle.room, terrainCollisionData);
         pos = terrainCollisionData.pos;
         vel = terrainCollisionData.vel;
     }
     if (next != null)
     {
         Vector2 vector2 = Custom.DirVec(pos, next.pos);
         float   num3    = Vector2.Distance(pos, next.pos);
         float   num4    = 0.5f;
         if (index == 0)
         {
             num4 = 0f;
         }
         else if (index == arm.joints.Length - 2)
         {
             num4 = 1f;
         }
         float num5 = -1f;
         float num6 = 0.5f;
         if (previous != null)
         {
             Vector2 lhs = Custom.DirVec(previous.pos, pos);
             num6 = Custom.LerpMap(Vector2.Dot(lhs, vector2), -1f, 1f, 1f, 0.2f);
         }
         if (num3 > totalLength)
         {
             num5 = totalLength;
         }
         else if (num3 < totalLength * num6)
         {
             num5 = totalLength * num6;
         }
         if (num5 > 0f)
         {
             pos      += vector2 * (num3 - num5) * num4;
             vel      += vector2 * (num3 - num5) * num4;
             next.vel -= vector2 * (num3 - num5) * (1f - num4);
         }
     }
     else
     {
         Vector2 a = arm.oracle.bodyChunks[1].pos;
         //if (this.arm.oracle.ID == Oracle.OracleID.SS)
         //{
         a -= arm.oracle.oracleBehavior.GetToDir * totalLength / 2f;
         //}
         //else
         //{
         //    a -= Custom.PerpendicularVector(this.arm.oracle.oracleBehavior.GetToDir) * this.totalLength / 2f;
         //}
         a   += Custom.DirVec(arm.oracle.bodyChunks[1].pos, pos) * totalLength / 2f;
         vel += Vector2.ClampMagnitude(a - pos, 50f) / 50f * 1.2f;
         pos += Vector2.ClampMagnitude(a - pos, 50f) / 50f * 1.2f;
         Vector2 a2   = Custom.DirVec(pos, arm.oracle.bodyChunks[0].pos);
         float   num7 = Vector2.Distance(pos, arm.oracle.bodyChunks[0].pos);
         pos += a2 * (num7 - totalLength);
         vel += a2 * (num7 - totalLength);
     }
 }
        private static void PlayerUpdatePatch(On.Player.orig_Update orig, Player player, bool eu)
        {
            int playerNumber = player.playerState.playerNumber;

            bowStats[playerNumber].aimDir = GetAimDir(player).normalized;

            if (bowStats[playerNumber].aimDir.magnitude > 0.4f)
            {
                bowStats[playerNumber].lastAimDir = bowStats[playerNumber].aimDir;
            }

            if (!bowStats[playerNumber].isDrawing && bowStats[playerNumber].released)
            {
                PhysicalObject releasedObject = GetOppositeObject(player, 0);

                if (releasedObject != null && releasedObject.abstractPhysicalObject.type == EnumExt_NewItems.Arrow)
                {
                    Arrow arrow = releasedObject as Arrow;
                    bowStats[playerNumber].controlLocked = 10;
                    Vector2 launchDir = bowStats[playerNumber].aimDir;
                    Vector2 thrownPos = player.firstChunk.pos + launchDir * 10f + new Vector2(0f, 4f);
                    player.grasps[1].Release();
                    arrow.Thrown(player, thrownPos, player.mainBodyChunk.pos - launchDir * 10f, new IntVector2(player.ThrowDirection, 0), Mathf.Lerp(1f, 1.5f, player.Adrenaline), eu);

                    foreach (BodyChunk bodyChunk in arrow.bodyChunks)
                    {
                        bodyChunk.pos = player.mainBodyChunk.pos + bowStats[playerNumber].lastAimDir * 10f;
                        bodyChunk.vel = (bowStats[playerNumber].lastAimDir.normalized) * (40f * GetFireStrength(player));
                    }

                    player.bodyChunks[0].vel -= launchDir * 3f;
                    player.bodyChunks[1].vel -= launchDir * 4.5f;

                    arrow.arrowDamageBonus = (1f * GetFireStrength(player)) * bowStats[playerNumber].arrowLethality;

                    arrow.stillFlyingCounter = Arrow.maxFlyingCount;
                    arrow.rotation           = launchDir.normalized;
                }

                bowStats[playerNumber].released = false;
            }

            orig(player, eu);

            if (globalStats[playerNumber].backSlot == null)
            {
                globalStats[playerNumber].backSlot = new BackSlot(player);
            }
            if (globalStats[playerNumber].headSlot == null)
            {
                globalStats[playerNumber].headSlot = new EquippedArmor(player, Armor.ArmorSlot.Head);
            }
            if (globalStats[playerNumber].bodySlot == null)
            {
                globalStats[playerNumber].bodySlot = new EquippedArmor(player, Armor.ArmorSlot.Body);
            }
            if (globalStats[playerNumber].accessorySlot == null)
            {
                globalStats[playerNumber].accessorySlot = new EquippedArmor(player, Armor.ArmorSlot.Accessory);
            }

            if (player.input[0].pckp && !globalStats[playerNumber].backSlot.interactionLocked && ((CanPutWeaponToBack(player, (player.grasps[0]?.grabbed as Weapon)) || CanPutWeaponToBack(player, (player.grasps[1]?.grabbed as Weapon))) || CanRetrieveWeaponFromBack(player)) && player.CanPutSpearToBack)
            {
                globalStats[playerNumber].backSlot.increment = true;
            }
            else
            {
                globalStats[playerNumber].backSlot.increment = false;
            }

            if (player.input[0].pckp && player.grasps[0] != null && player.grasps[0].grabbed is Creature && player.CanEatMeat(player.grasps[0].grabbed as Creature) && (player.grasps[0].grabbed as Creature).Template.meatPoints > 0)
            {
                globalStats[playerNumber].backSlot.increment         = false;
                globalStats[playerNumber].backSlot.interactionLocked = true;
            }
            else if (player.swallowAndRegurgitateCounter > 90)
            {
                globalStats[playerNumber].backSlot.increment         = false;
                globalStats[playerNumber].backSlot.interactionLocked = true;
            }

            globalStats[playerNumber].backSlot.Update(eu);

            if (globalStats[playerNumber].backSlot.HasAWeapon && player.spearOnBack.increment)
            {
                player.spearOnBack.increment = false;
            }

            for (int i = 0; i < 2; i++)
            {
                if (player.grasps[i] == null)
                {
                    continue;
                }

                PhysicalObject usedObject = player.grasps[i].grabbed;

                switch (usedObject)
                {
                case Club club:

                    Vector2 clubTip = (usedObject.firstChunk.pos + (usedObject as Weapon).rotation * 50f);

                    SharedPhysics.CollisionResult collisionResult = SharedPhysics.TraceProjectileAgainstBodyChunks((usedObject as SharedPhysics.IProjectileTracer), player.room, usedObject.firstChunk.pos, ref clubTip, 10f, player.collisionLayer, player, true);

                    if (collisionResult.obj != null && clubStats[playerNumber].firstHit)
                    {
                        clubStats[playerNumber].firstHit = false;
                        bool arenaHit = false;
                        if (usedObject.abstractPhysicalObject.world.game.IsArenaSession && usedObject.abstractPhysicalObject.world.game.GetArenaGameSession.GameTypeSetup.spearHitScore != 0 && player != null && collisionResult.obj is Creature)
                        {
                            arenaHit = true;
                            if ((collisionResult.obj as Creature).State is HealthState && ((collisionResult.obj as Creature).State as HealthState).health <= 0f)
                            {
                                arenaHit = false;
                            }
                            else if (!((collisionResult.obj as Creature).State is HealthState) && (collisionResult.obj as Creature).State.dead)
                            {
                                arenaHit = false;
                            }
                        }

                        if (collisionResult.obj is Creature)
                        {
                            player.room.socialEventRecognizer.WeaponAttack(usedObject as Club, player, collisionResult.obj as Creature, hit: true);
                            player.room.PlaySound(SoundID.Rock_Hit_Creature, collisionResult.chunk);

                            bool iKilledThis = false;

                            if (((collisionResult.obj as Creature).State as HealthState).health > 0f)
                            {
                                iKilledThis = true;
                            }

                            (collisionResult.obj as Creature).Violence(usedObject.firstChunk, (usedObject as Weapon).rotation * usedObject.firstChunk.mass * 2f, collisionResult.chunk, collisionResult.onAppendagePos, Creature.DamageType.Blunt, globalStats[playerNumber].meleeSkill * 0.6f, 20f);

                            if (((collisionResult.obj as Creature).State as HealthState).health <= 0f && iKilledThis)
                            {
                                player.room.socialEventRecognizer.Killing(player, collisionResult.obj as Creature);
                            }

                            if (arenaHit)
                            {
                                usedObject.abstractPhysicalObject.world.game.GetArenaGameSession.PlayerLandSpear(player, collisionResult.obj as Creature);
                            }
                        }
                        else
                        {
                            player.room.PlaySound(SoundID.Rock_Hit_Wall, collisionResult.chunk);
                        }
                    }

                    break;
                }
            }

            if (clubStats[playerNumber].swingTimer > 0)
            {
                clubStats[playerNumber].swingTimer--;
            }
            if (bowStats[playerNumber].controlLocked > 0)
            {
                bowStats[playerNumber].controlLocked--;
            }
            if (clubStats[playerNumber].swingDelay > 0)
            {
                clubStats[playerNumber].swingDelay--;
            }

            if (clubStats[playerNumber].comboCooldown > 0)
            {
                clubStats[playerNumber].comboCooldown--;

                if (clubStats[playerNumber].comboCooldown == 0)
                {
                    clubStats[playerNumber].comboCount = 0;
                }
            }

            if (globalStats[playerNumber].animTimer > 0)
            {
                globalStats[playerNumber].animTimer--;

                if (globalStats[playerNumber].animTimer == 0 && clubStats[playerNumber].firstHit)
                {
                    clubStats[playerNumber].firstHit = false;
                }
            }

            if (bowStats[playerNumber].isDrawing)
            {
                bowStats[playerNumber].drawTime = Mathf.Clamp(bowStats[playerNumber].drawTime + bowStats[playerNumber].drawSpeed, 0.0f, maxDrawTime);
            }
            else
            {
                bowStats[playerNumber].drawTime = Mathf.Clamp(bowStats[playerNumber].drawTime - (bowStats[playerNumber].drawSpeed * 3.0f), 0.0f, maxDrawTime);
            }
        }
Exemple #9
0
 public override void Update()
 {
     base.Update();
     smoothedFootingSecurity = Mathf.Lerp(smoothedFootingSecurity, (!attachedAtTip) ? Mathf.InverseLerp(3f, 30f, (float)sureOfFootingCounter) : 0f, 0.2f);
     attachedAtTip           = false;
     maxLength   = 25f * walkerBeast.preferredHeight * 1.33333337f;
     idealLength = Mathf.Min(Mathf.Lerp(idealLength, (grabDest == null) ? maxLength : (Vector2.Distance(FloatBase, floatGrabDest.Value) * 1.5f * Mathf.InverseLerp((float)setGrabDelay, 0f, (float)grabDelay)), 0.03f), maxLength);
     retractFac  = 0f;
     limp        = !walkerBeast.Consious;
     if (limp)
     {
         floatGrabDest = null;
         for (int i = 0; i < tChunks.Length; i++)
         {
             tChunks[i].vel *= 0.9f;
             Tentacle.TentacleChunk tentacleChunk = tChunks[i];
             tentacleChunk.vel.y = tentacleChunk.vel.y - 0.5f;
         }
     }
     for (int j = 0; j < tChunks.Length; j++)
     {
         tChunks[j].rad = 5f;
         float num = (float)j / (float)(tChunks.Length - 1);
         tChunks[j].vel *= 0.5f;
         if (backtrackFrom == -1 || j < backtrackFrom)
         {
             if (j < tChunks.Length - 1)
             {
                 tChunks[j].vel += walkerBeast.HeadDir * Mathf.Lerp(-1f, 1f, num) * Mathf.Pow(1f - num, 1.8f);
             }
             tChunks[j].vel += walkerBeast.moveDirection * Mathf.Sin(smoothedFootingSecurity * 3.14159274f) * 1.5f * Mathf.Lerp(1f, 2.5f, Mathf.Sin(num * 3.14159274f));
         }
         tChunks[j].pos = Vector2.Lerp(tChunks[j].pos, room.MiddleOfTile(segments[tChunks[j].currentSegment]), 0.03f);
         if (room.PointSubmerged(tChunks[j].pos))
         {
             tChunks[j].vel *= 0.5f;
         }
     }
     if (backtrackFrom == -1)
     {
         tChunks[1].vel += walkerBeast.moveDirection;
     }
     if (backtrackFrom == -1 && grabDest != null)
     {
         Tip.vel += Custom.DirVec(Tip.pos, floatGrabDest.Value) * Mathf.Lerp(0.2f, 38f, smoothedFootingSecurity);
     }
     if (floatGrabDest != null && Custom.DistLess(Tip.pos, floatGrabDest.Value, 40f) && backtrackFrom == -1)
     {
         Tip.pos       = floatGrabDest.Value;
         Tip.vel      *= 0f;
         attachedAtTip = true;
     }
     Tip.collideWithTerrain = !attachedAtTip;
     UpdateDesiredGrabPos();
     for (int k = 0; k < tChunks.Length; k++)
     {
         Tentacle.TentacleChunk tentacleChunk2 = tChunks[k];
         tentacleChunk2.vel.y = tentacleChunk2.vel.y - 0.1f;
         tChunks[k].vel      += connectedChunk.vel * 0.1f;
         if (!attachedAtTip)
         {
             if (floatGrabDest != null)
             {
                 tChunks[k].vel += Custom.DirVec(tChunks[k].pos, floatGrabDest.Value) * 0.3f;
             }
             else
             {
                 tChunks[k].vel += Custom.DirVec(tChunks[k].pos, desiredGrabPos + Custom.DirVec(FloatBase, desiredGrabPos) * 70f) * 0.6f;
             }
         }
     }
     if (attachedAtTip)
     {
         framesWithoutReaching = 0;
         if (SharedPhysics.RayTraceTilesForTerrain(room, BasePos, grabDest.Value))
         {
             if (!Custom.DistLess(Tip.pos, connectedChunk.pos, maxLength))
             {
                 ReleaseGrip();
             }
             if (!Custom.DistLess(Tip.pos, connectedChunk.pos, maxLength * 0.9f))
             {
                 walkerBeast.heldBackByLeg = true;
             }
         }
         else
         {
             ReleaseGrip();
         }
         if (playStepSound)
         {
             if (stepSoundVol > 0.5f)
             {
                 room.PlaySound(SoundID.Vulture_Tentacle_Grab_Terrain, Tip.pos, Mathf.InverseLerp(0.5f, 1f, stepSoundVol) * Mathf.InverseLerp(7f, 45f, Vector2.Distance(Tip.pos, Tip.lastPos)), 1f);
             }
             playStepSound = false;
         }
         stepSoundVol = 0f;
     }
     else
     {
         stepSoundVol  = Mathf.Min(1f, stepSoundVol + 0.025f);
         playStepSound = true;
         FindGrabPos();
         framesWithoutReaching++;
         if ((float)framesWithoutReaching > 60f && floatGrabDest == null)
         {
             framesWithoutReaching = 0;
         }
     }
     if (debugViz)
     {
         grabGoalSprites[1].pos = desiredGrabPos;
     }
 }