package com.ezardlabs.lostsector.ai;

import com.ezardlabs.dethsquare.Transform;

public class RangedBehaviour extends Behaviour {
	private final float range;

	RangedBehaviour(float moveSpeed, boolean willPatrol, float visionRange, float range) {
		super(moveSpeed, willPatrol, visionRange);
		this.range = range;
	}

	@Override
	protected CombatState onEnemySighted(Transform self, Transform enemy) {
		if (Math.abs(self.position.x - enemy.position.x) <= range) {
			return CombatState.ATTACKING;
		} else {
			return CombatState.TRACKING;
		}
	}

	@Override
	protected CombatState attack(Transform self, Transform target) {
		return null;
	}

	public static class Builder extends Behaviour.Builder<Builder> {
		private float range = 1500;

		public Builder setRange(float range) {
			this.range = range;
			return this;
		}

		@Override
		public RangedBehaviour create() {
			return new RangedBehaviour(moveSpeed, willPatrol, visionRange, range);
		}
	}
}

@@ -73,16 +73,88 @@
 ansform;
+%0Aimport com.ezardlabs.lostsector.ai.RangedBehaviour.Builder.ShootAction;
 %0A%0Apublic
@@ -223,16 +223,56 @@
 t range;
+%0A%09private final ShootAction shootAction;
 %0A%0A%09Range
@@ -345,24 +345,49 @@
  float range
+, ShootAction shootAction
 ) %7B%0A%09%09super(
@@ -445,16 +445,50 @@
  range;%0A
+%09%09this.shootAction = shootAction;%0A
 %09%7D%0A%0A%09@Ov
@@ -797,19 +797,73 @@
 %7B%0A%09%09
-return null
+shootAction.onShoot(self, target);%0A%09%09return CombatState.ATTACKING
 ;%0A%09%7D
@@ -959,16 +959,51 @@
  = 1500;
+%0A%09%09private ShootAction shootAction;
 %0A%0A%09%09publ
@@ -1081,16 +1081,131 @@
 s;%0A%09%09%7D%0A%0A
+%09%09public Builder setShootAction(ShootAction shootAction) %7B%0A%09%09%09this.shootAction = shootAction;%0A%09%09%09return this;%0A%09%09%7D%0A%0A
 %09%09@Overr
@@ -1311,24 +1311,127 @@
 Range, range
+, shootAction);%0A%09%09%7D%0A%0A%09%09public interface ShootAction %7B%0A%0A%09%09%09void onShoot(Transform self, Transform target
 );%0A%09%09%7D%0A%09%7D%0A%7D%0A

Allow for ranged enemies to define what exactly they do when they shoot