package EscaperSensor import public SetupObject import Escaper import Sensor public class EscaperSensorSetup extends SetupObject use Sensor protected var sensorHeight = 32. construct(vec3 pos, player owner, int unitId, angle facing, real radius, real sensorHeight) super(createUnit(owner, unitId, pos, facing)..addAbility(LOCUST_ID), createUnit(owner, unitId, pos, facing), radius) this.sensorHeight = sensorHeight addSensorListener(this, (UnitEntity source, UnitEntity target) -> onSensor(source, target)) construct(vec3 pos, player owner, int actorId, int setupId, angle facing, real radius, real sensorHeight) super(createUnit(owner, actorId, pos, facing)..addAbility(LOCUST_ID), createUnit(owner, setupId, pos, facing), radius) this.sensorHeight = sensorHeight addSensorListener(this, (UnitEntity source, UnitEntity target) -> onSensor(source, target)) construct(vec3 pos, player owner, int unitId, real radius, real sensorHeight) super(createUnit(owner, unitId, pos, angle(0))..addAbility(LOCUST_ID), createUnit(owner, unitId, pos, angle(0)), radius) this.sensorHeight = sensorHeight addSensorListener(this, (UnitEntity source, UnitEntity target) -> onSensor(source, target)) construct(unit pactor, real radius, real sensorHeight) super(createUnit(pactor.getOwner(), pactor.getTypeId(), pactor.getPos3Zero(), pactor.getFacingAngle())..addAbility(LOCUST_ID), pactor, radius) this.sensorHeight = sensorHeight setXY(pactor.getPos().toVec3() + vec2(0.01, 0)) addSensorListener(this, (UnitEntity source, UnitEntity target) -> onSensor(source, target)) function onSensor(UnitEntity source, UnitEntity target) if target instanceof Escaper let zdelta = source.getPos().z - target.pos.z if zdelta.abs() <= sensorHeight let escaper = target castTo Escaper escaper.kill(this) override function setFlying(boolean flag) if flying and not flag setVel(ZERO3) super.setFlying(flag) public class StaticEscaperSensorSetup extends StaticSetupObject protected var sensorHeight = 32. construct(vec3 pos, player owner, int unitId, angle facing, real radius, real sensorHeight) super(createUnit(owner, unitId, pos, facing)..addAbility(LOCUST_ID), createUnit(owner, unitId, pos, facing), radius, () -> onSensorEvent()) this.sensorHeight = sensorHeight construct(vec3 pos, player owner, int actorId, int setupId, angle facing, real radius, real sensorHeight) super(createUnit(owner, actorId, pos, facing)..addAbility(LOCUST_ID), createUnit(owner, setupId, pos, facing), radius, () -> onSensorEvent()) this.sensorHeight = sensorHeight construct(vec3 pos, player owner, int unitId, real radius, real sensorHeight) super(createUnit(owner, unitId, pos, angle(0))..addAbility(LOCUST_ID), createUnit(owner, unitId, pos, angle(0)), radius, () -> onSensorEvent()) this.sensorHeight = sensorHeight construct(unit pactor, real radius, real sensorHeight) super(createUnit(pactor.getOwner(), pactor.getTypeId(), pactor.getPos3Zero(), pactor.getFacingAngle())..addAbility(LOCUST_ID), pactor, radius, () -> onSensorEvent()) this.sensorHeight = sensorHeight setXY(pactor.getPos().toVec3() + vec2(0.01, 0)) static function onSensorEvent() let obj = GetTriggeringTrigger().getSource().getEntity() castTo StaticEscaperSensorSetup obj.onSensor() function onSensor() let target = GetTriggerUnit().getEntity() if target instanceof Escaper let zdelta = getPos().z - target.pos.z if zdelta.abs() <= sensorHeight let escaper = target castTo Escaper escaper.kill(this) override function setFlying(boolean flag) if flying and not flag setVel(ZERO3) super.setFlying(flag)