2022-04-30 09:41:17 -04:00
|
|
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
|
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
|
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
|
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
|
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
|
|
|
// Magicbane Emulator Project © 2013 - 2022
|
|
|
|
|
// www.magicbane.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package engine.net.client.handlers;
|
|
|
|
|
|
2024-01-03 19:47:30 -06:00
|
|
|
import engine.InterestManagement.WorldGrid;
|
2022-04-30 09:41:17 -04:00
|
|
|
import engine.exception.MsgSendException;
|
2024-01-03 19:47:30 -06:00
|
|
|
import engine.gameManager.ChatManager;
|
2024-01-05 19:28:43 -06:00
|
|
|
import engine.CollisionEngine.CollisionManager;
|
2022-04-30 09:41:17 -04:00
|
|
|
import engine.gameManager.MovementManager;
|
2024-01-03 19:47:30 -06:00
|
|
|
import engine.math.Vector3fImmutable;
|
2022-04-30 09:41:17 -04:00
|
|
|
import engine.net.client.ClientConnection;
|
|
|
|
|
import engine.net.client.msg.ClientNetMsg;
|
|
|
|
|
import engine.net.client.msg.MoveToPointMsg;
|
2023-09-10 14:08:54 -05:00
|
|
|
import engine.objects.*;
|
2024-01-03 19:47:30 -06:00
|
|
|
import engine.server.MBServerStatics;
|
|
|
|
|
|
|
|
|
|
import java.awt.geom.Line2D;
|
2022-04-30 09:41:17 -04:00
|
|
|
|
2024-01-03 20:39:18 -06:00
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
2022-04-30 09:41:17 -04:00
|
|
|
public class MoveToPointHandler extends AbstractClientMsgHandler {
|
|
|
|
|
|
|
|
|
|
public MoveToPointHandler() {
|
|
|
|
|
super(MoveToPointMsg.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
2023-07-15 09:23:48 -04:00
|
|
|
ClientConnection origin) throws MsgSendException {
|
2022-04-30 09:41:17 -04:00
|
|
|
MoveToPointMsg msg = (MoveToPointMsg) baseMsg;
|
2023-09-11 01:36:45 -05:00
|
|
|
PlayerCharacter pc = origin.getPlayerCharacter();
|
|
|
|
|
if(pc == null)
|
2023-09-10 19:37:46 -05:00
|
|
|
return true;
|
|
|
|
|
|
2024-01-03 19:47:30 -06:00
|
|
|
//check for collisions
|
|
|
|
|
Line2D travelLine = new Line2D.Float();
|
|
|
|
|
Vector3fImmutable endLoc = new Vector3fImmutable(msg.getEndLat(),msg.getEndAlt(),msg.getEndLon());
|
|
|
|
|
travelLine.setLine(pc.loc.x,pc.loc.z,endLoc.x,endLoc.z);
|
2024-01-03 20:39:18 -06:00
|
|
|
float movementDistance = 185 + pc.loc.distance(endLoc);
|
|
|
|
|
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(pc.loc, movementDistance, MBServerStatics.MASK_BUILDING);
|
|
|
|
|
for(AbstractWorldObject awo : awoList){
|
2024-01-03 19:47:30 -06:00
|
|
|
Building building = (Building)awo;
|
2024-01-05 19:21:24 -06:00
|
|
|
if(CollisionManager.CollisionDetected(building, travelLine,pc.getCharacterHeight())){
|
|
|
|
|
ChatManager.chatSystemInfo(pc, "Collision Detected");
|
|
|
|
|
//msg.setEndCoord();
|
|
|
|
|
MovementManager.movement(msg, pc);
|
|
|
|
|
return true;
|
2024-01-05 19:06:56 -06:00
|
|
|
}
|
2024-01-03 19:47:30 -06:00
|
|
|
}
|
2024-01-05 19:21:24 -06:00
|
|
|
ChatManager.chatSystemInfo(pc, "No Collision Detected");
|
2023-09-10 19:37:46 -05:00
|
|
|
MovementManager.movement(msg, pc);
|
2022-04-30 09:41:17 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|