Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 KB | None | 0 0
  1.     if (self.impaleChunk == null)
  2.     {
  3.         return;
  4.     }
  5.     self.stuckTime += 0.00357142859f;
  6.     float num = Custom.LerpMap(self.stuckTime, 0.4f, 1f, 1f, 0.5f);
  7.     self.attackReady = 1f;
  8.     self.flyingThisFrame = (self.stuckTime > 0.5f && self.Consious);
  9.     for (int i = 0; i < self.impaleDistances.GetLength(0); i++)
  10.     {
  11.         float d = Custom.LerpMap((float)i, 1f, (float)(self.bodyChunks.Length - 1), 1f, 0.1f) * num;
  12.         Vector2 a = Custom.DirVec(self.bodyChunks[i].pos, self.impaleChunk.pos) * (Vector2.Distance(self.bodyChunks[i].pos, self.impaleChunk.pos) - self.impaleDistances[i, 0]);
  13.         float num2 = self.impaleChunk.mass / (self.bodyChunks[i].mass + self.impaleChunk.mass);
  14.         self.bodyChunks[i].vel += a * num2 * d;
  15.         self.bodyChunks[i].pos += a * num2 * d;
  16.         self.impaleChunk.vel -= a * (1f - num2) * d;
  17.         self.impaleChunk.pos -= a * (1f - num2) * d;
  18.         if (rot && self.impaleChunk.rotationChunk != null)
  19.         {
  20.             a = Custom.DirVec(self.bodyChunks[i].pos, self.impaleChunk.rotationChunk.pos) * (Vector2.Distance(self.bodyChunks[i].pos, self.impaleChunk.rotationChunk.pos) - self.impaleDistances[i, 1]);
  21.             num2 = self.impaleChunk.rotationChunk.mass / (self.bodyChunks[i].mass + self.impaleChunk.rotationChunk.mass);
  22.             self.bodyChunks[i].vel += a * num2 * d;
  23.             self.bodyChunks[i].pos += a * num2 * d;
  24.             self.impaleChunk.rotationChunk.vel -= a * (1f - num2) * d;
  25.             self.impaleChunk.rotationChunk.pos -= a * (1f - num2) * d;
  26.         }
  27.     }
  28.     if (self.Consious)
  29.     {
  30.         for (int j = 1; j < self.TotalSegments; j++)
  31.         {
  32.             self.AddSegmentVel(j, self.stuckTime * Custom.RNV() * UnityEngine.Random.value * UnityEngine.Random.value * UnityEngine.Random.value * 18f);
  33.         }
  34.         self.crawlSin += 0.2f + 0.4f * num;
  35.         self.SinMovementInBody(2.5f * ((!self.small) ? 1f : 0.6f) * self.stuckTime, 2.5f * ((!self.small) ? 1f : 0.6f) * self.stuckTime, 0.6f, 0.6f);
  36.     }
  37.     if (self.stuckTime > 1f || (self.stuckTime > 0.2f && (self.grabbedBy.Count > 0 || !(self.impaleChunk.owner is Creature) || !self.room.VisualContact(self.mainBodyChunk.pos, self.impaleChunk.pos))))
  38.     {
  39.         self.stuckTime = 0f;
  40.         self.mainBodyChunk.vel += Custom.DirVec(self.impaleChunk.pos, self.mainBodyChunk.pos) * 9f;
  41.         self.bodyChunks[1].vel += Custom.DirVec(self.impaleChunk.pos, self.mainBodyChunk.pos) * 7f;
  42.         self.impaleChunk = null;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement