working
This commit is contained in:
38
tools/java/LandtrainConstraintAuthHelper.java
Normal file
38
tools/java/LandtrainConstraintAuthHelper.java
Normal file
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user