diff --git a/src/minecraft/dark/library/orbit/IOrbitingEntity.java b/src/minecraft/dark/library/orbit/IOrbitingEntity.java new file mode 100644 index 00000000..be35f524 --- /dev/null +++ b/src/minecraft/dark/library/orbit/IOrbitingEntity.java @@ -0,0 +1,16 @@ +package dark.library.orbit; + +import universalelectricity.core.vector.Vector3; + +public interface IOrbitingEntity +{ + /** + * Gets the current orbit the object is using + */ + public OrbitNetworkRing getOrbit(); + + /** + * Tells this object were it should be in the orbit + */ + public void setOrbitWayPoint(Vector3 vec); +} diff --git a/src/minecraft/dark/library/math/OrbitNetworkRing.java b/src/minecraft/dark/library/orbit/OrbitNetworkRing.java similarity index 59% rename from src/minecraft/dark/library/math/OrbitNetworkRing.java rename to src/minecraft/dark/library/orbit/OrbitNetworkRing.java index 01b5dee7..0f0f330d 100644 --- a/src/minecraft/dark/library/math/OrbitNetworkRing.java +++ b/src/minecraft/dark/library/orbit/OrbitNetworkRing.java @@ -1,4 +1,4 @@ -package dark.library.math; +package dark.library.orbit; import java.util.HashMap; import java.util.Iterator; @@ -7,14 +7,31 @@ import java.util.Map.Entry; import net.minecraft.entity.Entity; import universalelectricity.core.vector.Vector3; +/** + * Designed to be used by flying Entities to create an orbit pattern around a central point + * + * @author DarkGuardsman + * + */ public class OrbitNetworkRing { + /* DEFINED IDEAL OBJECTS NUMBERS OF ORBIT */ + public static final int minObjects = 3; + public static final int maxObjects = 20; + + /* CURRENT RADIUS OF THE CIRCLE */ float orbitRadius; + + /* CHANGE IN ROTATION OF THE CIRCLE X Y Z */ Vector3 rotationChange = new Vector3(0, 0, 0); - HashMap orbitMemeber = new HashMap(); + /* OBJECTS IN ORBIT */ + HashMap orbitMemeber = new HashMap(); - public OrbitNetworkRing(HashMap entities) + /** + * @param entities - entities to add to this orbit when its created < Entity, Radius change> + */ + public OrbitNetworkRing(HashMap entities) { if (entities != null) { @@ -22,17 +39,30 @@ public class OrbitNetworkRing } } - public HashMap getOrbitMemebers() + public boolean canOrbitExist() + { + int members = this.getOrbitMemebers().size(); + if (members > maxObjects || members < minObjects) + { + return false; + } + return true; + } + + /** + * Gets the list of Entities in this orbit + */ + public HashMap getOrbitMemebers() { if (this.orbitMemeber == null) { - this.orbitMemeber = new HashMap(); + this.orbitMemeber = new HashMap(); } return this.orbitMemeber; } /** - * Increase the rotation angles of the orbitRing + * Increase/changes the rotation angles of the orbit * * @param vec - rotation change stored as a vector3 * @param increase - add the vec rotation to current rotation @@ -65,21 +95,20 @@ public class OrbitNetworkRing public float getMinRadius() { float width = 0; - Iterator> it = this.getOrbitMemebers().entrySet().iterator(); + Iterator> it = this.getOrbitMemebers().entrySet().iterator(); while (it.hasNext()) { - Entity entity = it.next().getKey(); - width += entity.width; + IOrbitingEntity entity = it.next().getKey(); + if (entity instanceof Entity) + { + width += ((Entity) entity).width; + } } width = width / this.getOrbitMemebers().size(); return ((width + (width / 2)) * this.getOrbitMemebers().size()); } /** - * - * @param objectSize - side of the object in the direction it will orbit - * @param radIncrase - increase in radius size - * @param objects - number of the objects in the orbit * @param pos - position in the orbit * @return offset distance from orbit center *