Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1.         public void DoEntityPush() {
  2.             for (int id = 0; id < EntityList.MaxCount; id++) {
  3.                 Entity other = game.Entities.List[id];
  4.                 if (other == null || other == entity) continue;
  5.                 if (!other.Model.Pushes) continue;
  6.                
  7.                 bool yIntersects =
  8.                     entity.Position.Y <= (other.Position.Y + other.Size.Y) &&
  9.                     other.Position.Y  <= (entity.Position.Y + entity.Size.Y);
  10.                 if (!yIntersects) continue;
  11.                
  12.                 float dX = other.Position.X - entity.Position.X;
  13.                 float dZ = other.Position.Z - entity.Position.Z;
  14.                 float dist = dX * dX + dZ * dZ;
  15.                 if (dist < 0.0001f || dist > 1f) continue; // TODO: range needs to be lower?
  16.                
  17.                 Vector3 dir = Vector3.Normalize(dX, 0, dZ);
  18.                 entity.Velocity -= dir * (1 - dist) / 32f; // TODO: should be 24/25
  19.             }
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement