public override bool Hit(Bullet bullet, Vec2 hitPos)
 {
   hitPos += bullet.travelDirNormalized * 2f;
   if (1.0 - ((double) hitPos.y - (double) this.top) / ((double) this.bottom - (double) this.top) < (double) this._fluidLevel)
   {
     this.thickness = 2f;
     Vec2 off = hitPos - this.position;
     bool flag = false;
     foreach (FluidStream hole in this._holes)
     {
       if ((double) (hole.offset - off).length < 2.0)
       {
         hole.offset = off;
         hole.holeThickness += 0.5f;
         flag = true;
         break;
       }
     }
     if (!flag)
     {
       FluidStream fluidStream = new FluidStream(0.0f, 0.0f, (-bullet.travelDirNormalized).Rotate(Rando.Float(-0.2f, 0.2f), Vec2.Zero), 1f, off);
       this._holes.Add(fluidStream);
       fluidStream.streamSpeedMultiplier = 2f;
     }
     this._shakeMult = 1f;
     SFX.Play("bulletHitWater", pitch: Rando.Float(-0.2f, 0.2f));
     return base.Hit(bullet, hitPos);
   }
   this.thickness = 1f;
   return base.Hit(bullet, hitPos);
 }
Example #2
0
        public void FeedEdges()
        {
            if (this._rightCorner != null && (double)this.right > (double)this._rightCorner.corner.x && this._rightCorner.wallCorner)
            {
                this.x -= this.right - this._rightCorner.corner.x;
            }
            if (this._leftCorner != null && (double)this.left < (double)this._leftCorner.corner.x && this._leftCorner.wallCorner)
            {
                this.x += this._leftCorner.corner.x - this.left;
            }
            if (this._rightCorner != null && (double)this.right > (double)this._rightCorner.corner.x && !this._rightCorner.wallCorner)
            {
                float feedAmount = this.DistanceToFeedAmount(this.right - this._rightCorner.corner.x);
                this.x -= (float)(((double)this.right - (double)this._rightCorner.corner.x) / 2.0);
                if (this._rightStream == null)
                {
                    this._rightStream = new FluidStream(this._rightCorner.corner.x - 2f, this.y, new Vec2(1f, 0.0f), 1f);
                }
                this._rightStream.position.y = this.y - this._collisionOffset.y;
                this._rightStream.position.x = this._rightCorner.corner.x + 2f;
                this._rightStream.Feed(this.data.Take(feedAmount));
            }
            this._wide = this.FeedAmountToDistance(this.data.amount);
            float num1 = this._wide + 4f;

            this._collisionOffset.x = (float)-((double)num1 / 2.0);
            this._collisionSize.x   = num1;
            if (this._leftCorner != null && (double)this.left < (double)this._leftCorner.corner.x && !this._leftCorner.wallCorner)
            {
                float feedAmount = this.DistanceToFeedAmount(this._leftCorner.corner.x - this.left);
                this.x += (float)(((double)this._leftCorner.corner.x - (double)this.left) / 2.0);
                if (this._leftStream == null)
                {
                    this._leftStream = new FluidStream(this._leftCorner.corner.x - 2f, this.y, new Vec2(-1f, 0.0f), 1f);
                }
                this._leftStream.position.y = this.y - this._collisionOffset.y;
                this._leftStream.position.x = this._leftCorner.corner.x - 2f;
                this._leftStream.Feed(this.data.Take(feedAmount));
            }
            this._wide = this.FeedAmountToDistance(this.data.amount);
            float num2 = this._wide + 4f;

            this._collisionOffset.x = (float)-((double)num2 / 2.0);
            this._collisionSize.x   = num2;
        }