Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DoEntityPush() {
- for (int id = 0; id < EntityList.MaxCount; id++) {
- Entity other = game.Entities.List[id];
- if (other == null || other == entity) continue;
- if (!other.Model.Pushes) continue;
- bool yIntersects =
- entity.Position.Y <= (other.Position.Y + other.Size.Y) &&
- other.Position.Y <= (entity.Position.Y + entity.Size.Y);
- if (!yIntersects) continue;
- float dX = other.Position.X - entity.Position.X;
- float dZ = other.Position.Z - entity.Position.Z;
- float dist = dX * dX + dZ * dZ;
- if (dist < 0.0001f || dist > 1f) continue; // TODO: range needs to be lower?
- Vector3 dir = Vector3.Normalize(dX, 0, dZ);
- entity.Velocity -= dir * (1 - dist) / 32f; // TODO: should be 24/25
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement