/*
 * This file is part of Dynamic Surroundings, licensed under the MIT License (MIT).
 *
 * Copyright (c) OreCruncher
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.blockartistry.DynSurround.client.aurora;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import javax.annotation.Nonnull;

/**
 * Preset geometry of an Aurora. A preset is selected by the server when an
 * Aurora spawns.
 */
public final class AuroraGeometry {

	public final int length;
	public final float nodeLength;
	public final float nodeWidth;
	public final int bandOffset;
	public final int alphaLimit;

	private static final List<AuroraGeometry> PRESET = new ArrayList<AuroraGeometry>();

	static {
		// 10/5; 90/45
		PRESET.add(new AuroraGeometry(128, 30.0F, 2.0F, 45, 48));
		PRESET.add(new AuroraGeometry(128, 15.0F, 2.0F, 27, 48));
		PRESET.add(new AuroraGeometry(64, 30.0F, 2.0F, 45, 48));
		PRESET.add(new AuroraGeometry(64, 15.0F, 2.0F, 27, 48));

		PRESET.add(new AuroraGeometry(128, 30.0F, 2.0F, 45, 32));
		PRESET.add(new AuroraGeometry(128, 15.0F, 2.0F, 27, 32));
		PRESET.add(new AuroraGeometry(64, 30.0F, 2.0F, 45, 32));
		PRESET.add(new AuroraGeometry(64, 15.0F, 2.0F, 27, 32));

		PRESET.add(new AuroraGeometry(128, 30.0F, 2.0F, 45, 16));
		PRESET.add(new AuroraGeometry(128, 15.0F, 2.0F, 27, 16));
		PRESET.add(new AuroraGeometry(64, 30.0F, 2.0F, 45, 16));
		PRESET.add(new AuroraGeometry(64, 15.0F, 2.0F, 27, 16));
	}

	private AuroraGeometry(final int length, final float nodeLength, final float nodeWidth, final int bandOffset,
			final int alphaLimit) {
		this.length = length;
		this.nodeLength = nodeLength;
		this.nodeWidth = nodeWidth;
		this.bandOffset = bandOffset;
		this.alphaLimit = alphaLimit;
	}

	@Nonnull
	public static AuroraGeometry get(@Nonnull final Random random) {
		final int idx = random.nextInt(PRESET.size());
		return PRESET.get(idx);
	}

	@Override
	@Nonnull
	public String toString() {
		final StringBuilder builder = new StringBuilder();
		builder.append("bandLength:").append(this.length);
		builder.append(";nodeLength:").append(this.nodeLength);
		builder.append(";nodeWidth:").append(this.nodeWidth);
		builder.append(";bandOffset:").append(this.bandOffset);
		builder.append(";alphaLimit:").append(this.alphaLimit);
		return builder.toString();
	}
}
@@ -1805,34 +1805,34 @@
 0.0F, 2.0F, 45, 
-48
+96
 ));%0A%09%09PRESET.add
@@ -1869,26 +1869,26 @@
 , 2.0F, 27, 
-48
+96
 ));%0A%09%09PRESET
@@ -1932,18 +1932,18 @@
 0F, 45, 
-48
+96
 ));%0A%09%09PR
@@ -1995,10 +1995,10 @@
 27, 
-48
+96
 ));%0A
@@ -2044,34 +2044,34 @@
 0.0F, 2.0F, 45, 
-32
+64
 ));%0A%09%09PRESET.add
@@ -2108,26 +2108,26 @@
 , 2.0F, 27, 
-32
+64
 ));%0A%09%09PRESET
@@ -2171,18 +2171,18 @@
 0F, 45, 
-32
+64
 ));%0A%09%09PR
@@ -2234,10 +2234,10 @@
 27, 
-32
+64
 ));%0A
@@ -2283,34 +2283,34 @@
 0.0F, 2.0F, 45, 
-16
+32
 ));%0A%09%09PRESET.add
@@ -2347,26 +2347,26 @@
 , 2.0F, 27, 
-16
+32
 ));%0A%09%09PRESET
@@ -2410,18 +2410,18 @@
 0F, 45, 
-16
+32
 ));%0A%09%09PR
@@ -2473,10 +2473,10 @@
 27, 
-16
+32
 ));%0A

Make auroras have more alpha so they show more