39 lines
979 B
Java
39 lines
979 B
Java
package zombie.vehicles;
|
|
|
|
import zombie.characters.IsoGameCharacter;
|
|
|
|
/**
|
|
* Resolves the effective driver for constraint auth in chained towing.
|
|
* For middle vehicles in a chain, prefer the front/lead driver's authority.
|
|
*/
|
|
public final class LandtrainConstraintAuthHelper {
|
|
private LandtrainConstraintAuthHelper() {
|
|
}
|
|
|
|
public static IsoGameCharacter resolveConstraintDriver(BaseVehicle vehicle) {
|
|
if (vehicle == null) {
|
|
return null;
|
|
}
|
|
|
|
IsoGameCharacter driver = vehicle.getDriver();
|
|
if (driver != null) {
|
|
return driver;
|
|
}
|
|
|
|
BaseVehicle front = vehicle.getVehicleTowedBy();
|
|
if (front != null) {
|
|
driver = front.getDriver();
|
|
if (driver != null) {
|
|
return driver;
|
|
}
|
|
}
|
|
|
|
BaseVehicle rear = vehicle.getVehicleTowing();
|
|
if (rear != null) {
|
|
return rear.getDriver();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|